expo: [expo-camera/next 14.1.*] Expo Go app crashes when opening Camera
Minimal reproducible example
https://github.com/the-devbear/expo-camera-next-mre
What platform(s) does this occur on?
iOS
Did you reproduce this issue in a development build?
Yes
Summary
Hello, I’m using an IPhone 12 with expo Go and wanted to use the barcode scanner. Since the BarcodeScanner package redirects to expo-camera/next I wanted to use this instead. But unfortunately the expo go crashes as soon as I trie to open the camera.
It only crashes when I’m using CameraView and not Camera. It also works on the version 14.0.6.
Unfortunately I don’t get any error message in the terminal were I ran the build it just crashes…
So please let me know, how I can provide more Information.
Video 1: version 14.1.1
https://github.com/expo/expo/assets/104125178/83d235c6-2180-4f29-8635-571c9664facb
Video 2: version 14.0.6
https://github.com/expo/expo/assets/104125178/8307d568-66b1-4255-9fa8-7ac2ec9441b7
If I can help in any other way please let me know.
Environment
expo-env-info 1.2.0 environment info:
System:
OS: macOS 14.1.2
Shell: 5.9 - /bin/zsh
Binaries:
Node: 20.12.0 - ~/.nvm/versions/node/v20.12.0/bin/node
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 10.5.0 - ~/.nvm/versions/node/v20.12.0/bin/npm
Managers:
CocoaPods: 1.14.3 - /opt/homebrew/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 23.0, iOS 17.0, macOS 14.0, tvOS 17.0, watchOS 10.0
IDEs:
Xcode: 15.0/15A240d - /usr/bin/xcodebuild
npmPackages:
expo: ~50.0.14 => 50.0.14
react: 18.2.0 => 18.2.0
react-native: 0.73.6 => 0.73.6
npmGlobalPackages:
eas-cli: 7.6.2
Expo Workflow: managed
Expo Doctor Diagnostics
npx expo-doctor@latest
Need to install the following packages:
expo-doctor@1.5.0
Ok to proceed? (y) y
✔ Check Expo config for common issues
✔ Check package.json for common issues
✔ Check dependencies for packages that should not be installed directly
✔ Check for common project setup issues
✔ Check for issues with metro config
✔ Check npm/ yarn versions
✔ Check Expo config (app.json/ app.config.js) schema
✔ Check for legacy global CLI installed locally
✔ Check native tooling versions
✔ Check that native modules do not use incompatible support packages
✔ Check that native modules use compatible support package versions for installed Expo SDK
✔ Check that packages match versions required by installed Expo SDK
Didn't find any issues with the project!
About this issue
- Original URL
- State: closed
- Created 3 months ago
- Reactions: 5
- Comments: 23 (1 by maintainers)
This should be resolved in 14.1.3
I am also seeing this; like @the-devbear, 14.0.6 works whereas 14.1.2 crashes. This is happening for us in our development builds.
I’m also still having this issue even tho I have set the mute prop to
true.These are the crash logs copied from Xcode.
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** -[AVCaptureSession startRunning] startRunning may not be called between calls to beginConfiguration and commitConfiguration' *** First throw call stack: (0x18ddeab28 0x185c5ef78 0x1aac18e1c 0x102810bcc 0x10280168c 0x195bfadd4 0x195bfe2d8 0x195c121c8 0x195c10d8c 0x195c02284 0x195c02f30 0x195c0dcb4 0x195c0d528 0x1e9ce0f20 0x1e9ce0fc0)I have the same issue as @the-devbear. In my tests I found out, that the camera shows a black screen if the app has no permissions for the camera functionality but does not crash. If it does have permissions, it crashes instantly.
@alanjhughes
I had the same issue as shown on the video from OP, but using Development Builds. I bumped the version to 14.1.3, but as the two previous comments it doesn’t resolve it for me.
I even tried using yarn as suggested here: https://github.com/expo/expo/issues/27410
The Console shows:
While debugging I decided to switch to Expo Go, which I don’t generally use anymore and the camera started working again. What could be the reason for the difference?
@andrewbeckman I installed 14.1.3 which hasn’t solved the issue unfortunately…App crashed when request permissions on video (both camera and microphone.
thanks for your regards
I am using expo-camera/next@14.1.1 for barcode scanning only, so microphone is naturally NOT needed. I’ve added the
muteprop to theCameraViewand nomicrophonePermissionorNSMicrophoneUsageDescriptionto app config. Now I am not getting the microphone permissions prompt - just as expected. I am however still getting the NSGenericException error every time I start the camera, together with an app crash. I have granted permissions to use the camera.I tried do downgrade to 14.0.6, and this caused me to only get the error the first time, directly after granting permissions. Subsequent times when I opened the camera it ran smoothly.
I also tried to upgrade to 14.1.2 In hopes of some fix that would affect this but it acts the same as 14.1.1 (i.e. camera crashes every time after granting camera permission)
I looked into the error message in my logging tool and noticed that the error occurs in two different functions: the public func
onAppForegroundedand the private funcstartSession, both inCameraViewNextinexpo/packages/expo-camera/ios/Next/CameraViewNext.swift.There seems to be a delay in
startSession:async/await in swift is beyond my expertise, but it looks to me as if the delay is added to allow for commitConfiguration to complete instead of actually awaiting it or having some form of callback. Seems relevant since the error message states that
... startRunning may not be called between calls to beginConfiguration and commitConfiguration'.Does it imply that startRunning is called before commitConfiguration is called or before it is completed?
If the first is true and startRunning is called before commitConfiguration is called then perhaps it is called by another async function in parallel?
addErrorNotificationis called just two lines abovecommitConfigurationin the code block from the startSession func pasted above, andstartRunningis indeed called insideaddErrorNotification. Given async nature and the right timing then thestartRunningcall inaddErrorNotificationcould trigger beforecommitConfigurationinstartSession.The old/legacy expo-camera
Cameraview swift class does not do things the same way. It doesn’t run commitConfiguration prior to startRunning, but does this instead:These are just my observations, but I know nothing about swift so… Hopefully someone more knowledgeable can see exactly what needs to be done here.
I’ve reverted to “expo-camera”: “14.0.6”, and all works as excepted
same here, same error when crash, but I found it just randomly happen, sometimes it works, sometimes it crash instantly after allow permission
I have the same issue.
Had a look at their solution to set the
muteprop totrue, but this did not resolve the issue. Unfortunately for me, the application still crashes every time the camera is accessed. 😢Same issue encountared on a development build.
I was able to getting an error message: