Search code examples
arkitsigabrthittest

ARKit crashing in iOS 11.3


Since iOS11.3 I'm getting a significant number of new crash reports from my AR measurement app.

The crash description says: Exception Type: SIGABRT Exception Codes: #0 at 0x181b112ec Crashed Thread: 0 Application Specific Information: *** Terminating app due to uncaught exception 'std::invalid_argument', reason: 'extrinsicTransform must have determinant 1.'

The crash is triggered by this line in my code, which is called on didUpdateFrame

NSArray<ARHitTestResult *> *resultArray = [_arsnView hitTest:position types:ARHitTestResultTypeExistingPlaneUsingExtent | ARHitTestResultTypeEstimatedHorizontalPlane];

According to the crash reporting, it happens to about 10% of the sessions (!!!!). Before iOS11.3, I had <0.1% crashes.

I tried feeding the hitTest with different values for position, including NaN etc, but I'm not able to reproduce the crash.

Any ideas?

Thanks!!

UPDATE 1

I checked that the currentFrame is still valid when calling the hitTest. Despite checking this with if(_arsnView.session.currentFrame), the app still shows the same crash :(


Solution

  • Thanks for your help. I found that checking the trackingState before performing the hitTest, resolves the crash. So basically, I'm checking:

    if (_arsnView.session.currentFrame.camera.trackingState!=ARTrackingStateNormal) 
    {
         // do not perform hitTest
    }
    else 
    {
         // perform hitTest
    }
    

    In this example, _arsnView is a property from class ARSCNView