mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.57k stars 1.1k forks source link

🐛 Crash in OrientationManager; memory management and threading issues. #3290

Closed Voxar closed 5 days ago

Voxar commented 5 days ago

What's happening?

After updating from 3.9.1 to 4.6.1 I get a crash when opening a view with a <Camera ...> for the second time.

When the OrientationManager calls stopDeviceOrientationListener the callback block previously sent to motionManager.startAccelerometerUpdates is released which then frees an OrientationManager instance, presumably the one from the previous session that is still held on to by the block.

image

The block is retained until the motionManager is stopped. A [weak self] at https://github.com/mrousavy/react-native-vision-camera/blob/143ec9ff578e3b9bd6b86483ee490fc217d975eb/package/ios/Core/OrientationManager.swift#L164 seems to solve the crash.

However while testing the above quick fix by moving in and out of my react native camera view somewhat rapidly I also get this crash over several user-interactive threads all on objc_release, and one CoreMotion.MotionThread objc_MsgSend,

(lldb) x/s $x1 0x20979baa3: "isAccelerometerAvailable"

image

Now I am running a "My Mac (Designed for iPhone)" target with Continuity Camera from an iPhone with 18.2 beta today, so threading issues could be related to any of that. I'll give this a few more hours tomorrow to try the example and a fresh minimal case sample on the phone, and perhaps get a PR away with the block-retained self as well if I can determine that the threading issues are not related to that.

Reproduceable Code

I react native navigation to push a view that uses the camera and codeScanner.
          <Camera
            style={StyleSheet.absoluteFill}
            device={device}
            codeScanner={codeScanner}
            isActive={isActive}
            torch={enableFlashlight ? 'on' : 'off'}
          />

I navigate back and forth from a home screen and this view

Relevant log output

Here's navigating back and forth to and from the camera view. 

19:26:19.216: [info] 📸 VisionCamera.constantsToExport(): Found 4 initial Camera Devices.
19:26:19.283: [info] 📸 VisionCamera.didSetProps(_:): Updating 20 props: [onInitialized, cameraId, codeScannerOptions, enableBufferCompression, preview, onStarted, onCodeScanned, onOutputOrientationChanged, isActive, isMirrored, onViewReady, onError, onStopped, onPreviewOrientationChanged, onPreviewStarted, enableFrameProcessor, onPreviewStopped, flex, torch, onShutter]
19:26:19.285: [info] 📸 VisionCamera.configurePreviewOrientation(_:): Updating Preview rotation: portrait...
19:26:19.285: [info] 📸 VisionCamera.configureOutputOrientation(_:): Updating Outputs rotation: portrait...
19:26:19.285: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:19.286: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:19.286: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:19.287: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: true, outputsChanged: true, videoStabilizationChanged: true, orientationChanged: true, formatChanged: true, sidePropsChanged: true, torchChanged: true, zoomChanged: true, exposureChanged: true, audioSessionChanged: true, locationChanged: true)
19:26:19.287: [info] 📸 VisionCamera.configureDevice(configuration:): Configuring Input Device...
19:26:19.287: [info] 📸 VisionCamera.configureDevice(configuration:): Configuring Camera 1608A3BE-DD09-41E0-B989-CF8300000001__2...
19:26:19.301: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:19.301: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:19.301: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:19.301: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
AddInstanceForFactory: No factory registered for id <CFUUID 0x600002f906a0> F8BB1C28-BAE8-11D6-9C31-00039315CD46
19:26:19.364: [info] 📸 VisionCamera.configureDevice(configuration:): Successfully configured Input Device!
19:26:19.364: [info] 📸 VisionCamera.configureOutputs(configuration:): Configuring Outputs...
19:26:19.364: [info] 📸 VisionCamera.configureOutputs(configuration:): Adding Code Scanner output...
19:26:19.368: [info] 📸 VisionCamera.configurePreviewOrientation(_:): Updating Preview rotation: portrait...
19:26:19.368: [info] 📸 VisionCamera.configureOutputOrientation(_:): Updating Outputs rotation: portrait...
19:26:19.368: [info] 📸 VisionCamera.configureOutputs(configuration:): Successfully configured all outputs!
19:26:19.369: [info] 📸 VisionCamera.setTargetOutputOrientation(_:): Setting target output orientation from device to device...
<<<< FigCaptureCameraParameters >>>> Fig assert: "success" at bail (FigCaptureCameraParameters.m:255) - (err=0)
CMIOHardware.cpp:418:CMIOObjectSetPropertyData Error: 2003329396, failed
<<<< FigCaptureCameraParameters >>>> Fig assert: "success" at bail (FigCaptureCameraParameters.m:255) - (err=0)
|___ fsbp_Autofocus ___| Fig assert: "err == noErr" at bail (FigSampleBufferProcessor_Autofocus.m:2451) - (err=0)
19:26:24.912: [info] 📸 VisionCamera.didSetProps(_:): Updating 1 props: [isActive]
19:26:24.912: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:24.985: [info] 📸 VisionCamera.init(frame:session:): Preview Layer started previewing.
19:26:24.986: [info] 📸 VisionCamera.configure(_:): Beginning AudioSession configuration...
19:26:24.986: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:24.986: [info] 📸 VisionCamera.configureAudioSession(configuration:): Configuring Audio Session...
19:26:24.986: [info] 📸 VisionCamera.configure(_:): Beginning Location Output configuration...
19:26:24.987: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:24.987: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:24.987: [info] 📸 VisionCamera.configure(_:): Finished Location Output configuration!
19:26:24.987: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false, locationChanged: false)
19:26:24.987: [info] 📸 VisionCamera.configure(_:): Committed AudioSession configuration!
19:26:24.989: [info] 📸 VisionCamera.init(frame:session:): Preview Layer stopped previewing.
<<<< CMIOFigCaptureStream >>>> Fig assert: "! stream->streaming" at bail (CMIOFigCaptureStream.m:1206) - (err=0)
I1112 19:26:27.751034 1880600576 UIManagerBinding.cpp:164] instanceHandle is null, event of type topDisappear will be dropped
19:26:32.500: [info] 📸 VisionCamera.didSetProps(_:): Updating 20 props: [onInitialized, cameraId, codeScannerOptions, enableBufferCompression, preview, onStarted, onCodeScanned, onOutputOrientationChanged, isActive, isMirrored, onViewReady, onError, onStopped, onPreviewOrientationChanged, onPreviewStarted, enableFrameProcessor, onPreviewStopped, flex, torch, onShutter]
19:26:32.500: [info] 📸 VisionCamera.configurePreviewOrientation(_:): Updating Preview rotation: portrait...
19:26:32.500: [info] 📸 VisionCamera.configureOutputOrientation(_:): Updating Outputs rotation: portrait...
19:26:32.500: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:32.500: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: true, outputsChanged: true, videoStabilizationChanged: true, orientationChanged: true, formatChanged: true, sidePropsChanged: true, torchChanged: true, zoomChanged: true, exposureChanged: true, audioSessionChanged: true, locationChanged: true)
19:26:32.500: [info] 📸 VisionCamera.configureDevice(configuration:): Configuring Input Device...
19:26:32.500: [info] 📸 VisionCamera.configureDevice(configuration:): Configuring Camera 1608A3BE-DD09-41E0-B989-CF8300000001__2...
19:26:32.500: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:32.501: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:32.502: [info] 📸 VisionCamera.configureDevice(configuration:): Successfully configured Input Device!
19:26:32.502: [info] 📸 VisionCamera.configureOutputs(configuration:): Configuring Outputs...
19:26:32.502: [info] 📸 VisionCamera.configureOutputs(configuration:): Adding Code Scanner output...
19:26:32.504: [info] 📸 VisionCamera.configurePreviewOrientation(_:): Updating Preview rotation: portrait...
19:26:32.504: [info] 📸 VisionCamera.configureOutputOrientation(_:): Updating Outputs rotation: portrait...
19:26:32.504: [info] 📸 VisionCamera.configureOutputs(configuration:): Successfully configured all outputs!
19:26:32.504: [info] 📸 VisionCamera.setTargetOutputOrientation(_:): Setting target output orientation from device to device...
<<<< FigCaptureCameraParameters >>>> Fig assert: "success" at bail (FigCaptureCameraParameters.m:255) - (err=0)
CMIOHardware.cpp:418:CMIOObjectSetPropertyData Error: 2003329396, failed
19:26:34.997: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:34.997: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:34.997: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:34.997: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
<<<< FigCaptureCameraParameters >>>> Fig assert: "success" at bail (FigCaptureCameraParameters.m:255) - (err=0)
|___ fsbp_Autofocus ___| Fig assert: "err == noErr" at bail (FigSampleBufferProcessor_Autofocus.m:2451) - (err=0)
nw_connection_add_timestamp_locked_on_nw_queue [C8] Hit maximum timestamp count, will start dropping events
19:26:35.994: [info] 📸 VisionCamera.init(frame:session:): Preview Layer started previewing.
19:26:35.995: [info] 📸 VisionCamera.configure(_:): Beginning AudioSession configuration...
19:26:35.995: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:35.995: [info] 📸 VisionCamera.configureAudioSession(configuration:): Configuring Audio Session...
19:26:35.995: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:35.996: [info] 📸 VisionCamera.configure(_:): Committed AudioSession configuration!
19:26:35.996: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false, locationChanged: false)
19:26:35.996: [info] 📸 VisionCamera.configure(_:): Beginning Location Output configuration...
19:26:36.006: [info] 📸 VisionCamera.configure(_:): Finished Location Output configuration!
19:26:45.921: [info] 📸 VisionCamera.didSetProps(_:): Updating 1 props: [isActive]
19:26:45.921: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:45.921: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false, locationChanged: false)
19:26:45.922: [info] 📸 VisionCamera.init(frame:session:): Preview Layer stopped previewing.
<<<< CMIOFigCaptureStream >>>> Fig assert: "! stream->streaming" at bail (CMIOFigCaptureStream.m:1206) - (err=0)
nw_connection_add_timestamp_locked_on_nw_queue [C7] Hit maximum timestamp count, will start dropping events
nw_connection_add_timestamp_locked_on_nw_queue [C13] Hit maximum timestamp count, will start dropping events
I1112 19:26:49.486549 1880600576 UIManagerBinding.cpp:164] instanceHandle is null, event of type topDisappear will be dropped
19:26:52.386: [info] 📸 VisionCamera.didSetProps(_:): Updating 20 props: [onInitialized, cameraId, codeScannerOptions, enableBufferCompression, preview, onStarted, onCodeScanned, onOutputOrientationChanged, isActive, isMirrored, onViewReady, onError, onStopped, onPreviewOrientationChanged, onPreviewStarted, enableFrameProcessor, onPreviewStopped, flex, torch, onShutter]
19:26:52.386: [info] 📸 VisionCamera.configurePreviewOrientation(_:): Updating Preview rotation: portrait...
19:26:52.386: [info] 📸 VisionCamera.configureOutputOrientation(_:): Updating Outputs rotation: portrait...
19:26:52.387: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:52.387: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: true, outputsChanged: true, videoStabilizationChanged: true, orientationChanged: true, formatChanged: true, sidePropsChanged: true, torchChanged: true, zoomChanged: true, exposureChanged: true, audioSessionChanged: true, locationChanged: true)
19:26:52.387: [info] 📸 VisionCamera.configureDevice(configuration:): Configuring Input Device...
19:26:52.387: [info] 📸 VisionCamera.configureDevice(configuration:): Configuring Camera 1608A3BE-DD09-41E0-B989-CF8300000001__2...
19:26:52.387: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:52.387: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:52.390: [info] 📸 VisionCamera.configureDevice(configuration:): Successfully configured Input Device!
19:26:52.390: [info] 📸 VisionCamera.configureOutputs(configuration:): Configuring Outputs...
19:26:52.390: [info] 📸 VisionCamera.configureOutputs(configuration:): Adding Code Scanner output...
19:26:52.393: [info] 📸 VisionCamera.configurePreviewOrientation(_:): Updating Preview rotation: portrait...
19:26:52.393: [info] 📸 VisionCamera.configureOutputOrientation(_:): Updating Outputs rotation: portrait...
19:26:52.393: [info] 📸 VisionCamera.configureOutputs(configuration:): Successfully configured all outputs!
19:26:52.393: [info] 📸 VisionCamera.setTargetOutputOrientation(_:): Setting target output orientation from device to device...
<<<< FigCaptureCameraParameters >>>> Fig assert: "success" at bail (FigCaptureCameraParameters.m:255) - (err=0)
19:26:52.402: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:52.402: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
CMIOHardware.cpp:418:CMIOObjectSetPropertyData Error: 2003329396, failed
19:26:52.418: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:52.418: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:52.419: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:52.419: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
<<<< FigCaptureCameraParameters >>>> Fig assert: "success" at bail (FigCaptureCameraParameters.m:255) - (err=0)
|___ fsbp_Autofocus ___| Fig assert: "err == noErr" at bail (FigSampleBufferProcessor_Autofocus.m:2451) - (err=0)
19:26:53.567: [info] 📸 VisionCamera.init(frame:session:): Preview Layer started previewing.
19:26:53.569: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:53.569: [info] 📸 VisionCamera.configure(_:): Beginning AudioSession configuration...
19:26:53.569: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:53.569: [info] 📸 VisionCamera.configureAudioSession(configuration:): Configuring Audio Session...
19:26:53.570: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:53.570: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false, locationChanged: false)
19:26:53.570: [info] 📸 VisionCamera.configure(_:): Committed AudioSession configuration!
19:26:53.569: [info] 📸 VisionCamera.configure(_:): Beginning Location Output configuration...
19:26:53.570: [info] 📸 VisionCamera.configure(_:): Finished Location Output configuration!
19:26:54.125: [info] 📸 VisionCamera.didSetProps(_:): Updating 1 props: [isActive]
19:26:54.125: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:54.125: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false, locationChanged: false)
19:26:54.126: [info] 📸 VisionCamera.init(frame:session:): Preview Layer stopped previewing.
<<<< CMIOFigCaptureStream >>>> Fig assert: "! stream->streaming" at bail (CMIOFigCaptureStream.m:1206) - (err=0)
I1112 19:26:54.627750 1880600576 UIManagerBinding.cpp:164] instanceHandle is null, event of type topDisappear will be dropped
19:26:55.296: [info] 📸 VisionCamera.didSetProps(_:): Updating 20 props: [onInitialized, cameraId, codeScannerOptions, enableBufferCompression, preview, onStarted, onCodeScanned, onOutputOrientationChanged, isActive, isMirrored, onViewReady, onError, onStopped, onPreviewOrientationChanged, onPreviewStarted, enableFrameProcessor, onPreviewStopped, flex, torch, onShutter]
19:26:55.296: [info] 📸 VisionCamera.configurePreviewOrientation(_:): Updating Preview rotation: portrait...
19:26:55.296: [info] 📸 VisionCamera.configureOutputOrientation(_:): Updating Outputs rotation: portrait...
19:26:55.296: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:55.296: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: true, outputsChanged: true, videoStabilizationChanged: true, orientationChanged: true, formatChanged: true, sidePropsChanged: true, torchChanged: true, zoomChanged: true, exposureChanged: true, audioSessionChanged: true, locationChanged: true)
19:26:55.296: [info] 📸 VisionCamera.configureDevice(configuration:): Configuring Input Device...
19:26:55.296: [info] 📸 VisionCamera.configureDevice(configuration:): Configuring Camera 1608A3BE-DD09-41E0-B989-CF8300000001__2...
19:26:55.297: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:55.297: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:55.299: [info] 📸 VisionCamera.configureDevice(configuration:): Successfully configured Input Device!
19:26:55.299: [info] 📸 VisionCamera.configureOutputs(configuration:): Configuring Outputs...
19:26:55.299: [info] 📸 VisionCamera.configureOutputs(configuration:): Adding Code Scanner output...
19:26:55.301: [info] 📸 VisionCamera.configurePreviewOrientation(_:): Updating Preview rotation: portrait...
19:26:55.301: [info] 📸 VisionCamera.configureOutputOrientation(_:): Updating Outputs rotation: portrait...
19:26:55.301: [info] 📸 VisionCamera.configureOutputs(configuration:): Successfully configured all outputs!
19:26:55.301: [info] 📸 VisionCamera.setTargetOutputOrientation(_:): Setting target output orientation from device to device...
<<<< FigCaptureCameraParameters >>>> Fig assert: "success" at bail (FigCaptureCameraParameters.m:255) - (err=0)
19:26:55.311: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:55.311: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:55.311: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:55.311: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
CMIOHardware.cpp:418:CMIOObjectSetPropertyData Error: 2003329396, failed
<<<< FigCaptureCameraParameters >>>> Fig assert: "success" at bail (FigCaptureCameraParameters.m:255) - (err=0)
|___ fsbp_Autofocus ___| Fig assert: "err == noErr" at bail (FigSampleBufferProcessor_Autofocus.m:2451) - (err=0)
19:26:55.443: [info] 📸 VisionCamera.init(frame:session:): Preview Layer started previewing.
19:26:55.444: [info] 📸 VisionCamera.configure(_:): Beginning AudioSession configuration...
19:26:55.444: [info] 📸 VisionCamera.configure(_:): Beginning Location Output configuration...
19:26:55.444: [info] 📸 VisionCamera.configureAudioSession(configuration:): Configuring Audio Session...
19:26:55.444: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:55.444: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:55.444: [info] 📸 VisionCamera.configure(_:): Committed AudioSession configuration!
19:26:55.444: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false, locationChanged: false)
19:26:55.444: [info] 📸 VisionCamera.configure(_:): Finished Location Output configuration!
19:26:57.240: [info] 📸 VisionCamera.didSetProps(_:): Updating 1 props: [isActive]
19:26:57.240: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:57.240: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false, locationChanged: false)
19:26:57.241: [info] 📸 VisionCamera.init(frame:session:): Preview Layer stopped previewing.
<<<< CMIOFigCaptureStream >>>> Fig assert: "! stream->streaming" at bail (CMIOFigCaptureStream.m:1206) - (err=0)
I1112 19:26:57.745082 1880600576 UIManagerBinding.cpp:164] instanceHandle is null, event of type topDisappear will be dropped
19:26:58.421: [info] 📸 VisionCamera.didSetProps(_:): Updating 20 props: [onInitialized, cameraId, codeScannerOptions, enableBufferCompression, preview, onStarted, onCodeScanned, onOutputOrientationChanged, isActive, isMirrored, onViewReady, onError, onStopped, onPreviewOrientationChanged, onPreviewStarted, enableFrameProcessor, onPreviewStopped, flex, torch, onShutter]
19:26:58.421: [info] 📸 VisionCamera.configurePreviewOrientation(_:): Updating Preview rotation: portrait...
19:26:58.421: [info] 📸 VisionCamera.configureOutputOrientation(_:): Updating Outputs rotation: portrait...
19:26:58.421: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:58.422: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: true, outputsChanged: true, videoStabilizationChanged: true, orientationChanged: true, formatChanged: true, sidePropsChanged: true, torchChanged: true, zoomChanged: true, exposureChanged: true, audioSessionChanged: true, locationChanged: true)
19:26:58.422: [info] 📸 VisionCamera.configureDevice(configuration:): Configuring Input Device...
19:26:58.422: [info] 📸 VisionCamera.configureDevice(configuration:): Configuring Camera 1608A3BE-DD09-41E0-B989-CF8300000001__2...
19:26:58.422: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:58.422: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:58.424: [info] 📸 VisionCamera.configureDevice(configuration:): Successfully configured Input Device!
19:26:58.424: [info] 📸 VisionCamera.configureOutputs(configuration:): Configuring Outputs...
19:26:58.424: [info] 📸 VisionCamera.configureOutputs(configuration:): Adding Code Scanner output...
19:26:58.427: [info] 📸 VisionCamera.configurePreviewOrientation(_:): Updating Preview rotation: portrait...
19:26:58.427: [info] 📸 VisionCamera.configureOutputOrientation(_:): Updating Outputs rotation: portrait...
19:26:58.427: [info] 📸 VisionCamera.configureOutputs(configuration:): Successfully configured all outputs!
19:26:58.427: [info] 📸 VisionCamera.setTargetOutputOrientation(_:): Setting target output orientation from device to device...
<<<< FigCaptureCameraParameters >>>> Fig assert: "success" at bail (FigCaptureCameraParameters.m:255) - (err=0)
19:26:58.437: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:58.437: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
CMIOHardware.cpp:418:CMIOObjectSetPropertyData Error: 2003329396, failed
19:26:58.452: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:58.452: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:26:58.452: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:26:58.452: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
<<<< FigCaptureCameraParameters >>>> Fig assert: "success" at bail (FigCaptureCameraParameters.m:255) - (err=0)
|___ fsbp_Autofocus ___| Fig assert: "err == noErr" at bail (FigSampleBufferProcessor_Autofocus.m:2451) - (err=0)
19:26:58.567: [info] 📸 VisionCamera.init(frame:session:): Preview Layer started previewing.
19:26:58.568: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:58.568: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:58.568: [info] 📸 VisionCamera.configure(_:): Beginning AudioSession configuration...
19:26:58.568: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:26:58.568: [info] 📸 VisionCamera.configureAudioSession(configuration:): Configuring Audio Session...
19:26:58.568: [info] 📸 VisionCamera.configure(_:): Beginning Location Output configuration...
19:26:58.568: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false, locationChanged: false)
19:26:58.568: [info] 📸 VisionCamera.configure(_:): Committed AudioSession configuration!
19:26:58.568: [info] 📸 VisionCamera.configure(_:): Finished Location Output configuration!
19:27:02.960: [info] 📸 VisionCamera.didSetProps(_:): Updating 1 props: [isActive]
19:27:02.960: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:27:02.960: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false, locationChanged: false)
19:27:02.961: [info] 📸 VisionCamera.init(frame:session:): Preview Layer stopped previewing.
<<<< CMIOFigCaptureStream >>>> Fig assert: "! stream->streaming" at bail (CMIOFigCaptureStream.m:1206) - (err=0)
I1112 19:27:03.458796 1880600576 UIManagerBinding.cpp:164] instanceHandle is null, event of type topDisappear will be dropped
19:27:06.819: [info] 📸 VisionCamera.didSetProps(_:): Updating 20 props: [onInitialized, cameraId, codeScannerOptions, enableBufferCompression, preview, onStarted, onCodeScanned, onOutputOrientationChanged, isActive, isMirrored, onViewReady, onError, onStopped, onPreviewOrientationChanged, onPreviewStarted, enableFrameProcessor, onPreviewStopped, flex, torch, onShutter]
19:27:06.819: [info] 📸 VisionCamera.configurePreviewOrientation(_:): Updating Preview rotation: portrait...
19:27:06.819: [info] 📸 VisionCamera.configureOutputOrientation(_:): Updating Outputs rotation: portrait...
19:27:06.819: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:27:06.819: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: true, outputsChanged: true, videoStabilizationChanged: true, orientationChanged: true, formatChanged: true, sidePropsChanged: true, torchChanged: true, zoomChanged: true, exposureChanged: true, audioSessionChanged: true, locationChanged: true)
19:27:06.819: [info] 📸 VisionCamera.configureDevice(configuration:): Configuring Input Device...
19:27:06.819: [info] 📸 VisionCamera.configureDevice(configuration:): Configuring Camera 1608A3BE-DD09-41E0-B989-CF8300000001__2...
19:27:06.820: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:27:06.820: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:27:06.822: [info] 📸 VisionCamera.configureDevice(configuration:): Successfully configured Input Device!
19:27:06.822: [info] 📸 VisionCamera.configureOutputs(configuration:): Configuring Outputs...
19:27:06.822: [info] 📸 VisionCamera.configureOutputs(configuration:): Adding Code Scanner output...
19:27:06.824: [info] 📸 VisionCamera.configurePreviewOrientation(_:): Updating Preview rotation: portrait...
19:27:06.824: [info] 📸 VisionCamera.configureOutputOrientation(_:): Updating Outputs rotation: portrait...
19:27:06.824: [info] 📸 VisionCamera.configureOutputs(configuration:): Successfully configured all outputs!
19:27:06.824: [info] 📸 VisionCamera.setTargetOutputOrientation(_:): Setting target output orientation from device to device...
<<<< FigCaptureCameraParameters >>>> Fig assert: "success" at bail (FigCaptureCameraParameters.m:255) - (err=0)
19:27:06.835: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:27:06.835: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
CMIOHardware.cpp:418:CMIOObjectSetPropertyData Error: 2003329396, failed
19:27:06.848: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:27:06.848: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:27:06.848: [info] 📸 VisionCamera.didSetProps(_:): Updating 0 props: []
19:27:06.848: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
<<<< FigCaptureCameraParameters >>>> Fig assert: "success" at bail (FigCaptureCameraParameters.m:255) - (err=0)
|___ fsbp_Autofocus ___| Fig assert: "err == noErr" at bail (FigSampleBufferProcessor_Autofocus.m:2451) - (err=0)
19:27:08.255: [info] 📸 VisionCamera.init(frame:session:): Preview Layer started previewing.
19:27:08.256: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:27:08.256: [info] 📸 VisionCamera.configure(_:): Beginning AudioSession configuration...
19:27:08.256: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:27:08.256: [info] 📸 VisionCamera.configureAudioSession(configuration:): Configuring Audio Session...
19:27:08.256: [info] 📸 VisionCamera.didSetProps(_:): A new configure { ... } call arrived, aborting this one...
19:27:08.257: [info] 📸 VisionCamera.configure(_:): Beginning Location Output configuration...
19:27:08.257: [info] 📸 VisionCamera.configure(_:): Committed AudioSession configuration!
19:27:08.257: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false, locationChanged: false)
19:27:08.257: [info] 📸 VisionCamera.configure(_:): Finished Location Output configuration!
19:27:09.077: [info] 📸 VisionCamera.didSetProps(_:): Updating 1 props: [isActive]
19:27:09.077: [info] 📸 VisionCamera.configure(_:): configure { ... }: Waiting for lock...
19:27:09.077: [info] 📸 VisionCamera.configure(_:): configure { ... }: Updating CameraSession Configuration... Difference(inputChanged: false, outputsChanged: false, videoStabilizationChanged: false, orientationChanged: false, formatChanged: false, sidePropsChanged: false, torchChanged: false, zoomChanged: false, exposureChanged: false, audioSessionChanged: false, locationChanged: false)
19:27:09.078: [info] 📸 VisionCamera.init(frame:session:): Preview Layer stopped previewing.

Camera Device

{
  "isMultiCam": false,
  "hardwareLevel": "full",
  "formats": [],
  "maxExposure": 8,
  "id": "1608A3BE-DD09-41E0-B989-CF8300000001__2",
  "supportsRawCapture": false,
  "hasTorch": false,
  "maxZoom": 67.5,
  "supportsFocus": false,
  "hasFlash": true,
  "supportsLowLightBoost": false,
  "minExposure": -8,
  "sensorOrientation": "portrait",
  "neutralZoom": 1,
  "physicalDevices": [
    "wide-angle-camera"
  ],
  "minZoom": 1,
  "name": "vPhone Camera",
  "position": "back",
  "minFocusDistance": 0
}

Device

iPhone 13 Pro iOS 18.2

VisionCamera Version

4.6.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

maintenance-hans[bot] commented 5 days ago

Guten Tag, Hans here.

Thanks for your detailed report, but it looks like you need to gather ze logs from Xcode or adb logcat to help mrousavy understand ze problem better. Also, make sure to try reproducing ze issue in the VisionCamera Example app, as this is essential to get it resolved.

If you want quicker responses, consider supporting ze project by sponsoring mrousavy. Cheers! 🍻

Note: If you think I made a mistake by closing this issue, please ping @mrousavy to take a look.

Voxar commented 5 days ago

I did not manage to run the example. I get errors following the readme

⋊> ~/W/T/r/r/package on main ⨯ bun bootstrap 
$ bun && cd example && bun && bun pods
Bun is a fast JavaScript runtime, package manager, bundler, and test runner. (1.1.34+5e5e7c60f)

Usage: bun <command> [...flags] [...args]

Commands:
  run       ./my-script.ts       Execute a file with Bun
            lint                 Run a package.json script
  test                           Run unit tests with Bun
  x         nuxi                 Execute a package binary (CLI), installing if needed (bunx)
  repl                           Start a REPL session with Bun
  exec                           Run a shell script directly with Bun

  install                        Install dependencies for a package.json (bun i)
  add       elysia               Add a dependency to package.json (bun a)
  remove    moment               Remove a dependency from package.json (bun rm)
  update    @shumai/shumai       Update outdated dependencies
  outdated                       Display latest versions of outdated dependencies
  link      [<package>]          Register or link a local npm package
  unlink                         Unregister a local npm package
  publish                        Publish a package to the npm registry
  patch <pkg>                    Prepare a package for patching
  pm <subcommand>                Additional package management utilities

  build     ./a.ts ./b.jsx       Bundle TypeScript & JavaScript into a single file

  init                           Start an empty Bun project from a blank template
  create    next-app             Create a new project from a template (bun c)
  upgrade                        Upgrade to latest version of Bun.
  <command> --help               Print help text for command.

Learn more about Bun:            https://bun.sh/docs
Join our Discord community:      https://bun.sh/discord
/bin/bash: line 0: cd: example: No such file or directory
error: script "bootstrap" exited with code 1
Voxar commented 2 days ago

Hello @mrousavy. I do think the bot made a mistake closing this as I did attach an xcode log and I could not run the example at all by following the current instructions.

Turns out the issues are only surfaced when I'm using the Continuity Camera. I guess that is a bit narrow case for you and others to bother with. I will try anyways as development is so much nicer when you can the app you work on directly on the Mac.

Any ideas on the threading issue would be welcome as I have no clue about what React Natives thread handling looks like. I'll start with trying to just dispatch all MotionManager calls to the same queue.

Here's a demo app: https://github.com/Voxar/react-native-vision-camera-continuity-camera-crash