簡體   English   中英

Apple iOS ARKit:“傳感器無法提供所需的輸入”錯誤並停止工作

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

我正在開發一個同時使用ARKit和硬件視頻解碼器的應用程序。 一旦解碼器開始解碼,控制台中就會出現以下錯誤消息,並阻止跟蹤正常工作。

有時,此錯誤不會顯示,應用程序正常工作。 經過一些調試后,我發現這個錯誤只發生在“開始”(啟動應用程序后不久)。 一旦它通過該點,它在其余時間工作正常。

有誰知道問題是什么或如何繞過它?


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 =傳感器未能提供所需的輸入。,NSUnderlyingError = 0x1c4c51280 {錯誤域= AVFoundationErrorDomain代碼= -11819“無法完成操作”UserInfo = {NSLocalizedDescription =無法完成操作,NSLocalizedRecoverySuggestion =稍后再試。}}, NSLocalizedRecoverySuggestion =確保應用程序具有所需的隱私設置。,NSLocalizedDescription =必需的傳感器失敗。}


更新

解決方案是在手機設置中設置羅盤校准。 相信這個答案。

轉至設置>隱私>位置服務>系統服務,然后將指南針校准設置為開。

如何防止崩潰

在您的班級頂部聲明您的配置,例如:

var configuration = ARWorldTrackingConfiguration()並確保在viewWillAppear方法中設置並添加配置。

然后添加此方法來處理錯誤。

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()
        }
    }
}

它只是處理你注意到的錯誤。

接下來,添加此函數以使用新的配置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])
}

希望它有所幫助,我也希望找到這個明顯錯誤的實際修復。

worldAlignment設置為gravityAndHeading需要啟用位置服務:

  • 檢查您的設備是否已啟用位置服務。
  • 檢查Info.plist是否設置了Privacy - Photo Library Additions Usage Description

如果指南針方向對您的應用至關重要,則應考慮引導用戶啟用位置服務並實施后備。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM