Start a new topic

AVCaptureSession can't startRunning between calls to beginConfiguration

AVCaptureSession can't startRunning between calls to beginConfiguration


Hi,

I'm updating an existing application which uses Wikitude iOS SDK. I'm now getting an error when I start the WTArchitectView view:

*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** AVCaptureSession can't startRunning between calls to beginConfiguration / commitConfiguration'

I'm using the public SDK 4.0.2 (with a correct license key), testing on iOS 8.0.2 / iPhone 5.

The full call stack is:

Thread 1Queue : com.apple.main-thread (serial)

#0 0x33a49dfc in __pthread_kill ()

#1 0x33ac7d36 in pthread_kill ()

#2 0x339e9908 in abort ()

#3 0x32d279c8 in abort_message ()

#4 0x32d41670 in default_terminate_handler() ()

#5 0x33403f24 in _objc_terminate() ()

#6 0x32d3ede2 in std::__terminate(void (*)()) ()

#7 0x32d3e5a8 in __cxa_throw ()

#8 0x33403d5e in objc_exception_throw ()

#9 0x248964a0 in - ()

#10 0x002b57c8 in __63-_block_invoke ()

#11 0x00e1daea in _dispatch_call_block_and_release ()

#12 0x00e1dad6 in _dispatch_client_callout ()

#13 0x00e214f6 in _dispatch_main_queue_callback_4CF ()

#14 0x25d1bbe8 in __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ ()

#15 0x25d1a2e8 in __CFRunLoopRun ()

#16 0x25c68620 in CFRunLoopRunSpecific ()

#17 0x25c68432 in CFRunLoopRunInMode ()

#18 0x2d0170a8 in GSEventRunModal ()

#19 0x29253358 in UIApplicationMain ()

#20 0x001ab484 in main

Enqueued from com.apple.main-thread (Thread 1)Queue : com.apple.main-thread (serial)

#0 0x00e28794 in _dispatch_barrier_async_f_slow ()

#1 0x00e1ec20 in dispatch_async ()

#2 0x002b56c8 in - ()

#3 0x0027e33c in wikitude::ios_sdk::impl::iOSCameraService::startPlatformCamera() ()

#4 0x0027f478 in - ()

#5 0x00285aee in - ()

#6 0x0027fde0 in wikitude::ios_sdk::impl::iOSPlatformServiceProvider::startService(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) ()

#7 0x003cc6c2 in wikitude::sdk_core::impl::CameraService::doResume() ()

#8 0x00415556 in wikitude::sdk_core::impl::ArchitectService::resume() ()

#9 0x003c094c in wikitude::sdk_core::impl::ServiceManager::resume() ()

#10 0x00460eb0 in wikitude::sdk_core::impl::ArchitectEngine::resume() ()

#11 0x002cb03e in - ()

#12 0x002c79ca in - ()

 

 

The SDK is being used as follows:

 

    if (!self.architectView)

    {

        self.architectView = ;

        self.architectView.delegate = self;

        ;

        ;

    }

    

    ;

    if ( )

    {

        DDLogInfo(@"ARchitect is running with version: %@", );

        ;

        

    }

 

 

Today I received your test results with the custom SDK that you send us via mail. I will write the answer only in the forum since more people can benefit from it. The additional log output was somehow expected but doesn't bring me closer to a solution.

Can you please tell me if you're calling any Wikitude iOS SDK API from within an dispatch_async block? Maybe you can post the complete view controller impl. so that I can see the overal SDK usage. 

As I don't have an iPhone 5 running iOS 8.0.2 it's a little bit hard to debug. Can you reproduce the issue on any other device/iOS combination?

Best regards

Andreas

 

Hi,

No, it's not being called within a dispatch_async block. I have also tested on both iPhone 5 / iOS 7.1 and iPhone 6+ / iOS 8.1 and everything works correctly, the problem only occurs on the iPhone 5 / iOS 8.0.2. (I haven't tested other devices with iOS 8.0.x).

The view controller implementation is as follows:

 

- (void)viewWillAppear:(BOOL)animated

{

    ;

    

    if (!self.architectView)

    {

        self.architectView = ;

        self.architectView.delegate = self;

        ;

        ;

    }

    ;

    if ( )

    {

        DDLogInfo(@"ARchitect is running with version: %@", );

        ;

        

    }

    else

    {

        DDLogError(@"WTARchitectView wasn't able to start. Please check e.g. the -ObjC linker flag in your project settings.");

    }

}

 

- (void)viewWillDisappear:(BOOL)animated

{

    ;

    ;

}

 

- (void)didReceiveMemoryWarning

{

    ;

    // Dispose of any resources that can be recreated.

}

 

- (void)loadARchitectWorldForWorldName:(NSString *)worldName

{

    if (self.architectView.superview)

    {

        if (worldName)

        {

            NSURL *absoluteWorldURL = ;

            if (absoluteWorldURL)

            {

                ;

            

            }

            else

            {

                DDLogError(@"Unable to find ARchitect World path in App resouce bundle: %@", worldName);

            }

            

        }

        else

        {

            DDLogError(@"Undefined ARchitect world name");

        }

    }

}

 

- (void)architectView:(WTArchitectView *)architectView didFinishLoad:(NSURL *)url

{

    ;

}

 

Hi,

I have tested with the custom framework provided, and have nailed the source of the problem.

The error messages reported by the library are:

architect view encountered internal error: Error Domain=com.wikitude.architect.services.camera Code=106 "Error creating device input for camera position '1'. ('Error Domain=AVFoundationErrorDomain Code=-11852 "Cannot use Back Camera" UserInfo=0x199ae320 {NSLocalizedDescription=Cannot use Back Camera, AVErrorDeviceKey=<AVCaptureFigVideoDevice: 0x199a8750 >, NSLocalizedFailureReason=This app is not authorized to use Back Camera.}')" UserInfo=0x199ae340 {NSLocalizedDescription=Error creating device input for camera position '1'. ('Error Domain=AVFoundationErrorDomain Code=-11852 "Cannot use Back Camera" UserInfo=0x199ae320 {NSLocalizedDescription=Cannot use Back Camera, AVErrorDeviceKey=<AVCaptureFigVideoDevice: 0x199a8750 >, NSLocalizedFailureReason=This app is not authorized to use Back Camera.}')}

 

The cause of the issue is not iOS 8.0.2 specific, but that the app was denied permission to use the camera. This of couse can be checked in our app before instantiating the WTArchitectView, though of course it is an improvement if this error can be detected and reported by the Wikitude library (or at least not crashing when this error occurs).

 

Thanks very much for your help is solving this issue.

 

Hi Nigel,
Thx for reporting, testing and also finding the issue! We will definitely improve the error handling in the next SDK release.

Just one more question: Did the SDK crash with the latest .framework you had? Have you tried to call -start with a @try @catch block?

Best regards

Andreas

No, the latest framework didn't crash after showing the error message in the console. It just showed a blank screen as would be expected if access to the camera has not been authorised.

 

Perfect, than this will be part of the SDK 4.1 which will be release beginning of 2015.

Best regards

Andreas
Login or Signup to post a comment