Skip to content

fix: an unreadable content:// attachment no longer crashes the app - #34

Merged
adibhanna merged 1 commit into
mainfrom
fix/content-uri-crash
Aug 28, 2026
Merged

fix: an unreadable content:// attachment no longer crashes the app#34
adibhanna merged 1 commit into
mainfrom
fix/content-uri-crash

Conversation

@adibhanna

Copy link
Copy Markdown
Contributor

Fixes the one crash cluster in Android vitals for 1.1.11 (4a1ba7cf…, 2 events / 1 user): Capacitor's WebViewLocalServer let a document provider's IllegalArgumentException escape shouldInterceptRequest while serving a content:// attachment from a folder (SAF) vault, killing the process.

Fix: MainActivity installs a BridgeWebViewClient subclass that wraps the local-server call; any RuntimeException while 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 at content://media/external/file/nope (MediaProvider's IllegalArgumentException — the exact frames from the vitals stack; Process md.zennotes … has died); the fixed build fires onerror and keeps the same pid. Normal local attachments still render.

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.
@adibhanna
adibhanna merged commit 9394700 into main Aug 28, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant