Open short-dsb opened 5 months ago
I don't even have activeColorSpace
in the codebase. This was in V2, but not in V3 or V4. Are you sure you are on 4.0.4?
Hm. Maybe this user was on an older version. I don’t see any repeats of this particular issue today. Thanks for taking a look. 🙂
Can confirm that this is still happening with 4.3.2. Here's the symbolicated stack traces:
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x83f20 __exceptionPreprocess
1 libobjc.A.dylib 0x16018 objc_exception_throw
2 AVFCapture 0x59d90 __61-[AVCaptureDeferredPhotoProcessor _establishServerConnection]_block_invoke
3 libdispatch.dylib 0x3dd4 _dispatch_client_callout
4 libdispatch.dylib 0x132c4 _dispatch_lane_barrier_sync_invoke_and_complete
5 AVFCapture 0x5d7ec -[AVCaptureFigVideoDevice setActiveColorSpace:]
6 Foundation 0x147c0c -[NSObject(NSKeyValueObservingPrivate) _changeValueForKeys:count:maybeOldValuesDict:maybeNewValuesDict:usingBlock:]
7 Foundation 0x1478ac -[NSObject(NSKeyValueObservingPrivate) _changeValueForKey:key:key:usingBlock:]
8 Foundation 0x1467e8 _NSSetLongLongValueAndNotify
9 AVFCapture 0xb698 -[AVCaptureSession _updateDeviceActiveFormatsAndActiveConnections]
10 AVFCapture 0x28498 -[AVCaptureSession _buildAndRunGraph:]
11 AVFCapture 0x2821c -[AVCaptureSession _commitConfiguration]
12 AVFCapture 0x20cf4 -[AVCaptureSession addOutput:]
13 <app_name> 0x6bdac8 CameraSession.configureOutputs(configuration:) + 16 (AVCapturePhotoOutput.QualityPrioritization+descriptor.swift:16)
14 <app_name> 0x6b9fe4 closure #1 in CameraSession.configure(_:) + 135 (CameraSession.swift:135)
15 <app_name> 0x8abcc thunk for @escaping @callee_guaranteed @Sendable () -> () (<compiler-generated>)
@mrousavy please consider reopening this issue.
This is a completely different issue @mars-lan. Also, what is the NSInvalidArgumentException
's message? There's only a stacktrace, but no error.
This is a completely different issue @mars-lan. Also, what is the
NSInvalidArgumentException
's message? There's only a stacktrace, but no error.
My bad. Here's the missing error message for NSInvalidArgumentException
, which is why I believe it's the same issue.
Fatal Exception: NSInvalidArgumentException
*** -[AVCaptureDevice setActiveColorSpace:] Not supported - use activeFormat.supportedColorSpaces
@mars-lan you're either on VisionCamera V2 (which is by far no longer supported), or this is an Apple bug. As I said above, activeColorSpace
is not used by VisionCamera anymore.
@mars-lan you're either on VisionCamera V2 (which is by far no longer supported), or this is an Apple bug. As I said above,
activeColorSpace
is not used by VisionCamera anymore.
The app is using VisionCamera 4.3.2. You're correct that it doesn't set activeColorSpace
directly, but based on the stack traces, the function is eventually invoked by AVFCapture
:
5 AVFCapture 0x5d7ec -[AVCaptureFigVideoDevice setActiveColorSpace:]
FWIW, we've seen this issue on iOS 16.5.1, 17.3.1 & 17.5.1 for various iPhone models (12, 13, 15).
Well then it might be an iOS bug? I don't see anything in the stacktrace that I'm doing wrong.. Also I can't reproduce this 😅
Well then it might be an iOS bug? I don't see anything in the stacktrace that I'm doing wrong.. Also I can't reproduce this 😅
It's possible. We also can't reproduce this ourselves either. Seen this on 7 different devices so far in Crashlytics so it's not exactly rare.
I don’t see any repeats of this particular issue today.
Just an update that we’re still seeing this issue periodically. As @mars-lan said, it seems to affect a variety of models and iOS versions.
Per this Stack Overflow comment, a workaround may be to set automaticallyConfiguresCaptureDeviceForWideColor
to false
on the AVCaptureSession
instance. Worth a shot?
Interesting - yea can you just set that on your end and let me know if it fixed anything? You can put that inside the configure
block.
Same here, found this on firebase crashlytics + users reporting it, but can't reproduce it myself.
@mrousavy We haven’t seen this issue since we applied the workaround, although it’s only been a couple weeks. At the very least, there seem to be no undesirable side effects.
If anyone wants to try this as well and maybe get more signal, you can apply the following diff via patch-package
.
diff --git a/node_modules/react-native-vision-camera/ios/Core/CameraSession.swift b/node_modules/react-native-vision-camera/ios/Core/CameraSession.swift
index 10b0f33..587b92e 100644
--- a/node_modules/react-native-vision-camera/ios/Core/CameraSession.swift
+++ b/node_modules/react-native-vision-camera/ios/Core/CameraSession.swift
@@ -132,6 +132,9 @@ final class CameraSession: NSObject, AVCaptureVideoDataOutputSampleBufferDelegat
VisionLogger.log(level: .info, message: "configure { ... }: Updating CameraSession Configuration... \(difference)")
do {
+ // https://github.com/mrousavy/react-native-vision-camera/issues/2892
+ self.captureSession.automaticallyConfiguresCaptureDeviceForWideColor = false;
+
// If needed, configure the AVCaptureSession (inputs, outputs)
if difference.isSessionConfigurationDirty {
self.captureSession.beginConfiguration()
Can confirm that the fix works. @mrousavy please consider adding it.
What's happening?
This iOS crash appears to be a new instance of #198 on v4.0.4.
Reproduceable Code
Relevant log output
Camera Device
Device
iOS 17.4.1
VisionCamera Version
4.0.4
Can you reproduce this issue in the VisionCamera Example app?
No, I cannot reproduce the issue in the Example app
Additional information