weixin_39671621
weixin_39671621
2021-01-09 06:15

Add a warning for Windows users that Windows Defender might delay the server boot

Purpose and Motivation

cf. #4368

I've spent a lot of time trying to figure out why Windows Defender might delay server boot but recent Windows Defender updates makes it more and more difficult to debug it as I can reproduce the problem only once a day approximately, whereas I could reproduce it after every boot a few months ago. It means that I can only debug once per day... I am not proud of that PR but I don't know what else to do to go ahead with this issue.

Types of changes

Add a warning. I split the warning into four lines so that you can read it in the post window. Not sure about that one.

To-do list

  • [ ] Code is tested
  • [ ] All tests are passing
  • [ ] Updated documentation
  • [X] This PR is ready for review

该提问来源于开源项目:supercollider/supercollider

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

9条回答

  • weixin_39880899 weixin_39880899 4月前

    If we can't pinpoint it, I think that printing a warning is a reasonable action. I wonder what others think.

    I have 2 suggestions: - maybe we could only print it if the server did not boot after X seconds?

    supercollider
    Platform.case(
        \windows, {
            {
                if(this.serverRunning.not, {
                    "Warning : on some Windows-based machines, Windows Defender".postln;
                    ...
                });
            }.defer(6) //or whatever is a reasonable wait time...
        }
    );
    
    • For newlines, I'm on the fence. If there are newlines in the message, it might be cleaner to write
    "Warning : on some Windows-based machines, Windows Defender\nsometimes delays server boot by one minute.(...)".postln;
    • Maybe a one line warning, followed by an explanation without line breaks?
    supercollider
    "Server: possible boot delay".warn;
    "On some Windows-based machines, Windows Defender sometimes delays server boot (...)".postln;
    

    These are just ideas, not sure if others would like them, especially that the whole thing is anything but elegant...

    点赞 评论 复制链接分享
  • weixin_39671621 weixin_39671621 4月前

    Thanks Marcin ! I implemented your two suggestions and it's better ! The only downside is that the warning will be displayed if the server fails to boot for another reason, which may lead to confusion. I don't know if it's possible to get the last server boot status code.

    点赞 评论 复制链接分享
  • weixin_39880899 weixin_39880899 4月前

    How about

    supercollider
    Platform.case(
        \windows, {
            warnRoutine !? {warnRoutine.stop}; // in case boot is requested more than once
            warnRoutine = fork{
                7.wait;
                if (this.serverRunning.not) {
                    "Server: possible boot delay.".warn;
                    "On some Windows-based machines, Windows Defender sometimes delays server boot by one minute.".postln;
                    "You can add scsynth.exe process to Windows Defender exclusion list to disable this check. It's safe.".postln;                      
                };
            };
        }
    );
    

    and then adding something like

    supercollider
    prOnServerProcessExit { |exitCode|
        (...)
        Platform.case(
            \windows, {
                warnRoutine.stop;
                warnRoutine = nil;
            }
        )
    }
    

    Also not sure if we need to clean up after this?

    点赞 评论 复制链接分享
  • weixin_39775577 weixin_39775577 4月前

    the warning should probably go in scsynth, so that clients besides sclang are aware. i can give you pointers on how to do that if you want.

    点赞 评论 复制链接分享
  • weixin_39671621 weixin_39671621 4月前

    Thanks Brian ! Yes, I would not mind pointers if it's not too much work for you !

    点赞 评论 复制链接分享
  • weixin_39775577 weixin_39775577 4月前

    sorry for the long delay!

    here's an overview of what my suggestion would entail: - when the server is booted in RT mode (and maybe NRT mode? not sure, i haven't encountered this), launch a secondary thread that sleeps for several seconds using the 2nd overload of https://en.cppreference.com/w/cpp/thread/condition_variable/wait_for on a shared condition_variable and mutex; the example code on that page illustrates the general idea. the predicate should test a shared boolean flag that's initially false - when the server finishes booting (you'll have to decide the proper indicator for this) set the flag to true and notify the cv - do the same thing (set the flag to true and notify) at the end of main to prevent that thread from crashing the application on exit - you can use the return value from wait_for to determine whether the flag was ever set or not, if it wasn't then post the error - only do this on windows

    点赞 评论 复制链接分享
  • weixin_39671621 weixin_39671621 4月前

    Thank you Brian for the detailed suggestion !

    点赞 评论 复制链接分享
  • weixin_39775577 weixin_39775577 4月前

    no problem! feel free to hit me up on slack if you have questions

    点赞 评论 复制链接分享
  • weixin_39671621 weixin_39671621 4月前

    Closing this PR, I'm doing a fresh new one !

    点赞 评论 复制链接分享

相关推荐