fix: an unreadable content:// attachment no longer crashes the app - #34
Merged
Conversation
Android vitals for 1.1.11 (2 events, 1 user): the process died inside Capacitor's WebViewLocalServer while it served a content:// asset. The WebView requested an attachment from a folder (SAF) vault, the document provider raised IllegalArgumentException for it (removed, renamed, or its permission gone), and nothing between ContentResolver.openInputStream and Chromium's request interceptor catches that, so an unreadable image was a fatal crash instead of a broken one. MainActivity now installs a BridgeWebViewClient subclass whose shouldInterceptRequest wraps the local server: any RuntimeException while resolving a request answers 404 and the app carries on. Reproduced on the API 35 emulator with the shipped 1.1.11 APK — an <img> pointed at content://media/external/file/nope (MediaProvider throws IllegalArgumentException 'Unknown URL', the exact frames in the vitals stack) killed the process; with this change the same request fires the image's onerror and the process survives. Local attachments still render.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the one crash cluster in Android vitals for 1.1.11 (
4a1ba7cf…, 2 events / 1 user): Capacitor'sWebViewLocalServerlet a document provider'sIllegalArgumentExceptionescapeshouldInterceptRequestwhile serving acontent://attachment from a folder (SAF) vault, killing the process.Fix:
MainActivityinstalls aBridgeWebViewClientsubclass that wraps the local-server call; anyRuntimeExceptionwhile resolving a request answers 404, so a stale/unreadable attachment is a broken image, not a dead app.Verified on the API 35 emulator: the shipped 1.1.11 APK dies on an
<img>pointed atcontent://media/external/file/nope(MediaProvider'sIllegalArgumentException— the exact frames from the vitals stack;Process md.zennotes … has died); the fixed build firesonerrorand keeps the same pid. Normal local attachments still render.