Hi, We've been waiting on this fix which I can see is now available in a beta release of Unity 2017. https://issuetracker.unity3d.com/issues/uwp-wsa-runinbackground-doesnt-work-on-uwp-wsa We're still using 5.6 and are unlikely to upgrade to 2017 at this stage, will the fix be backported? Cheers, Alex
I believe Tomas is referring to another issue. I don't yet know what our plans to backport it is, but you can easily work around it yourself by calling this API from your scripts: https://docs.microsoft.com/en-us/windows/uwp/launch-resume/run-minimized-with-extended-execution
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.
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.
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.
How do you determine Update() loop stops running? Are you sure the OS doesn't suspend the process at that point?
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.