[Android] Bridgeless callbacks crash after pick + null-safety in mime detection and startActivityForResult
Android-only. Distinct from the open iOS PRs (#2404 / #2406) — no iOS code involved.
Three issues on the New Architecture (bridgeless) Android path:
Crash after a successful pick (bridgeless). After a pick,
onAssetsObtainedinvokes the JS callback from a backgroundExecutorServicethread. Under the New Architecture this trips a fatal CHECK in the JSI/C++ layer because callbacks must run on the JS/UI thread, so the app crashes right after selecting media.Unhandled
NullPointerExceptionfromstartActivityForResult. OnlyActivityNotFoundExceptionis caught (camera and library launches). The framework can also throwNullPointerExceptionwhen the activity's window decor view isn't yet available, crashing the app instead of returning an error to JS.NullPointerException/ unhelpful error in mime detection.getMimeTypecallscontentResolverMimeType.isBlank()without a null check, butContentResolver.getType(uri)can returnnull. The"Unsupported file type"error also carries no context.
I have an Android-only fix ready (marshal callbacks onto the UI thread with null-guards; widen the startActivityForResult catch and tag launchFailed:; null-check the mime type and enrich the error). Happy to open the PR referencing this issue.
Source: react-native-image-picker/react-native-image-picker