Search code examples
visual-studio-2015windows-store-appswindows-8.1

How to debug frozen Windows Store app


We're developing a Windows app (8.1, non-UWP) which completely freezes when running in the background (minimized) for some time (about half an hour). The app will show the regular user interface but won't respond to UI events. Windows does not detect that the application is "Not responding" (what happens e.g. on Windows Forms if the main thread is blocked).

When the app freezes, the debugger of Visual Studio 2015 aborts with the following message:

The network connection to has been lost. Debugging ist aborted.

I'm having a hard time to debug this issue. What I've already tried:

  • Suspending and resuming the app from within Visual Studio (doesn't trigger the issue)
  • Disabling all background tasks which could probably cause the UI thread to be blocked
  • Checking all available log sources for additional information (Event Logs etc.) - no entries there
  • Running the app on different hardware - same issue
  • Attaching a debugger to the app process in stucked state - shows main thread in "External code"
  • No difference between release/debug mode

So my question is: How to debug a Windows store app freezing when running in the background.


Solution

  • Add Debug.WriteLine("") to all the UI and background functions (Entry, success, and exception points) which you might suspect causing issues. Write debug logs are not affecting your app in release mode. Keep a closer look at the output window for your logs and at the same time monitor Diagnostic tools as well.

    Question: Have you used Dispatcher on your code? If so make sure CoreDispatcherPriority is not set to High priority. I had a freezing issue and fixed it just by making it Normal and Low in several places.

     await
                        CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                            () =>
                            {
                                _navigationService.NavigateTo(typeof(OutPage), mdm.Content.MessageData.ToString());
                            });
    

    Also look at the Windows event viewer for clues. Hope this helps.

    enter image description here