Skip to content

fix(android): initialize CameraDevicesManager after React instance se… #3597

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

MdAbubakar
Copy link

Summary

Fixes IllegalStateException: Tried to access a JS module before the React instance was fully set up
on Android when using VisionCamera.

The crash occurs because sendAvailableDevicesChangedEvent() is called from the init {} block
before initialize() has been invoked by React Native, meaning getJSModule() is not yet safe to call.

Changes

  • Moved cameraProvider + extensionsManager initialization from init {} to initialize().
  • Registers AvailabilityCallback only after React instance is ready.

Reproduction Steps

  1. Open an app using VisionCamera immediately on app launch.
  2. The camera availability event is emitted before React is ready → crash.
  3. This fix delays event emission until initialize() is called.

Test Plan

  • Verified on Android 12/14 that the crash no longer occurs.
  • Camera devices list still populates correctly on startup.

Copy link

vercel bot commented Aug 5, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-vision-camera ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 5, 2025 1:45pm

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