简体   繁体   English

Apple iOS ARKit:“传感器无法提供所需的输入”错误并停止工作

[英]Apple iOS ARKit: “A sensor failed to deliver the required input” error and stops working

I am developing an application that uses both ARKit and hardware video decoder. 我正在开发一个同时使用ARKit和硬件视频解码器的应用程序。 As soon as the decoder start to decode, the following error message appears in console and prevent tracking from working properly. 一旦解码器开始解码,控制台中就会出现以下错误消息,并阻止跟踪正常工作。

Occasionally, this error do not show up and the app works normally. 有时,此错误不会显示,应用程序正常工作。 After some debugging, I found out this error only happens at the "beginning" (shortly after launching the app). 经过一些调试后,我发现这个错误只发生在“开始”(启动应用程序后不久)。 Once it passes that point, it works fine for the rest of the time. 一旦它通过该点,它在其余时间工作正常。

Does anyone know what the problem is or how to go around it? 有谁知道问题是什么或如何绕过它?


2017-08-11 20:48:02.550228-0700 PortalMetal[4037:893878] [] <<<< AVCaptureSession >>>> -[AVCaptureSession _handleServerConnectionDiedNotification]: (0x1c0007eb0)(pthread:0x170387000) ServerConnectionDied 2017-08-11 20:48:02.564053-0700 PortalMetal[4037:893747] [Session] Session did fail with error: Error Domain=com.apple.arkit.error Code=102 "Required sensor failed." 2017-08-11 20:48:02.550228-0700 PortalMetal [4037:893878] [] <<<< AVCaptureSession >>>> - [AVCaptureSession _handleServerConnectionDiedNotification] :( 0x1c0007eb0)(pthread:0x170387000)ServerConnectionDied 2017-08-11 20 :48:02.564053-0700 PortalMetal [4037:893747] [会话]会话确实失败并显示错误:错误Domain = com.apple.arkit.error Code = 102“所需传感器失败。” UserInfo={NSLocalizedFailureReason=A sensor failed to deliver the required input., NSUnderlyingError=0x1c4c51280 {Error Domain=AVFoundationErrorDomain Code=-11819 "Cannot Complete Action" UserInfo={NSLocalizedDescription=Cannot Complete Action, NSLocalizedRecoverySuggestion=Try again later.}}, NSLocalizedRecoverySuggestion=Make sure that the application has the required privacy settings., NSLocalizedDescription=Required sensor failed.} UserInfo = {NSLocalizedFailureReason =传感器未能提供所需的输入。,NSUnderlyingError = 0x1c4c51280 {错误域= AVFoundationErrorDomain代码= -11819“无法完成操作”UserInfo = {NSLocalizedDescription =无法完成操作,NSLocalizedRecoverySuggestion =稍后再试。}}, NSLocalizedRecoverySuggestion =确保应用程序具有所需的隐私设置。,NSLocalizedDescription =必需的传感器失败。}


Update 更新

The solution is to do with compass calibration being set in the phone settings. 解决方案是在手机设置中设置罗盘校准。 Credit to this answer. 相信这个答案。

Go to Settings > Privacy > Location Services > System Services, and set Compass Calibration to ON. 转至设置>隐私>位置服务>系统服务,然后将指南针校准设置为开。

How to prevent Crashing 如何防止崩溃

Declare your config at the top of your class eg: 在您的班级顶部声明您的配置,例如:

var configuration = ARWorldTrackingConfiguration() and make sure you setup and add your config in the viewWillAppear method. var configuration = ARWorldTrackingConfiguration()并确保在viewWillAppear方法中设置并添加配置。

Then add this method to handle the error. 然后添加此方法来处理错误。

func session(_ session: ARSession, didFailWithError error: Error) {
    // Present an error message to the user
    print("Session failed. Changing worldAlignment property.")
    print(error.localizedDescription)

    if let arError = error as? ARError {
        switch arError.errorCode {
        case 102:
            configuration.worldAlignment = .gravity
            restartSessionWithoutDelete()
        default:
            restartSessionWithoutDelete()
        }
    }
}

It just handles the error that you've noticed. 它只是处理你注意到的错误。

Next, add this function to reset the session with a new config worldAlignment: 接下来,添加此函数以使用新的配置worldAlignment重置会话:

func restartSessionWithoutDelete() {
    // Restart session with a different worldAlignment - prevents bug from crashing app
    self.sceneView.session.pause()

    self.sceneView.session.run(configuration, options: [
        .resetTracking,
        .removeExistingAnchors])
}

Hope it helps, and I also hope to find an actual fix to this apparent bug. 希望它有所帮助,我也希望找到这个明显错误的实际修复。

Setting worldAlignment to gravityAndHeading needs the location service to be enabled: worldAlignment设置为gravityAndHeading需要启用位置服务:

  • check if your device has location service turned on. 检查您的设备是否已启用位置服务。
  • Check if Info.plist has set Privacy - Photo Library Additions Usage Description 检查Info.plist是否设置了Privacy - Photo Library Additions Usage Description

If the compass orientation is crucial for your app, you should consider to guide the user to do turn the location service on and implement a fallback. 如果指南针方向对您的应用至关重要,则应考虑引导用户启用位置服务并实施后备。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ARkit统一项目,视频播放停止。 iOS 11.2.5,错误:Domain = com.apple.arkit.error代码= 102“必需的传感器失败。” - ARkit unity project, video playback stops. iOS 11.2.5 with error: Domain=com.apple.arkit.error Code=102 “Required sensor failed.” 使用 ARKit 读取 iOS 光传感器 - Reading iOS light sensor with ARKit 跟踪iOS分配时,Apple Instruments停止工作 - Apple Instruments stops working when tracing iOS allocations 当应用程序从后台删除时,Apple Push通知无法在ios 7上传递 - Apple Push notification not deliver on ios 7 when application remove from background 与Apple的通信失败错误 - Communication with Apple failed error Apple Developer Portal 的身份验证失败:Apple Service Error -1018 while expo build:ios - Authentication with Apple Developer Portal failed! Apple Service Error -1018 while expo build:ios 错误:无法安装此模板所需的 iOS 项目的 CocoaPods 依赖项 - Error: Failed to install CocoaPods dependencies for iOS project, which is required by this template Apple Pay是否需要与新的iOS应用程序集成? - Is Apple Pay a required integration with new iOS apps? ios7中的CLLocationManager停止工作 - CLLocationManager in ios7 stops working ARKit代码问题{未知错误-1 = ffffffffffffffffff错误:任务因退出1而失败} - ARKit code issue {unknown error -1=ffffffffffffffff error: Task failed with exit 1}
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM