Hi,
The camera doesn't wake up / work after the device has been in sleep mode or the screen was in screen timeout mode.
Test Device
- Samsung Galaxy Tab6a
- Android 5.1.1
How to replicate the issue:
- Open app that uses the react-native-barcodescanner and go to the view that uses the camera
- Navigate away from the view to any view that doesn't use the camera
- Let the device go to sleep or in screen timeout mode
- Unlock screen and go to view which uses the camera
In all of my apps the viewfinder is black after walking through the previous steps
What I found so far:
- It is not a permission issue
- If I close the app after this issue has occured and reopen it the camera does work again
- If I leave the view with the camera open and let the device go to sleep, it will work after I unlock the screen
- When this issue occurs the android camera app also doesn't work
- The Android device monitor shows the following errors when the device goes to sleep:
09-01 22:56:55.833: E/CameraPreview(15121): java.lang.RuntimeException: Camera is being used after Camera.release() was called 09-01 22:56:55.833: E/CameraPreview(15121): java.lang.RuntimeException: Camera is being used after Camera.release() was called 09-01 22:56:55.833: E/CameraPreview(15121): at android.hardware.Camera.native_cancelAutoFocus(Native Method) 09-01 22:56:55.833: E/CameraPreview(15121): at android.hardware.Camera.cancelAutoFocus(Camera.java:1348) 09-01 22:56:55.833: E/CameraPreview(15121): at com.eguma.barcodescanner.CameraPreview.stopCameraPreview(CameraPreview.java:89) 09-01 22:56:55.833: E/CameraPreview(15121): at com.eguma.barcodescanner.CameraPreview.stopCamera(CameraPreview.java:52) 09-01 22:56:55.833: E/CameraPreview(15121): at com.eguma.barcodescanner.BarcodeScannerView.onPause(BarcodeScannerView.java:43) 09-01 22:56:55.833: E/CameraPreview(15121): at com.eguma.barcodescanner.BarcodeScannerManager.onHostPause(BarcodeScannerManager.java:58) 09-01 22:56:55.833: E/CameraPreview(15121): at com.facebook.react.bridge.ReactContext.onHostPause(ReactContext.java:179) 09-01 22:56:55.833: E/CameraPreview(15121): at com.facebook.react.XReactInstanceManagerImpl.moveToBeforeResumeLifecycleState(XReactInstanceManagerImpl.java:573) 09-01 22:56:55.833: E/CameraPreview(15121): at com.facebook.react.XReactInstanceManagerImpl.onHostPause(XReactInstanceManagerImpl.java:489) 09-01 22:56:55.833: E/CameraPreview(15121): at com.facebook.react.ReactActivity.onPause(ReactActivity.java:120) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.Activity.performPause(Activity.java:6765) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1338) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4418) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4391) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4366) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.ActivityThread.access$1200(ActivityThread.java:219) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1746) 09-01 22:56:55.833: E/CameraPreview(15121): at android.os.Handler.dispatchMessage(Handler.java:102) 09-01 22:56:55.833: E/CameraPreview(15121): at android.os.Looper.loop(Looper.java:145) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.ActivityThread.main(ActivityThread.java:6939) 09-01 22:56:55.833: E/CameraPreview(15121): at java.lang.reflect.Method.invoke(Native Method) 09-01 22:56:55.833: E/CameraPreview(15121): at java.lang.reflect.Method.invoke(Method.java:372) 09-01 22:56:55.833: E/CameraPreview(15121): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 09-01 22:56:55.833: E/CameraPreview(15121): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
Please help! I really need this to work.
Thanks.
Regards,
Gawein
Hi,
The camera doesn't wake up / work after the device has been in sleep mode or the screen was in screen timeout mode.
Test Device
How to replicate the issue:
In all of my apps the viewfinder is black after walking through the previous steps
What I found so far:
09-01 22:56:55.833: E/CameraPreview(15121): java.lang.RuntimeException: Camera is being used after Camera.release() was called 09-01 22:56:55.833: E/CameraPreview(15121): java.lang.RuntimeException: Camera is being used after Camera.release() was called 09-01 22:56:55.833: E/CameraPreview(15121): at android.hardware.Camera.native_cancelAutoFocus(Native Method) 09-01 22:56:55.833: E/CameraPreview(15121): at android.hardware.Camera.cancelAutoFocus(Camera.java:1348) 09-01 22:56:55.833: E/CameraPreview(15121): at com.eguma.barcodescanner.CameraPreview.stopCameraPreview(CameraPreview.java:89) 09-01 22:56:55.833: E/CameraPreview(15121): at com.eguma.barcodescanner.CameraPreview.stopCamera(CameraPreview.java:52) 09-01 22:56:55.833: E/CameraPreview(15121): at com.eguma.barcodescanner.BarcodeScannerView.onPause(BarcodeScannerView.java:43) 09-01 22:56:55.833: E/CameraPreview(15121): at com.eguma.barcodescanner.BarcodeScannerManager.onHostPause(BarcodeScannerManager.java:58) 09-01 22:56:55.833: E/CameraPreview(15121): at com.facebook.react.bridge.ReactContext.onHostPause(ReactContext.java:179) 09-01 22:56:55.833: E/CameraPreview(15121): at com.facebook.react.XReactInstanceManagerImpl.moveToBeforeResumeLifecycleState(XReactInstanceManagerImpl.java:573) 09-01 22:56:55.833: E/CameraPreview(15121): at com.facebook.react.XReactInstanceManagerImpl.onHostPause(XReactInstanceManagerImpl.java:489) 09-01 22:56:55.833: E/CameraPreview(15121): at com.facebook.react.ReactActivity.onPause(ReactActivity.java:120) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.Activity.performPause(Activity.java:6765) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.Instrumentation.callActivityOnPause(Instrumentation.java:1338) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4418) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.ActivityThread.performPauseActivity(ActivityThread.java:4391) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:4366) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.ActivityThread.access$1200(ActivityThread.java:219) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1746) 09-01 22:56:55.833: E/CameraPreview(15121): at android.os.Handler.dispatchMessage(Handler.java:102) 09-01 22:56:55.833: E/CameraPreview(15121): at android.os.Looper.loop(Looper.java:145) 09-01 22:56:55.833: E/CameraPreview(15121): at android.app.ActivityThread.main(ActivityThread.java:6939) 09-01 22:56:55.833: E/CameraPreview(15121): at java.lang.reflect.Method.invoke(Native Method) 09-01 22:56:55.833: E/CameraPreview(15121): at java.lang.reflect.Method.invoke(Method.java:372) 09-01 22:56:55.833: E/CameraPreview(15121): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 09-01 22:56:55.833: E/CameraPreview(15121): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)Please help! I really need this to work.
Thanks.
Regards,
Gawein