-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Description
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.
Platforms
- iOS
- Android
- Web
Request or proposed solution
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:
capacitor/ios/Capacitor/Capacitor/WebViewDelegationHandler.swift
Lines 158 to 162 in e8507cf
| open func webViewWebContentProcessDidTerminate(_ webView: WKWebView) { | |
| CAPLog.print("⚡️ WebView process terminated") | |
| bridge?.reset() | |
| webView.reload() | |
| } |
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: #2265
Additional Information
This is an old issue that was closed, with a request to reopen if it's still valid.