iOS 10 [AVAudioSession privateInterruptionWithInfo:] crash - ios10

The new version has a large number of crashes on iOS 10.
The message is
SEGV_ACCERR
libobjc.A.dylib objc_msgSend
There are two kinds of crashes.
1:
libobjc.A.dylib objc_msgSend + 16
AVFAudio -[AVAudioSession privateInterruptionWithInfo:] + 172
AVFAudio (anonymous namespace)::HandlePropertyListenerCallback(unsigned int, objc_selector*, NSObject*) + 92
libdispatch.dylib __dispatch_call_block_and_release + 24
libdispatch.dylib __dispatch_client_callout + 16
libdispatch.dylib _dispatch_main_queue_callback_4CF + 1000
CoreFoundation ___CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
CoreFoundation ___CFRunLoopRun + 1660
CoreFoundation CFRunLoopRunSpecific + 444
GraphicsServices GSEventRunModal + 180
UIKit -[UIApplication _run] + 684
UIKit UIApplicationMain + 208
MyApplication main (main.m:16)
libdyld.dylib _start + 4
2:
libobjc.A.dylib objc_msgSend + 28
libAVFAudio.dylib -[AVAudioSession privateBeginInterruption] + 60
Foundation ___NSThreadPerformPerform + 340
CoreFoundation ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
CoreFoundation ___CFRunLoopDoSources0 + 412
CoreFoundation ___CFRunLoopRun + 724
CoreFoundation CFRunLoopRunSpecific + 384
GraphicsServices GSEventRunModal + 180
UIKit UIApplicationMain + 204
MyApplication main (main.m:16)
libdyld.dylib _start + 4
How do I solve this problem?

The delegate property is deprecated in AVAudioSession and it is replaced with a Notification AVAudioSessionInterruptionNotification. So rather using delegate property register for this notification. Image depicting the same from header of AVAudioSession.h -

Related

Need help in finding crash cause

Below are the crash logs from an iPad. I'm getting this crash randomly while I'm pushing and popping out a UIViewController from Navigation controller. Any help/pointer is appreciated.
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x00000000
Crashed Thread: 0
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libobjc.A.dylib 0x31430386 _ZL12realizeClassP7class_t + 34
1 libobjc.A.dylib 0x314303e6 _ZL12realizeClassP7class_t + 130
2 libobjc.A.dylib 0x3142a836 prepareForMethodLookup + 74
3 libobjc.A.dylib 0x3142a740 lookUpMethod + 40
4 libobjc.A.dylib 0x3142a70c _class_lookupMethodAndLoadCache3 + 12
5 libobjc.A.dylib 0x31429fc4 objc_msgSend_uncached + 20
6 UIKit 0x3186553e -[UINavigationItem _accumulateViewsFromItems:isLeft:refreshViews:] + 270
7 UIKit 0x31851244 -[UINavigationItem _updateViewsForBarSizeChangeAndApply:] + 124
8 UIKit 0x319e023a __33-[UINavigationBar layoutSubviews]_block_invoke_0 + 250
9 UIKit 0x31838b46 +[UIView(Animation) _performWithoutAnimation:] + 62
10 UIKit 0x3184d2e2 -[UINavigationBar layoutSubviews] + 382
11 UIKit 0x31814f30 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 176
12 CoreFoundation 0x315431f4 -[NSObject performSelector:withObject:] + 36
13 QuartzCore 0x35459a9e -[CALayer layoutSublayers] + 210
14 QuartzCore 0x354596b6 CA::Layer::layout_if_needed(CA::Transaction*) + 210
15 QuartzCore 0x3545d83c CA::Context::commit_transaction(CA::Transaction*) + 220
16 QuartzCore 0x3545d578 CA::Transaction::commit() + 308
17 QuartzCore 0x354554b2 CA:::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 50
18 CoreFoundation 0x315b8b14 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 12
19 CoreFoundation 0x315b6d50 __CFRunLoopDoObservers + 252
20 CoreFoundation 0x315b70aa __CFRunLoopRun + 754
21 CoreFoundation 0x3153a49e CFRunLoopRunSpecific + 294
22 CoreFoundation 0x3153a366 CFRunLoopRunInMode + 98
23 GraphicsServices 0x32a13432 GSEventRunModal + 130
24 UIKit 0x3183fcce UIApplicationMain + 1074
25 SmartClassTPS 0x000b551a main (main.m:16)
26 SmartClassTPS 0x000b5170 start + 32
Was able to figure out long back but forgot to update here. KVO observer not removed! Silly me :-|. BTW thanks for the support. SO rocks.
Most probably you forgot to clear some delegates before releasing an object.

Rare not reproducible crash related to UIKit

I have a random-looking crash related to UIKit and I can't seem to figure out what is wrong.
Does anyone see a familiar pattern here or do you think this might be a random OS-related crash? Is there a way to find out which Buttons or UI-elements were involved here?
Thread 0 Crashed:
0 libobjc.A.dylib 0x35260f78 objc_msgSend + 15
1 UIKit 0x312363d7 -[UIView(Hierarchy) superview] + 50
2 UIKit 0x31239abb -[UIView nextResponder] + 82
3 UIKit 0x31354011 forwardTouchMethod + 36
4 UIKit 0x3124f97d -[UIWindow _sendTouchesForEvent:] + 400
5 UIKit 0x3124f319 -[UIWindow sendEvent:] + 380
6 UIKit 0x31235695 -[UIApplication sendEvent:] + 356
7 UIKit 0x313e762f __42-[UIApplication _cancelTouches:withEvent:]_block_invoke_0 + 54
8 UIKit 0x312a5d0d -[UIApplication _cancelTouches:withEvent:includingGestures:notificationBlock:] + 544
9 UIKit 0x312a5ae9 -[UIApplication _cancelTouches:withEvent:] + 84
10 UIKit 0x31234eb1 _UIApplicationHandleEvent + 5688
11 GraphicsServices 0x33c7722b PurpleEventCallback + 882
12 CoreFoundation 0x37535523 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 38
13 CoreFoundation 0x375354c5 __CFRunLoopDoSource1 + 140
14 CoreFoundation 0x37534313 __CFRunLoopRun + 1370
15 CoreFoundation 0x374b74a5 CFRunLoopRunSpecific + 300
16 CoreFoundation 0x374b736d CFRunLoopRunInMode + 104
17 GraphicsServices 0x33c76439 GSEventRunModal + 136
18 UIKit 0x31263cd5 UIApplicationMain + 1080

iphone - understanding crash logs

Im developing my app and yesterday while I was playing with it crashed. I wasnt debugging, so I thought I'd take a look at the crash log today.
But my surprise is that I can't see anything that can give me some info, here it is:
Thread 0 Crashed:
0 libobjc.A.dylib 0x33479464 objc_msgSend + 16
1 MapKit 0x31bffe28 -[MKMapView annotationContainer:viewForAnnotation:] + 36
2 MapKit 0x31bffaba -[MKAnnotationContainerView _addViewForAnnotation:] + 270
3 MapKit 0x31c25540 -[MKAnnotationContainerView addViewForManagedAnnotation:] + 8
4 MapKit 0x31c21df2 -[MKMapView(UserPositioningInternal) _runPositioningChange] + 1034
5 MapKit 0x31c20036 -[MKMapView(UserPositioningInternal) _startPositioningChange:] + 22
6 MapKit 0x31c23446 -[MKMapView(UserPositioningInternal) locationManagerUpdatedLocation:] + 578
7 CoreFoundation 0x33a5ebb8 -[NSObject(NSObject) performSelector:withObject:] + 16
8 CoreFoundation 0x33a83266 -[NSArray makeObjectsPerformSelector:withObject:] + 394
9 MapKit 0x31c1232a -[MKLocationManager _reportLocationStatus:] + 34
10 MapKit 0x31c13844 -[MKLocationManager _reportLocationSuccess] + 36
11 MapKit 0x31c134b8 -[MKLocationManager locationManager:didUpdateToLocation:fromLocation:] + 688
12 CoreLocation 0x34371410 -[CLLocationManager onClientEventLocation:] + 528
13 CoreLocation 0x3436f68e -[CLLocationManager onClientEvent:supportInfo:] + 98
14 CoreLocation 0x3436f7e6 OnClientEventInternal + 14
15 CoreLocation 0x3436b534 CLClientInvokeCallback(__CLClient*, CLClientEvent, __CFDictionary const*) + 60
16 CoreLocation 0x3436d3cc CLClientHandleDaemonDataLocation(__CLClient*, CLClientLocation const*, __CFDictionary const*) + 196
17 CoreLocation 0x3436d512 CLClientHandleDaemonData(__CFMessagePort*, long, __CFData const*, void*) + 286
18 CoreFoundation 0x33a813fe __CFMessagePortPerform + 242
19 CoreFoundation 0x33a556f8 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 20
20 CoreFoundation 0x33a556bc __CFRunLoopDoSource1 + 160
21 CoreFoundation 0x33a47f76 __CFRunLoopRun + 514
22 CoreFoundation 0x33a47c80 CFRunLoopRunSpecific + 224
23 CoreFoundation 0x33a47b88 CFRunLoopRunInMode + 52
24 GraphicsServices 0x33b0e4a4 GSEventRunModal + 108
25 GraphicsServices 0x33b0e550 GSEventRun + 56
26 UIKit 0x32099322 -[UIApplication _run] + 406
27 UIKit 0x32096e8c UIApplicationMain + 664
28 Palyque 0x0000280a main (main.m:14)
29 Palyque 0x00002794 start + 44
Hope you can help me with this, thanks.
Without the app still in memory I'm not sure there's much you can do. From experience I guess you messaged an object that has been dealloc'd. (Maybe the datasource object for your MKMapView?) I'd try running your app with zombies enabled to track it down.

Why deleteRecording crashed (AVAudioRecorder, iOS)?

[recorder deleteRecording]; works well 30 times, but around 31 it crashes.
0 libobjc.A.dylib 0x3266fc98 objc_msgSend + 16
1 Foundation 0x328c203c -[NSError dealloc] + 36
2 CoreFoundation 0x30d2dc3c -[NSObject(NSObject) release] + 24
3 Foundation 0x328e687c -[NSFilesystemItemRemoveOperation dealloc] + 36
4 Foundation 0x328bc7b2 -[NSOperation release] + 38
5 CoreFoundation 0x30d2e19a CFRelease + 62
6 CoreFoundation 0x30d30eb4 _CFAutoreleasePoolPop + 140
7 Foundation 0x328abbae NSPopAutoreleasePool + 2
8 Foundation 0x3293a908 __NSThreadPerformPerform + 620
9 CoreFoundation 0x30da0a72 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 6
10 CoreFoundation 0x30da2758 __CFRunLoopDoSources0 + 376
11 CoreFoundation 0x30da34e4 __CFRunLoopRun + 224
12 CoreFoundation 0x30d33ebc CFRunLoopRunSpecific + 224
13 CoreFoundation 0x30d33dc4 CFRunLoopRunInMode + 52
14 GraphicsServices 0x31896418 GSEventRunModal + 108
15 GraphicsServices 0x318964c4 GSEventRun + 56
16 UIKit 0x355b9d62 -[UIApplication _run] + 398
17 UIKit 0x355b7800 UIApplicationMain + 664
18 AppName 0x000020f6 main (main.m:16)
19 AppName 0x00002050 start + 44
I found that this happens when deleteRecording is trying to delete a non existent file. So check if file exists before you call it:
if ([[NSFileManager defaultManager] fileExistsAtPath:self.recorder.url.path]) {
if (![self.recorder deleteRecording])
NSLog(#"Failed to delete %#", self.recorder.url);
}
It must be a bug in AVAudioRecorder.

Enumeration Mutation During UIView transitionWithView

I'm experience an occasional crash of my iPhone application where I'm getting the following exception
NSGenericException', reason: '*** Collection <CALayerArray: 0x26f6b0> was mutated while being enumerated.
With the stack trace on the crashing thread of
Thread 0 Crashed:
0 libSystem.B.dylib 0x00078ac8 __kill + 8
1 libSystem.B.dylib 0x00078ab8 kill + 4
2 libSystem.B.dylib 0x00078aaa raise + 10
3 libSystem.B.dylib 0x0008d03a abort + 50
4 libstdc++.6.dylib 0x00044a20 __gnu_cxx::__verbose_terminate_handler() + 376
5 libobjc.A.dylib 0x00005958 _objc_terminate + 104
6 libstdc++.6.dylib 0x00042df2 __cxxabiv1::__terminate(void (*)()) + 46
7 libstdc++.6.dylib 0x00042e46 std::terminate() + 10
8 libstdc++.6.dylib 0x00042f16 __cxa_throw + 78
9 libobjc.A.dylib 0x00004838 objc_exception_throw + 64
10 CoreFoundation 0x0009f850 __NSFastEnumerationMutationHandler + 208
11 libobjc.A.dylib 0x0000a51a objc_enumerationMutation + 18
12 UIKit 0x00007bfe -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 142
13 UIKit 0x00007c2e -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:withObject:copySublayers:] + 190
14 UIKit 0x00007cd2 -[UIView(Hierarchy) _makeSubtreePerformSelector:withObject:] + 22
15 UIKit 0x00007628 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 304
16 UIKit 0x000074e8 -[UIView(Hierarchy) addSubview:] + 16
17 UIKit 0x0006c350 +[UIViewControllerWrapperView wrapperViewForView:frame:] + 232
18 UIKit 0x00077d0c -[UINavigationController _startTransition:fromViewController:toViewController:] + 468
19 UIKit 0x00077abc -[UINavigationController _startDeferredTransitionIfNeeded] + 176
20 UIKit 0x00077a00 -[UINavigationController viewWillLayoutSubviews] + 8
21 UIKit 0x0006dca8 -[UILayoutContainerView layoutSubviews] + 132
22 UIKit 0x0000fbc0 -[UIView(CALayerDelegate) _layoutSublayersOfLayer:] + 20
23 CoreFoundation 0x0003e2e4 -[NSObject(NSObject) performSelector:withObject:] + 16
24 QuartzCore 0x0000f942 -[CALayer layoutSublayers] + 114
25 QuartzCore 0x0000f6fa CALayerLayoutIfNeeded + 178
26 QuartzCore 0x000094c4 CA::Context::commit_transaction(CA::Transaction*) + 204
27 QuartzCore 0x000092da CA::Transaction::commit() + 186
28 QuartzCore 0x0002d9b6 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 46
29 CoreFoundation 0x00030236 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 10
30 CoreFoundation 0x000300aa __CFRunLoopDoObservers + 406
31 CoreFoundation 0x000276b4 __CFRunLoopRun + 848
32 CoreFoundation 0x00027270 CFRunLoopRunSpecific + 224
33 CoreFoundation 0x00027178 CFRunLoopRunInMode + 52
34 GraphicsServices 0x000045ec GSEventRunModal + 108
35 GraphicsServices 0x00004698 GSEventRun + 56
36 UIKit 0x0000411c -[UIApplication _run] + 396
37 UIKit 0x00002128 UIApplicationMain + 664
38 iDriveGreen 0x00003026 main (main.m:13)
39 iDriveGreen 0x00002ff0 start + 32
This crash is being triggered after the following code is executed.
StopRouteViewController *stopVC = [[StopRouteViewController alloc] init];
[UIView transitionWithView:self.navigationController.view
duration:0.5
options:UIViewAnimationOptionTransitionFlipFromLeft
animations:^{
[self.navigationController pushViewController:stopVC animated:NO];
}
completion:NULL];
[stopVC release];
Does this look blatantly wrong to anyone? My current thought is that is is either tied to stopVC being released before it is pushed or with transitioning with navigationController.view while at the same time pushing a new viewController to the navigationController.
Since this only occurs occasionally, I'd like to have a little more confidence before I commit a potential fix.
Yes, this is incorrect usage of the API. -[UINavigationController pushViewController:animated:] handles animation on its own. Even if you pass NO as the second argument, it is still manipulating the view hierarchy, which is what's causing your crash.
Basically, there is no reason to put a call to -[UINavigationController pushViewController:animated:] in an animation block, as you have done. If you want to animate the push of your controller, pass YES as the second argument.