Search Unity

[UWP] Application hangs when suspended in a loading screen

Discussion in 'Windows' started by MichaelDae, Nov 21, 2016.

  1. MichaelDae

    MichaelDae

    Joined:
    Mar 17, 2015
    Posts:
    4
    Hi,

    we are porting a game to UWP which runs quite fine, though on some machines, we are seeing the reproducible issue that, when minimizing & suspending while in a loading screen, the game freezes. At some point this also happend while being in a scene, though we could fix that by disabling 'Application.RunInBackground'.

    There is no specific error message that hints on something that could be wrong. I suspect that there's something blocking the engine from suspending the D3D device, because in most logs the line "Trimming D3D resources." is missing. Sometimes the game code is still running, so there is still log ouptut from the game after resuming the game.
    Though, when suspending again, Windows will kill the game because it is not responding to the suspend call in time.

    Is there anything we could have missed ? As far as I can see we don't have the option to retrieve the graphics device and call Trim() manually, without creating a native plugin (and I'd really like to avoid that).

    I also tried to create a repo project, but I was unable to reproduce this in smaller projects til now. But I will continue working on that.

    A bit of information about our configuration:
    The Unity version is 5.3.5p8, I looked through all the patch/release notes for the newer versions, but could not find anything related.
    The project is D3D and we are building master builds, so the code is .NET native.
    Application.RunInBackground is disabled.
    We are not doing anything in the suspend/resume handler.
    We are changing scenes using LoadAsync.
    The content is loaded from Assetbundles asynchronously..


    Thanks,
    Michael
     
  2. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Are you able to reproduce this easily? Best way to figure out what the engine is doing during that time is to profile it. Here's a nice (I'm biased) guide on how to use Windows Performance Analyzer:

    http://files.unity3d.com/zilys/ETWPerfGuide/data/AnalyzingPerformanceUsingETW.html

    Basically, you'd have to look for what the Unity's main thread is doing after the suspend event is received by the application. If you can't figure it out, you can always send me the trace in a PM and I'll be able to take a look.

    Just from the description, I can't really tell what's going on.
     
  3. MichaelDae

    MichaelDae

    Joined:
    Mar 17, 2015
    Posts:
    4
    Hi,

    thanks for the hint. I created a couple of performance and network traces but still can't really see what is happening.
    What I can see though is that, when resuming, the ApplicationFrameHost is running getting the focus first, just like usual alt-tabbing, but the game is never re-activated.
    Another thing I just saw is that, whenever I break the application, I have a couple of Tasks named "WinRT operation as Task" beeing stuck in "Scheduled and waiting to run". They are most likely caused by opening files using GetFileFromPathAsync/OpenStreamForReadAsync..
    Could this be a problem for suspending the app ?

    One thing I forgot to mention is that we are using Xbox live services, including storage, achievements, and presence.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Could you PM me the traces so I could take a look?
     
  5. MichaelDae

    MichaelDae

    Joined:
    Mar 17, 2015
    Posts:
    4
    I'll try to make a shorter trace so I can send it to you, any particular trace options you need ?
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
  7. MichaelDae

    MichaelDae

    Joined:
    Mar 17, 2015
    Posts:
    4
    Unfortunately, the WPR tool crashes on the laptop (where I can easily reproduce the issue), when I try to load any WPR profile. I'll have a look into that and will send you a PM when I managed to load and record.
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Try installing the latest windows 10 SDK - they had bunch of fixes in the last one.
     
  9. liangpengcheng

    liangpengcheng

    Joined:
    Nov 19, 2016
    Posts:
    2
    I have the same problem .....
     
  10. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Got any more information than that? What's happening exactly? Which Unity version are you on