Search Unity

Bug 759166 backport

Discussion in 'Windows' started by ameinfjg, Sep 28, 2017.

  1. ameinfjg

    ameinfjg

    Joined:
    Feb 14, 2017
    Posts:
    78
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,916
    hey, it's fixed in 5.2.5f1 and above - that includes 5.6
     
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
  4. ameinfjg

    ameinfjg

    Joined:
    Feb 14, 2017
    Posts:
    78
    Hi guys, thanks for the information.

    I tried the workaround suggested but it doesn't quite work as I would like. Whilst it's true that requesting extended execution prevents the game from suspending it still seems that Update and Coroutines stop running whilst in the background. I suspect this explains why the original fix for the aforementioned bug (in 5.3.1p3) stated;

    "... Note: if application window is minimized it will be still paused, because OS suspends the application"

    So I suspect both is needed - a request to the OS to not suspend and this fix in the Unity engine.
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    So Application.runInBackground currently prevents the engine from pausing itself when you minimize or focus another application. What it doesn't do is that it doesn't prevent application getting suspended (it doesn't use ExtendedExecution). Our fix for that was to start using ExtendedExecution APIs in addition to not pausing the engine. For that workaround to work, you still need to have Application.runInBackground enabled.
     
  6. ameinfjg

    ameinfjg

    Joined:
    Feb 14, 2017
    Posts:
    78
    In my test Run In Background is checked in the player settings. I also tried explicitly calling Application.runInBackground = true on Start but this had no effect. This is using Unity 5.6.2p4, for reference.
     
  7. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    How do you determine Update() loop stops running? Are you sure the OS doesn't suspend the process at that point?
     
  8. ameinfjg

    ameinfjg

    Joined:
    Feb 14, 2017
    Posts:
    78
    I can give you a test project if you like,
    I have both a MonoBehaviour with an Update & a Coroutine and a C# Task with a loop that delays for a second. Each prints debug to the log with the current time.
    Without the ExtendedExecution all halt when the game is minimised. With ExtendedExecution the C# Task continues to log but the MonoBehaviour Update/Coroutine still does not.
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    A project demonstrating the issue would be appreciated.
     
  10. ameinfjg

    ameinfjg

    Joined:
    Feb 14, 2017
    Posts:
    78
    I've attached one. It should be self-explanatory.
     

    Attached Files:

  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    That actually helps. Thank you. I'll look into doing that backport.
     
  12. ameinfjg

    ameinfjg

    Joined:
    Feb 14, 2017
    Posts:
    78
    That's great, thanks. Is there any way I can keep track of that?
     
  13. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Unfortunately, no. But I'll reply to this thread when I know which patch release it will land to.
     
  14. ameinfjg

    ameinfjg

    Joined:
    Feb 14, 2017
    Posts:
    78
    Ok, thanks.
     
  15. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Hey @ameinfjg, I backported the fix and it will be in 5.6.4p2.
     
  16. ameinfjg

    ameinfjg

    Joined:
    Feb 14, 2017
    Posts:
    78
    Excellent. Thanks for the update.