How to debug app hanging on Windows Phone 8.1

2019-07-13 01:28发布

问题:

I am developing a Windows Phone 8.1 Application.

My app completely hangs on launch and doesn't move/scroll on user input. However, if I force close my app and re-open, it seems to work fine.

So there are 2 outcomes, both happens sometimes, but inconsistently

  1. The app completely hangs and ignores all user input
  2. The app works properly

While checking the output window I observed that when the first scenario occurs, my output window displays a series of thread exits as shown below

The thread 0x680 has exited with code 259 (0x103).
The thread 0x780 has exited with code 259 (0x103).
The thread 0xc5c has exited with code 259 (0x103).
The thread 0x9a0 has exited with code 259 (0x103).
The thread 0xc90 has exited with code 259 (0x103).
The thread 0x4f4 has exited with code 0 (0x0).
The thread 0x2f4 has exited with code 0 (0x0).

However, in the second scenario when the app works fine, I don't see these thread exits.

This has made me to feel that this could be happening because of some threads being stuck in infinite loop.

Apart from this, I don't see any exceptions that could be causing this issue

I did have a look at this and this links. But it doesn't say how to fix these type of issues.

How do I debug these type of issues. Issues that makes the UI hang completely.

I would be very grateful if someone can point me in the right direction.

回答1:

In addition to getting a minimal repro as Fred suggests above, try going to the Debug -> Exceptions... menu and enabling Thrown for all of them to see if anything interesting pops up (note: you often get benign 1st-chance exceptions from inside Windows, so take with a grain of salt).

When the app is in the hung state hit the Pause button in VS and look at the Debug -> Windows -> Parallel Tasks window to see if you can determine what is waiting.

Finally, consider adding Debug.WriteLine calls at various points in your app (in the App constructor, whenever you start a download, whenever you complete a download, etc.) to see if any of your code is executed.