question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: Notify JS-layer when webview crashed

See original GitHub issue

Feature Request

It would be great if the JS-layer (Capacitor app) could know that the underlying web view crashed and subsequently restarted. Right now there is nothing to discern these from a regular app startup and users won’t be aware that data was lost.

More concretely, an issue that occur frequently is that we take a photograph via an <input capture> element and do on-the-fly resize using JS and canvas, and the web view crashes, causing the page to reload. But for the user this isn’t obvious, it’s just a short flash when the web view reloads, and they don’t know that the photograph failed and they’ve just lost data.

If we could listen to these events we could show a warning to the user.

This is the code on iOS today:

https://github.com/ionic-team/capacitor/blob/0a25cce21f935c0d18cdeb9b0e04a9b6145f2072/ios/Capacitor/Capacitor/CAPBridgeViewController.swift#L279-L281

Platform Support Requested

  • Android
  • iOS

Describe Preferred Solution

There are multiple solutions, but one could be a listener similar to appRestoredResult , that would let us know that the app restored after a crash.

We’d then have the ability to show a warning to the user.

Additional Context

This related issue about the web view crashing when taking photos: https://github.com/ionic-team/capacitor/issues/2265

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:14
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

3reactions
diachedeliccommented, Jan 28, 2022

We have found the iOS WebView to be very sensitive to memory usage. It crashes quite often on startup, possibly due to this bug: https://bugs.webkit.org/show_bug.cgi?id=212790. If you have any memory leaks in the WebView, it will eventually be terminated. WebKit unfortunately has some nasty memory leaks associated with the <video> and <canvas> elements.

In general, an automatic reload is necessary in production. But I would prefer a crash in development. And ideally, we should be able to override the default behaviour, so we can maintain the integrity of the app.

2reactions
diachedeliccommented, Aug 20, 2020

Would it be so crazy to crash the app if webViewWebContentProcessDidTerminate was called? I think I would prefer the app to quit immediately and obviously, rather than data disappearing silently. Perhaps it could be a configuration option.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WebView Crashes [Bug?] - Stack Overflow
Here's where the weirdness begins: This code works fine. If I uncomment the second line that assigns a value to src.Html, the program...
Read more >
JavaScript Windows Store application may crash when an ...
This issue occurs on a Windows 8.1 based computer that has Internet Explorer 11 installed and the asynchronous operation is started by using...
Read more >
Google fixes issue causing Android apps to crash ... - The Verge
Android apps were crashing for some users, but Google now has a fix. The issue is due to a system component called Android...
Read more >
Here's how to fix those mysterious Android WebView crashes
How to Fix the Recent App Crashes. To use WatfordHert's method, go to the main Android Settings menu, then tap "Apps & Notifications"...
Read more >
UWP Webview crashes the App - invalid memory access
We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found