fix: prevent crashes on setDataSource failure and missing native module - #149
Open
gandol wants to merge 2 commits into
Open
fix: prevent crashes on setDataSource failure and missing native module#149gandol wants to merge 2 commits into
gandol wants to merge 2 commits into
Conversation
gandol
force-pushed
the
fix/android-setdatasource-runtime-crash
branch
2 times, most recently
from
July 15, 2026 04:32
7f18234 to
c73a532
Compare
…lure MediaMetadataRetriever.setDataSource can throw RuntimeException (e.g. status 0x80000000 for bad/unsupported remote URLs). The previous catch only handled IOException and IllegalStateException, so the uncaught RuntimeException on the worker thread killed the entire app process. Catch Exception in create(), wrap RuntimeException in getBitmapAtTime, validate empty URLs, and always release the retriever in finally.
Destructuring create from CreateThumbnail throws if the native module is not linked (e.g. Expo Go, incomplete autolinking). Export safe fallbacks that reject the Promise instead of crashing at import time.
gandol
force-pushed
the
fix/android-setdatasource-runtime-crash
branch
from
July 15, 2026 04:33
c73a532 to
a7cf48c
Compare
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.
Summary
Exception(includingRuntimeExceptionfromMediaMetadataRetriever.setDataSource) so bad/unsupported video URLs reject the JS Promise instead of crashing the Android processfinally; coerce headers toMap<String, String>Problem
1. Android process crash (
setDataSource)On Android,
MediaMetadataRetriever.setDataSourcecan throw:This happens for empty URLs, unsupported codecs, or remote videos the retriever cannot open. The previous catch block only handled
IOException | IllegalStateException, so the uncaughtRuntimeExceptionon the worker thread killed the entire app:JS
.catch()never runs because the process dies before the Promise is rejected.Related: #62, #131
2. JS crash when native module is missing
throws if
CreateThumbnailisundefined(Expo Go, incomplete autolinking, etc.). This change uses optional chaining and rejects the Promise instead.Test plan
createThumbnailwith a valid local/remote video URL → still resolves with a thumbnailurl→ Promise rejects withCreateThumbnail_ERROR(no crash)0x80000000) → Promise rejects (no crash)createThumbnail()rejects (no crash)