Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰 Focus not working on some Android devices when setting FPS #3029

Open
3 of 5 tasks
rodrigobertolotti opened this issue Jun 26, 2024 · 5 comments
Open
3 of 5 tasks
Labels
馃悰 bug Something isn't working

Comments

@rodrigobertolotti
Copy link

What's happening?

If i set my fps in the camera to fps={15} and tap to focus on certain android devices, i get a crash or error where the camera eventually recovers but it leads to a 3 o 4 seconds of UI freezed. If i remove the fps prop, the error does not happen.

Just to clarify, the current camera device indicates focusing is supported and although on my use case im setting fps to 15, i can reproduce it on the ShadowLens and on the example app for that same device.

This happens only on some Androd devices (Pixel 2 and Pixel 5), this does not happen on my iPhone 15 Pro or other android devices (Xiaomi 13c with Android 14 works fine for example).

This same crash happens on the ShadowLens app while recording and tapping to focus.

This is the error on the js side:

{ [session/recoverable-error: An unknown error occurred while creating the Camera Session, but the Camera can recover from it.]
name: 'session/recoverable-error',
_code: 'session/recoverable-error',
_message: 'An unknown error occurred while creating the Camera Session, but the Camera can recover from it.',
_cause: undefined }

Reproduceable Code

<Camera
              fps={15}
              photo={true}
              photoQualityBalance="quality"
              video={true}
              photoHdr={true}
              outputOrientation="device"
              enableZoomGesture={true}
              device={currentDevice}
              format={format}
              torch={torchOn ? 'on' : 'off'}
              isActive={cameraActive}
              audio={audioEnabled}
              photoQualityBalance={'quality'}
              onInitialized={onCameraReady}
              exposure={exposure}
              aspectRatio={aspectRatio}
              videoMode={videoMode}
              enableHighQualityPhotos={highQualityPhotos}
              style={cameraStyle}
              codeScanner={codeScanner && scanCodes}
              videoStabilizationMode={videoStabilization}
              onError={processCameraError}
            ></Camera>

Relevant log output

E  Unable to access camera: CAMERA_ERROR (3): createDefaultRequest:1618: Camera 0: Error creating default request for template 3: Function not implemented (-38)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  java.lang.Exception: Stack trace
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at java.lang.Thread.dumpStack(Thread.java:1529)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.CaptureSession.issueBurstCaptureRequest(CaptureSession.java:796)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.CaptureSession.issuePendingCaptureRequest(CaptureSession.java:659)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.CaptureSession.issueCaptureRequests(CaptureSession.java:546)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.Camera2CameraImpl.submitCaptureRequests(Camera2CameraImpl.java:1645)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.Camera2CameraImpl$ControlUpdateListenerInternal.onCameraControlCaptureRequests(Camera2CameraImpl.java:2363)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.Camera2CameraControlImpl.submitCaptureRequestsInternal(Camera2CameraControlImpl.java:640)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.FocusMeteringControl.cancelAfAeTrigger(FocusMeteringControl.java:527)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.FocusMeteringControl.cancelFocusAndMeteringInternal(FocusMeteringControl.java:828)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.FocusMeteringControl.cancelFocusAndMeteringWithoutAsyncResult(FocusMeteringControl.java:815)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.FocusMeteringControl.lambda$executeMeteringAction$10$androidx-camera-camera2-internal-FocusMeteringControl(FocusMeteringControl.java:790)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.FocusMeteringControl$$ExternalSyntheticLambda6.run(Unknown Source:4)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:231)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:173)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2024-06-26 12:46:18.701  8783-8847  System.err              com.mrousavy.camera.example          W  	at java.lang.Thread.run(Thread.java:923)
2024-06-26 12:46:18.702  8783-8847  UseCaseAttachState      com.mrousavy.camera.example          D  Active and attached use case: [androidx.camera.video.VideoCapture-5d589c8b-abae-4cdb-bb29-e961f854f21e137680087, androidx.camera.core.Preview-1694c683-ccda-428d-bcc2-a294807f7b4e261039729, androidx.camera.core.ImageCapture-c30a4f7f-1d88-4457-af5a-a206df9de3b4168819798] for camera: 0
2024-06-26 12:46:18.703  8783-8847  CaptureSession          com.mrousavy.camera.example          D  Attempting to submit CaptureRequest after setting
2024-06-26 12:46:18.703  8783-8847  CaptureSession          com.mrousavy.camera.example          D  Issuing request for session.
2024-06-26 12:46:18.703  8783-8847  Camera2Cap...estBuilder com.mrousavy.camera.example          D  createCaptureRequest
2024-06-26 12:46:18.704  8783-8847  CaptureSession          com.mrousavy.camera.example          E  Unable to access camera: CAMERA_ERROR (3): The camera device has encountered a serious error
2024-06-26 12:46:18.704  8783-8847  System.err              com.mrousavy.camera.example          W  java.lang.Exception: Stack trace
2024-06-26 12:46:18.704  8783-8847  System.err              com.mrousavy.camera.example          W  	at java.lang.Thread.dumpStack(Thread.java:1529)
2024-06-26 12:46:18.704  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.CaptureSession.issueRepeatingCaptureRequests(CaptureSession.java:644)
2024-06-26 12:46:18.704  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.CaptureSession.setSessionConfig(CaptureSession.java:185)
2024-06-26 12:46:18.704  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.Camera2CameraImpl.updateCaptureSessionConfig(Camera2CameraImpl.java:1399)
2024-06-26 12:46:18.704  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.Camera2CameraImpl$ControlUpdateListenerInternal.onCameraControlUpdateSessionConfig(Camera2CameraImpl.java:2357)
2024-06-26 12:46:18.705  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.Camera2CameraControlImpl.updateSessionConfigSynchronous(Camera2CameraControlImpl.java:569)
2024-06-26 12:46:18.705  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.FocusMeteringControl.cancelFocusAndMeteringInternal(FocusMeteringControl.java:835)
2024-06-26 12:46:18.705  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.FocusMeteringControl.cancelFocusAndMeteringWithoutAsyncResult(FocusMeteringControl.java:815)
2024-06-26 12:46:18.705  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.FocusMeteringControl.lambda$executeMeteringAction$10$androidx-camera-camera2-internal-FocusMeteringControl(FocusMeteringControl.java:790)
2024-06-26 12:46:18.705  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.camera2.internal.FocusMeteringControl$$ExternalSyntheticLambda6.run(Unknown Source:4)
2024-06-26 12:46:18.705  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:231)
2024-06-26 12:46:18.705  8783-8847  System.err              com.mrousavy.camera.example          W  	at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:173)
2024-06-26 12:46:18.705  8783-8847  System.err              com.mrousavy.camera.example          W  	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2024-06-26 12:46:18.705  8783-8847  System.err              com.mrousavy.camera.example          W  	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2024-06-26 12:46:18.705  8783-8847  System.err              com.mrousavy.camera.example          W  	at java.lang.Thread.run(Thread.java:923)
2024-06-26 12:46:18.706  8783-8847  DeferrableSurface       com.mrousavy.camera.example          D  use count-1,  useCount=1 closed=false androidx.camera.core.SurfaceRequest$2@23e2706
2024-06-26 12:46:18.706  8783-8847  DeferrableSurface       com.mrousavy.camera.example          D  use count-1,  useCount=0 closed=false androidx.camera.core.impl.ImmediateSurface@afe1b60
2024-06-26 12:46:18.706  8783-8847  DeferrableSurface       com.mrousavy.camera.example          D  Surface no longer in use[total_surfaces=5, used_surfaces=2](androidx.camera.core.impl.ImmediateSurface@afe1b60}
2024-06-26 12:46:18.706  8783-8847  DeferrableSurface       com.mrousavy.camera.example          D  use count-1,  useCount=1 closed=false androidx.camera.core.SurfaceRequest$2@13bc404
2024-06-26 12:46:18.707  8783-8847  Camera2CameraImpl       com.mrousavy.camera.example          D  {Camera@1db0428[id=0]} Camera receive onErrorCallback
2024-06-26 12:46:18.707  8783-8847  Camera2CameraImpl       com.mrousavy.camera.example          D  CameraDevice.onError(): 0 failed with ERROR_CAMERA_DEVICE while in OPENED state. Will attempt recovering from error.
2024-06-26 12:46:18.707  8783-8847  Camera2CameraImpl       com.mrousavy.camera.example          D  Attempt to reopen camera[0] after error[ERROR_CAMERA_DEVICE]
2024-06-26 12:46:18.708  8783-8847  Camera2CameraImpl       com.mrousavy.camera.example          D  {Camera@1db0428[id=0]} Transitioning camera internal state: OPENED --> REOPENING
2024-06-26 12:46:18.708  8783-8847  CameraStateRegistry     com.mrousavy.camera.example          D  Recalculating open cameras:
                                                                                                    Camera                                       State                 
                                                                                                    -------------------------------------------------------------------
                                                                                                    Camera@1db0428[id=0]                         OPENING               
                                                                                                    Camera@e956fc3[id=1]                         UNKNOWN               
                                                                                                    -------------------------------------------------------------------
                                                                                                    Open count: 1 (Max allowed: 1)
2024-06-26 12:46:18.709  8783-8847  CameraStateMachine      com.mrousavy.camera.example          D  New public camera state CameraState{type=OPENING, error=StateError{code=3, cause=null}} from OPENING and StateError{code=3, cause=null}
2024-06-26 12:46:18.709  8783-8847  CameraStateMachine      com.mrousavy.camera.example          D  Publishing new public camera state CameraState{type=OPENING, error=StateError{code=3, cause=null}}
2024-06-26 12:46:18.709  8783-8783  CameraSession           com.mrousavy.camera.example          I  Camera State: OPENING (has error: true)
2024-06-26 12:46:18.709  8783-8847  Camera2CameraImpl       com.mrousavy.camera.example          D  {Camera@1db0428[id=0]} Resetting Capture Session
2024-06-26 12:46:18.709  8783-8847  SyncCaptureSessionImpl  com.mrousavy.camera.example          D  [androidx.camera.camera2.internal.SynchronizedCaptureSessionImpl@7d91285] Session call close()
2024-06-26 12:46:18.709  8783-8783  CameraView              com.mrousavy.camera.example          E  invokeOnError(...):
2024-06-26 12:46:18.709  8783-8783  System.err              com.mrousavy.camera.example          W  com.mrousavy.camera.core.RecoverableError: An unknown error occurred while creating the Camera Session, but the Camera can recover from it.

Camera Device

{"hardwareLevel": "full", "hasFlash": true, "hasTorch": true, "id": "0", "isMultiCam": false, "maxExposure": 12, "maxZoom": 7, "minExposure": -12, "minFocusDistance": 10, "minZoom": 1, "name": "0 (BACK) androidx.camera.camera2", "neutralZoom": 1, "physicalDevices": ["wide-angle-camera"], "position": "back", "sensorOrientation": "landscape-left", "supportsFocus": true, "supportsLowLightBoost": false, "supportsRawCapture": false}

Device

Google Pixel 2 Android 11

VisionCamera Version

4.1.0

Can you reproduce this issue in the VisionCamera Example app?

Yes, I can reproduce the same issue in the Example app here

Additional information

@rodrigobertolotti rodrigobertolotti added the 馃悰 bug Something isn't working label Jun 26, 2024
@maintenance-hans maintenance-hans bot changed the title Focus not working on some Android devices when setting FPS 馃悰 Focus not working on some Android devices when setting FPS Jun 26, 2024
Copy link

Guten Tag, Hans here.

Note

New features, bugfixes, updates and other improvements are all handled mostly by @mrousavy in his free time.
To support @mrousavy, please consider 馃挅 sponsoring him on GitHub 馃挅.
Sponsored issues will be prioritized.

@mrousavy
Copy link
Owner

So this is definitely a CameraX bug then.
Can you report it in the CameraX issue tracker?

@mrousavy
Copy link
Owner

(thanks for the detailed testing & logs btw)

@mrousavy
Copy link
Owner

Did you post a CameraX issue? If yes, please link it here for visibility.

@rodrigobertolotti
Copy link
Author

Hi, I was quite busy I'll try to do it today. I'll paste the link here as soon it's done. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
馃悰 bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants