Question

I submit my app to app store and after 5 days they reject it. They tell me that the app crashed on 7.1.1 iPhone 5s running iOS 7.1.1.

Is it a problem on the library AFNetworking?

Thank you for help.

This is the crash report :

Exception Type:  EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Triggered by Thread:  0

Last Exception Backtrace:
(0x18c2e2950 0x198cbc1fc 0x18afca928 0x10006812c 0x18f2ac670 0x18f2ac3f4 0x10007e828 0x18f2c410c 0x18f332508 0x18f332470 0x18f29e4cc 0x18c2a30a8 0x18c2a0330 0x18c2a06bc 0x18c1e16d0 0x191e7dc0c 0x18f312fdc 0x100104e08 0x1992afaa0)

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0   libsystem_kernel.dylib          0x00000001993aa868 __semwait_signal_nocancel + 8
1   libsystem_c.dylib               0x000000019931be5c usleep$NOCANCEL + 64
2   libsystem_c.dylib               0x000000019933e80c abort + 116
3   Bubbler                         0x0000000100155b3c 0x100028000 + 1235772
4   CoreFoundation                  0x000000018c2e2ce4 __handleUncaughtException + 640
5   libobjc.A.dylib                 0x0000000198cbc4c4 _objc_terminate() + 112
6   libc++abi.dylib                 0x000000019857f164 std::__terminate(void (*)()) + 12
7   libc++abi.dylib                 0x000000019857ed38 __cxa_rethrow + 140
8   libobjc.A.dylib                 0x0000000198cbc3a4 objc_exception_rethrow + 40
9   CoreFoundation                  0x000000018c1e1748 CFRunLoopRunSpecific + 572
10  GraphicsServices                0x0000000191e7dc08 GSEventRunModal + 164
11  UIKit                           0x000000018f312fd8 UIApplicationMain + 1152
12  Bubbler                         0x0000000100104e04 0x100028000 + 904708
13  libdyld.dylib                   0x00000001992afa9c start + 0

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x0000000199391aa8 kevent64 + 8
1   libdispatch.dylib               0x0000000199295998 _dispatch_mgr_thread + 48

Thread 2:
0   libsystem_kernel.dylib          0x00000001993aae74 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x0000000199429548 start_wqthread + 0

Thread 3:
0   libsystem_kernel.dylib          0x00000001993aae74 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x0000000199429548 start_wqthread + 0

Thread 4:
0   libsystem_kernel.dylib          0x0000000199391ca0 mach_msg_trap + 8
1   CoreFoundation                  0x000000018c2a2570 __CFRunLoopServiceMachPort + 180
2   CoreFoundation                  0x000000018c2a0700 __CFRunLoopRun + 832
3   CoreFoundation                  0x000000018c1e16cc CFRunLoopRunSpecific + 448
4   Foundation                      0x000000018cd7d2c0 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 292
5   Foundation                      0x000000018cddad74 -[NSRunLoop(NSRunLoop) run] + 92
6   Bubbler                         0x000000010016ebc8 0x100028000 + 1338312
7   Foundation                      0x000000018ce64408 __NSThread__main__ + 996
8   libsystem_pthread.dylib         0x000000019942be18 _pthread_body + 164
9   libsystem_pthread.dylib         0x000000019942bd70 _pthread_start + 136
10  libsystem_pthread.dylib         0x0000000199429550 thread_start + 0

Thread 5:
0   libsystem_kernel.dylib          0x00000001993aae74 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x0000000199429548 start_wqthread + 0

Thread 6:
0   libsystem_kernel.dylib          0x00000001993aae74 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x0000000199429548 start_wqthread + 0

Thread 7 name:  AFNetworking
Thread 7:
0   libsystem_kernel.dylib          0x0000000199391ca0 mach_msg_trap + 8
1   CoreFoundation                  0x000000018c2a2570 __CFRunLoopServiceMachPort + 180
2   CoreFoundation                  0x000000018c2a0700 __CFRunLoopRun + 832
3   CoreFoundation                  0x000000018c1e16cc CFRunLoopRunSpecific + 448
4   Foundation                      0x000000018cd7d2c0 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 292
5   Foundation                      0x000000018cddad74 -[NSRunLoop(NSRunLoop) run] + 92
6   Bubbler                         0x0000000100037ff0 0x100028000 + 65520
7   Foundation                      0x000000018ce64408 __NSThread__main__ + 996
8   libsystem_pthread.dylib         0x000000019942be18 _pthread_body + 164
9   libsystem_pthread.dylib         0x000000019942bd70 _pthread_start + 136
10  libsystem_pthread.dylib         0x0000000199429550 thread_start + 0

Thread 8 name:  com.apple.NSURLConnectionLoader
Thread 8:
0   libsystem_kernel.dylib          0x0000000199391ca0 mach_msg_trap + 8
1   CoreFoundation                  0x000000018c2a2570 __CFRunLoopServiceMachPort + 180
2   CoreFoundation                  0x000000018c2a0700 __CFRunLoopRun + 832
3   CoreFoundation                  0x000000018c1e16cc CFRunLoopRunSpecific + 448
4   Foundation                      0x000000018cdd6424 +[NSURLConnection(Loader) _resourceLoadLoop:] + 344
5   Foundation                      0x000000018ce64408 __NSThread__main__ + 996
6   libsystem_pthread.dylib         0x000000019942be18 _pthread_body + 164
7   libsystem_pthread.dylib         0x000000019942bd70 _pthread_start + 136
8   libsystem_pthread.dylib         0x0000000199429550 thread_start + 0

Thread 9:
0   libsystem_kernel.dylib          0x00000001993aae74 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x0000000199429548 start_wqthread + 0

Thread 10:
0   libsystem_kernel.dylib          0x00000001993aae74 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x0000000199429548 start_wqthread + 0

Thread 11:
0   libsystem_kernel.dylib          0x00000001993aae74 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x0000000199429548 start_wqthread + 0

Thread 12:
0   libsystem_kernel.dylib          0x00000001993aae74 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x0000000199429548 start_wqthread + 0

Thread 13:
0   libsystem_kernel.dylib          0x00000001993aae74 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x0000000199429548 start_wqthread + 0

Thread 14:
0   libsystem_kernel.dylib          0x00000001993aae74 __workq_kernreturn + 8
1   libsystem_pthread.dylib         0x0000000199429548 start_wqthread + 0

Thread 15:
0   libsystem_kernel.dylib          0x0000000199391ca0 mach_msg_trap + 8
1   CoreFoundation                  0x000000018c2a2570 __CFRunLoopServiceMachPort + 180
2   CoreFoundation                  0x000000018c2a0700 __CFRunLoopRun + 832
3   CoreFoundation                  0x000000018c1e16cc CFRunLoopRunSpecific + 448
4   Foundation                      0x000000018cd7d2c0 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 292
5   Foundation                      0x000000018cddad74 -[NSRunLoop(NSRunLoop) run] + 92
6   Bubbler                         0x0000000100145414 0x100028000 + 1168404
7   Foundation                      0x000000018ce64408 __NSThread__main__ + 996
8   libsystem_pthread.dylib         0x000000019942be18 _pthread_body + 164
9   libsystem_pthread.dylib         0x000000019942bd70 _pthread_start + 136
10  libsystem_pthread.dylib         0x0000000199429550 thread_start + 0

Thread 16 name:  com.apple.CFSocket.private
Thread 16:
0   libsystem_kernel.dylib          0x00000001993aa76c __select + 8
1   libsystem_pthread.dylib         0x000000019942be18 _pthread_body + 164
2   libsystem_pthread.dylib         0x000000019942bd70 _pthread_start + 136
3   libsystem_pthread.dylib         0x0000000199429550 thread_start + 0

Thread 0 crashed with ARM Thread State (64-bit):
    x0: 0x000000000000003c   x1: 0x0000000000000000   x2: 0x0000000000000001   x3: 0x0000000000000001
    x4: 0x0000000000000000   x5: 0x0000000000989680   x6: 0x0000000000000000   x7: 0x0000000000000000
    x8: 0x000000019c1f6000   x9: 0x0000000000000001  x10: 0x0000000000000000  x11: 0x00000000431bde83
   x12: 0x0000000000000018  x13: 0x0000000000060000  x14: 0x0000000000000000  x15: 0x0000000000000000
   x16: 0x00000000000001a7  x17: 0x00000001001d8390  x18: 0x0000000000000000  x19: 0x0000000000000000
   x20: 0x000000016fdd78b0  x21: 0x00000001997050e0  x22: 0x000000017004e370  x23: 0x0000000000000013
   x24: 0x0000000000000013  x25: 0x000000018f97c190  x26: 0x000000018f997f64  x27: 0x000000018c34dcb5
   x28: 0x00000001996fc1f8  fp: 0x000000016fdd78a0   lr: 0x00000001992f6e4c
    sp: 0x000000016fdd7870   pc: 0x00000001993aa868 cpsr: 0xa0000000

UPDATE

Class captureDeviceClass = NSClassFromString(@"AVCaptureDevice"); 
if (captureDeviceClass != nil) { 
    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 
    [device lockForConfiguration:nil]; 
    [device setFlashMode:AVCaptureFlashModeOff]; 
    [device unlockForConfiguration]; 
} //It crash in this line [device setFlashMode:AVCaptureFlashModeOff];
Was it helpful?

Solution

From Apple docs:

@property(nonatomic) AVCaptureFlashMode flashMode

Discussion
Before changing the value of this property, 
you must call lockForConfiguration: 
to acquire exclusive access to the device’s configuration properties. 
Otherwise, setting the value of this property raises an exception. 
When you are done configuring the device, call unlockForConfiguration 
to release the lock and allow other devices to configure the settings.

That's why it's crashing, you need to acquire exclusive access.

So just add:

if ([device isFlashModeSupported:AVCaptureFlashModeOff) {
    NSError *error;
    if ([device lockForConfiguration:&error) {
        //It's now safe to add your original code here....
        [device setFlashMode:AVCaptureFlashModeOff]; 
    }

    else 
        NSLog(@"ERROR: %@", [error localizedDescription]);
}

This way if there is a reason why the app can't lock in the flash mode you want you will get an error. It will also skip over it so it won't raise and exception & crash.

*untested just from reading the docs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top