I'm current running iOS 13 Beta 3. This is happening on my XS Max I use for development, but it can happen on other models and OS versions too.
When creating ARSessions, mostly when using an ARFaceTrackingConfiguration but to a lesser extent with an ARWorldTrackingConfiguration, one of two things happen.
1) The code hangs during the call to create the ARSCNView() instance, requiring a reboot of the phone before this will work again, or
2) I get an error from the ARSession error handler "func session(_ session: ARSession, didFailWithError error: Error)" reporting "Required sensor failed"
I keep resetting the session via the following code fragment recommended in other threads:
let configuration = ARFaceTrackingConfiguration()
configuration.worldAlignment = .gravity
//configuration.worldAlignment = .gravityAndHeading
arSceneView.session.run(configuration, options: [
I've tried everything mentioned in the forums here and that I've found via Google searches, including during the reset:
- Setting configuration.worldAlignment to .gravity, which fares no better than .gravityAndHeading
- Setting the just-mentioned settings before the initial call to create the session configuration doesn't help either.
- Turning Compass Calibration on the phone either on or off
- Verifying that the proper Location settings are enabled and tested in the code prior to setting up the session, and all of the proper text string combinations are set for Location Always, When in Use, and Always and When in Use
- Verifying in settings that Location services are on and that Location for the app is set to Always
If I have the app just keep endlessly resetting the session, eventually it works (unless the ARSCNView creation fails and a reboot is required), sometimes on the first try and sometimes on the Nth try (even a dozen or more) one or two minutes later, so it really can't be due to any permission setting on the phone or it would always fail.
Rebooting the phone may help a little, but sometimes it will do the session failure even on the first run after a reboot. Running builds in either Release or Debug, with or without XCode, don't appear to make any difference.
I'm at wits end and have to assume others are still running into this even though there aren't any recent posts on the topic.
Does anyone have any suggestions?