Skip to content

fix: Make sure that camera is initialized when querying devices#3704

Open
ldalzottomp wants to merge 1 commit intomrousavy:mainfrom
ldalzottomp:main
Open

fix: Make sure that camera is initialized when querying devices#3704
ldalzottomp wants to merge 1 commit intomrousavy:mainfrom
ldalzottomp:main

Conversation

@ldalzottomp
Copy link
Contributor

@ldalzottomp ldalzottomp commented Jan 28, 2026

What

This PR fixes user reports where android app shows no camera at all by changing how android initialization is done.

Changes

Note: RNVC = React Native Vision Camera

The root cause was:

  • RNVC native module were initializing camera related structure asynchronously on module load. (code)
  • RNVC rely on a initial single call to getConstants() and initialize() to list devices. (next calls to getConstants() are cached by RN) (code)

This leads to a scenario where:

  • The first call to getConstants() is done without camera structures being initialised. Leading the function returning empty as if no devices were detected. Subsequent calls to getConstants() are cached by react-native and always returns the first result. (code)
  • initialize() being called before getConstants() there is still a way that the devices registered are empty due to asynchronicity of the init (see the attached image).

This PR fixes this behaviour and makes sure that camera structure are initialized when demanded by awaiting the initialization task. We keep starting the initialzation as early as possible.

Here is an image of init log with additional lines:

Screenshot 2026-01-30 at 11 31 20

The issue is super easy to reproduce. On any app, introduce an artificial delay before extensionsManager = ExtensionsManager.getInstanceAsync(reactContext, cameraProvider!!).await(executor)

Tested on

Google Pixel 7 : Android 16.

Related issues

@vercel
Copy link

vercel bot commented Jan 28, 2026

@ldalzottomp is attempting to deploy a commit to the mrousavy's Team Team on Vercel.

A member of the Team first needs to authorize it.

@ldalzottomp ldalzottomp changed the title fix: Make sure that camera is initialized when getConstants() is called fix: Make sure that camera is initialized when querying devices Jan 30, 2026
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