Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Help with UWP port exceptions

Discussion in 'Windows' started by WildframeXbox, Apr 16, 2018.

  1. WildframeXbox

    WildframeXbox

    Joined:
    Oct 13, 2017
    Posts:
    18
    Hi,
    We are currently focusing on finishing the UWP but suddenly some constant exceptions have started appearing in the output window when playing the game.

    I've isolated some of those exceptions but I don't really know how to solve them or what is the problem. I'ts important to notice that these exceptions are not happening in any other platform.

    The first one seems to be happening whenever someone calls DiscardContents with DXD11. We have two post-processes that use temporary RenderTextures, and following the call stack they lead to a call to ReleaseTemporary.
    Another one happens inside the Windows.Xbox.Services.dll and I don't know how I can extract more info about this one so here is a capture of the call stack in case it can be useful
    OtherCallstack.PNG

    I'm deploying to local machine with Visual Studio 2017 and the build was made with Unity 2017.2.1p2. I'm also using the latest release of the Xbox Live API (1711) unity plugin.

    Hope someone can help because we are getting serious performance spikes in UWP because of the garbage collector and the only thing we can think that is causing them are those exceptions.
     
  2. Barkers-Crest

    Barkers-Crest

    Joined:
    Jun 19, 2013
    Posts:
    159
    I can't speak specifically to your exceptions, but for Garbage Collections have you tried running in Master mode?

    We get collections in Release Mode (you can tell by the yellow notch in Visual Studio Profiler) but do not in Master.
     
  3. phipro

    phipro

    Microsoft Employee

    Joined:
    Aug 19, 2013
    Posts:
    123
    If you are having issues with the Xbox Live Plugin, feel free to report those issues on GitHub so the team can take a look.

    https://github.com/Microsoft/xbox-live-unity-plugin
    The callstack you have posted there doesn't include symbols, and without them we can't really see what's going on.
     
  4. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    Do you have any proof those exceptions are causing garbage collection issues? That seems unlikely - the exceptions you mention are C++ exceptions and they have nothing to do with garbage collection.

    Did you try profiling the game to see whether that's where the perf issues are coming from? These exceptions are happening inside Windows components, and they're caught, so they don't cause any crashes. They can still cause perf issues if a lot of them are happening per frame and especially if you have a debugger attached, but that should be first proven with a profiler before they can be blamed (I have yet to see a game where this was an issue).
     
  5. WildframeXbox

    WildframeXbox

    Joined:
    Oct 13, 2017
    Posts:
    18
    @Barkers-Crest, I don't really think it will solve the problem but I'll check.

    @phipro We are not using that plugin as it seems that it is not necessary with IL2CPP and .NET4.6. Following this page https://docs.microsoft.com/en-us/wi...started-with-partner/partner-unity-uwp-il2cpp I'm using this plugin https://github.com/Microsoft/xbox-live-api/releases .However, I will post an issue there.

    @Tautvydas-Zilys I have no proof that those exceptions are what are causing the garbage collection issues but I cannot think of something else as the other platforms are not experiencing this performance spikes neither those exceptions.
    Here is a picture of one of those spikes in the profiler:
    GCCollectProfiler.PNG

    And here is one of the DXD11 exception call stack:
    DiscardContentsCallstack.PNG
     
  6. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
  7. WildframeXbox

    WildframeXbox

    Joined:
    Oct 13, 2017
    Posts:
    18
    @Tautvydas-Zilys You were right, the garbage collection issues were not related to those exceptions. Thanks to that tool we were able to find and kill the problem. However the exceptions are still there. The game seems to be working good, but I don't really like to have per-frame exceptions.

    I've isolated the ones that keep appearing every frame and are these two:
    upload_2018-4-18_14-48-7.png

    upload_2018-4-18_14-49-40.png
     
  8. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,644
    What was the problem if you don't mind sharing? Perhaps it will help others.

    As for the exceptions: I'm afraid they're happening inside D3D11 runtime and NVidia drivers - it's not something we can affect, unfortunately.

    I haven't seen the second callstack, but I have investigated the DiscardResource exception before. Microsoft told me it was harmless and we should ignore it. However, are you running with D3D11 debug layers enabled (I think you are, since d3d11_3SDKLayers.dll is in the callstack)? I believe that exception is part of their debugging code. We enable debug layers always in Debug builds, and we enable it in Release builds if you specify "-force-d3d11-debug" command line argument. We never enable it in Master builds.
     
  9. WildframeXbox

    WildframeXbox

    Joined:
    Oct 13, 2017
    Posts:
    18
    Ofc I can share it. Using the tool you suggested we were able to see that in those spikes the most consuming call was the internal function to register to an event, followed by an Array New and Array Copy. Investigating who subscribed to that event (thankfully just a few classes) guide us to find a coroutine that kept registering to that event. I don't know why it was launched more than once, but I changed the StartCoroutine from the OnEnable to a Start and that fixed the problem.

    As they are not affecting gameplay, we can ignore them by now. It will be great to get rid of them if we can in the future.