Closed anderpaz closed 1 week ago
Guten Tag, Hans here. Unfortunately, it seems ze issue is not reproducible because you did not try it in ze VisionCamera Example app. Plus, you did not provide logs relevant to isolating ze problem, such as using adb logcat for your device. Please provide these details next time, it helps mrousavy greatly. If you would like ze project to be improved faster, consider supporting it by sponsoring mrousavy here. Thank you!
Note: If you think I made a mistake by closing this issue, please ping
@mrousavy
to take a look.
hey! I think i had the same issue. Can you try this code?
const isFocused = useIsFocused();
// https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/src/hooks/useIsForeground.ts
const isForeground = useIsForeground();
const isActive = isFocused && isForeground;
<Camera
isActive={isActive}
/>
Normally, the camera works, but if the battery is low and I restart the device and try to scan a QR code, at some point after the 3rd or 5th restart, the screen goes black and I get this error in the log.
Creating CodeScanner output... 2024-11-08 10:28:24.911 3096-3096 CameraSession com.spacecom.mpmobile E Failed to configure CameraSession! Error: MlKitContext has not been initialized, Config-Diff: Difference(deviceChanged=true, outputsChanged=true, sidePropsChanged=true, isActiveChanged=true, orientationChanged=true, locationChanged=true) java.lang.IllegalStateException: MlKitContext has not been initialized at com.google.android.gms.common.internal.Preconditions.checkState(com.google.android.gms:play-services-basement@@18.3.0:2) at com.google.mlkit.common.sdkinternal.MlKitContext.getInstance(com.google.mlkit:common@@18.9.0:1) at com.google.mlkit.vision.barcode.BarcodeScanning.getClient(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.3.0:3) at com.mrousavy.camera.core.CodeScannerPipeline.<init>(CodeScannerPipeline.kt:27) at com.mrousavy.camera.core.CameraSession_ConfigurationKt.configureOutputs(CameraSession+Configuration.kt:219) at com.mrousavy.camera.core.CameraSession.configure(CameraSession.kt:135) at com.mrousavy.camera.react.CameraView$update$1.invokeSuspend(CameraView.kt:153) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) at android.os.Handler.handleCallback(Handler.java:958) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:230) at android.os.Looper.loop(Looper.java:319) at android.app.ActivityThread.main(ActivityThread.java:8913) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) 2024-11-08 10:28:24.911 3096-3096 CameraView com.spacecom.mpmobile E invokeOnError(...): 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W java.lang.IllegalStateException: MlKitContext has not been initialized 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.google.android.gms.common.internal.Preconditions.checkState(com.google.android.gms:play-services-basement@@18.3.0:2) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.google.mlkit.common.sdkinternal.MlKitContext.getInstance(com.google.mlkit:common@@18.9.0:1) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.google.mlkit.vision.barcode.BarcodeScanning.getClient(com.google.android.gms:play-services-mlkit-barcode-scanning@@18.3.0:3) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.mrousavy.camera.core.CodeScannerPipeline.<init>(CodeScannerPipeline.kt:27) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.mrousavy.camera.core.CameraSession_ConfigurationKt.configureOutputs(CameraSession+Configuration.kt:219) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.mrousavy.camera.core.CameraSession.configure(CameraSession.kt:135) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at com.mrousavy.camera.react.CameraView$update$1.invokeSuspend(CameraView.kt:153) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at android.os.Handler.handleCallback(Handler.java:958) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at android.os.Handler.dispatchMessage(Handler.java:99) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at android.os.Looper.loopOnce(Looper.java:230) 2024-11-08 10:28:24.911 3096-3096 System.err com.spacecom.mpmobile W at android.os.Looper.loop(Looper.java:319) 2024-11-08 10:28:24.912 3096-3096 System.err com.spacecom.mpmobile W at android.app.ActivityThread.main(ActivityThread.java:8913) 2024-11-08 10:28:24.912 3096-3096 System.err com.spacecom.mpmobile W at java.lang.reflect.Method.invoke(Native Method) 2024-11-08 10:28:24.912 3096-3096 System.err com.spacecom.mpmobile W at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608) 2024-11-08 10:28:24.912 3096-3096 System.err com.spacecom.mpmobile W at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103) 2024-11-08 10:28:24.917 3096-3096 Dialog com.spacecom.mpmobile I mIsDeviceDefault = false, mIsSamsungBasicInteraction = false, isMetaDataInActivity = false
hey! I think i had the same issue. Can you try this code?
const isFocused = useIsFocused(); // https://github.com/mrousavy/react-native-vision-camera/blob/main/package/example/src/hooks/useIsForeground.ts const isForeground = useIsForeground(); const isActive = isFocused && isForeground; <Camera isActive={isActive} />
Guten Tag, Hans here. Unfortunately, it seems ze issue is not reproducible because you did not try it in ze VisionCamera Example app. Plus, you did not provide logs relevant to isolating ze problem, such as using adb logcat for your device. Please provide these details next time, it helps mrousavy greatly. If you would like ze project to be improved faster, consider supporting it by sponsoring mrousavy here. Thank you!
Note: If you think I made a mistake by closing this issue, please ping
@mrousavy
to take a look.
I can't test with the example, but the error is very specific to react-native-vision-camera.
What's happening?
At times, when the device turns on with low battery, for example, 5-10%, I only get a black screen. In my error log, I get MlKitContext.
Reproduceable Code
Relevant log output
Camera Device
Device
Samsung A15
VisionCamera Version
"react-native-vision-camera": "4.3.1",
Can you reproduce this issue in the VisionCamera Example app?
I didn't try (⚠️ your issue might get ignored & closed if you don't try this)
Additional information