question

Madhu-8808 avatar image
0 Votes"
Madhu-8808 asked ·

UWP app crashing

Hi,

Our UWP app contains many web views and also it loads image/videos etc.. When using the app to load lot of data continuously the app crashes. In different machines this seems to happen at different memory levels. In my machine when the app uses more than 600mb roughly it seems to crash. But the total memory of the machine is at 50%.
1. When a UWP app crashes like that, is there a way to identify the exact issue of that crash? Does it write to the System log in the Windows?
2. Assuming the reason for the crash is memory, is there a way to set a higher memory level for the app? (from the code also we have done memory releasing, where we have noticed memory issues and if we give time for the app to load data then it releases the memory to a certain extent. The crashing happens if the user load data very quickly)
3. Are there any specific things we need to do in the code related to memory handling/releasing

Thank you.
Madhu

windows-uwp
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

mrlacey avatar image
3 Votes"
mrlacey answered ·

Using multiple webviews is a red flag for me.
If you're loading content from a remote source (over the web) then the amount of memory used to render that content. Reclaiming that memory can also be a challenge.

I'd start by avoiding using multiple webviews and just create one that you reuse across multiple pages as necessary. (You may need to remove and reassign the parent or create at a "shell" level depending on the structure of your app.)
If you need multiple webviews on a single XAML page I'd also see if you can change things to avoid that if possible.

Of course, first use the built-in diagnostic tools to determine if this is where you should be looking https://docs.microsoft.com/en-us/visualstudio/profiling/profiling-feature-tour?view=vs-2019

· 2 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@mrlacey Thank you for the quick response. In a single page we use multiple web views. Please see the attached image. There like Topic1, Topic 2 there can 20-30 items and each of them use a web view (we used web views because we need to show html data there. Text with bullet numbering and other html tags etc). We do not load over the web. Data is in the app's sqlite table and we load from there to the web view. App can have many pages like this. It's dynamically loading depending on the content. Any suggestions on how we can manage memory if we have multiple web views like that in a single page? Thank you.


9572-iwwebviews.png


0 Votes 0 · ·
iwwebviews.png (1.2 MiB)

To manage the memory used by webviews, you should make sure you're removing content before destroying instances and make sure you're disposing of everything correctly.
You may also benefit from maintaining a collection of webview instances that you reuse so that you can avoid creating more than are necessary.

HOWEVER, I would change the content so that you don't need a webview to display it.
WebViews are very heavyweight controls and using them to display a small piece of formatted text is overkill.
If at all possible, as the content is being shipped with the app, I would first convert it into a format that is easier to work with and so doesn't need a WebView to be rendered.

1 Vote 1 · ·
danielescipioni avatar image
2 Votes"
danielescipioni answered ·

I suggest to use a AppCenter Diagnostics to collect information about crashes. You can find related documentation for UWP at https://docs.microsoft.com/en-us/appcenter/sdk/crashes/uwp and https://docs.microsoft.com/en-us/appcenter/diagnostics/windows-support, and more general information at https://docs.microsoft.com/en-us/appcenter/diagnostics/.

· 1 · Share
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.


Thank you for sharing your knowledge with community .

0 Votes 0 · ·