The following forum(s) are migrating to a new home on Microsoft Q&A (Preview): Developing Universal Windows apps!

Ask new questions on Microsoft Q&A (Preview).
Interact with existing posts until December 13, 2019, after which content will be closed to all new and existing posts.

Learn More

 none
UWP app crashes when the app state changes from Suspended to Resume. RRS feed

  • Question

  • When my UWP app's state changes from Running to Suspended state I can see  OnSuspending event getting triggered. But when I try to run the app back in the foreground, it never triggers the OnResume event.

    To know the previous execution state of the app, I run it again and it gives the value "Not Running", so I am assuming the app is crashing. 

    I can't reproduce this issue in debug mode. How can I find the root cause of this crash?

    Thanks!

    Note: I do use GetDeferral() in the Onsuspending() event.

    Wednesday, October 30, 2019 3:40 PM

All replies

  • Hi,

    Based on you description, you mentioned that the resume event is not triggered. And you checked the previous execution state which shows 'Not Running'. But I have a question here. Does the app close automatically when you try to resume it? If it doesn't close itself, when do you checked the previous execution state? Manually launch the app?  Can you make sure that the onsuspending event is completely executed before you resume your app?

    Best regards,

    Roy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, October 31, 2019 4:16 AM
    Moderator
  • Hey Roy,

    Thanks for your response.

    In my app I have added a log file to track the sequence of the events. When I minimise the app I can see the OnSuspending event getting executed without any exception. After that when I try to run the app in foreground by pressing the xbox button and selecting the app from the list. At this point I can see the app is exited and I can't see OnResume event been triggered.So, I run the app again to check the previous execution state which says "Not Running".

    Example of the logs that I have added:

    1|2019-10-31T14:30:48.4112229+00:00|INFO|3|App|App entering foreground from the background
    2|2019-10-31T14:30:49.9548096+00:00|INFO|3|App|App entered background
    3|2019-10-31T14:30:50.1232941+00:00|INFO|3|App|Entering On Suspending event
    4|2019-10-31T14:30:50.2699291+00:00|INFO|3|App|Exiting On Suspending event
    5|2019-10-31T14:30:52.7718464+00:00|INFO|3|App|the app is resuming
    6|2019-10-31T14:30:52.8270375+00:00|INFO|3|App|App entering foreground from the background
    7|2019-10-31T14:30:54.2958277+00:00|INFO|3|App|App entered background
    8|2019-10-31T14:30:54.5637032+00:00|INFO|3|App|Entering On Suspending event
    9|2019-10-31T14:30:54.6859340+00:00|INFO|3|App|Exiting On Suspending event
    10|2019-10-31T14:30:57.1368347+00:00|INFO|3|App|the app is resuming
    11|2019-10-31T14:30:57.1676128+00:00|INFO|3|App|App entering foreground from the background
    12|2019-10-31T14:30:58.7478892+00:00|INFO|3|App|App entered background
    13|2019-10-31T14:30:58.7660524+00:00|INFO|3|App|Entering On Suspending event
    14|2019-10-31T14:30:59.1253307+00:00|INFO|3|App|Exiting On Suspending event

    From the last log you can see, the app doesn't manage to trigger the OnResume event.

    Thanks,

    Sweta.





    • Edited by Sweta0019 Thursday, October 31, 2019 2:35 PM
    Thursday, October 31, 2019 1:50 PM
  • Hi,

    Thanks for the explanation, I understand it now. It's a strange behavior. If the app is closed by the system, the previous state should be Terminated instead of Not Running. Could you please take a look at the Event Viewer? If the app crashes, there should be error logs in the Event Viewer. You can find the log in Event Viewer -> Applications and Services Logs -> Microsoft -> Windows -> Apps -> Microsoft-Windows-TWinUI/Operational.

    Best regards,

    Roy


    "Developing Universal Windows apps" forum will be migrating to a new home on Microsoft Q&A (Preview)!
    We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!
    For more information, please refer to the sticky post.

    Friday, November 1, 2019 7:03 AM
    Moderator
  • Hi Roy,

    I can't see any error log in the  Event Viewer -> Applications and Services Logs -> Microsoft -> Windows -> Apps -> Microsoft-Windows-TWinUI/Operational. 

    I have added log in App_UnhandledException() and saved the exception in a var in the local storage. But that never has any exception in it.

    I could have derived that the system is closing the app, but as you said because the previous state is "Not Running" instead of "Terminated", I feel it's crash.

    Thanks,

    Sweta.


    • Edited by Sweta0019 Friday, November 1, 2019 12:08 PM
    Friday, November 1, 2019 12:04 PM
  • Hi,

    It's really a strange issue. What's the device that running your app and what's the version? What's the target version of your app? Does this issue happen when your app is running on another device? 

    Another suggestion is that you could try to use App Center  in your app. This could help to get app's diagnostics. 

    Best regards,

    Roy


    "Developing Universal Windows apps" forum will be migrating to a new home on Microsoft Q&A (Preview)!
    We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!
    For more information, please refer to the sticky post.


    Monday, November 4, 2019 6:13 AM
    Moderator
  • Hi,

    I am using Xboxone X and the version is 10.0.18363.7196. The app target version in 1903.

    I already use App Center in the app. But can we get the crash report while I am debugging the app? If yes, where does it gets saved?

    I did try to use the Xbox device Portal in the web to get the Crash dump, but it never shows up anything when that crash happens.

    Just to check if this works, I intentionally make the app to crash and I can see a dump file getting created.

    Thanks,

    Sweta.



    • Edited by Sweta0019 Monday, November 4, 2019 5:06 PM
    Monday, November 4, 2019 2:47 PM
  • Hi,

    I'm sorry to say that I don't have an XboxOne X to test now. But I try to ask other engineers to test this. Could you please share a repro sample with me? A simple demo will be enough. Please delete all the sensitive code and just keep the code that could reproduce the problem. This could help us to locate the problem.

    Best regards,

    Roy


    "Developing Universal Windows apps" forum will be migrating to a new home on Microsoft Q&A (Preview)!
    We invite you to post new questions in the "Developing Universal Windows apps" forum’s new home on Microsoft Q&A (Preview)!
    For more information, please refer to the sticky post.

    Tuesday, November 5, 2019 2:06 AM
    Moderator