iOS 9 Crashing in _prepareForCAFlush with EXC_BAD_ACCESS KERN_INVALID_ADDRESS

寵の児 提交于 2019-12-01 02:36:35

For me the problem was that I was showing and dismissing the keyboard when the application was minimized.

    [self.textView becomeFirstResponder];
    [self.textView resignFirstResponder];

I performed the above code on the applicationWillResignActive event. removing this code fixed the crash.

We encountered the a crash with a similar stack trace, and after a long investigation we found out that it was related to an other crash; fixing that also fixed this, however I'm still unsure how the two crashes are related.

Here are the details about the other crash:

We had a function call in one of our methods like

AudioServicesAddSystemSoundCompletion(self.soundID,  
                                      [[NSRunLoop currentRunLoop] getCFRunLoop],  
                                      kCFRunLoopDefaultMode,  
                                      AudioServicesSystemSoundCompletion,  
                                      (void *)CFBridgingRetain(self)); 

where AudioServicesSystemSoundCompletion looked like

void AudioServicesSystemSoundCompletion(SystemSoundID ssID,  void *clientData) {  
     AudioServicesRemoveSystemSoundCompletion(ssID);  
     CFRelease(clientData);  
}

Executing that function call two or more times simultaneously caused the app to crash. We fixed this by passing NULL instead of (void *)CFBridgingRetain(self) and removing the CFRelease(clientData); line.

Since this fix we no longer see the '_prepareForCAFlush' crash anymore.

Also note that according to Crashlytics the device had very high memory usage each time the crash has reproduced.

Hope this helps!

I'm also facing this issue and I think that I found what might be causing it. Are you guys by any chance using SDWebImage? Because that's the only place where I found that CFRunLoopRun() is being called and also other people complained on: Dead thread ticket -> App Crash

Seems to be only affecting devices with 32-bit processors A5 and A6 - iPod 5th Gen, iPhone 4S/5/5C, iPad 2/Mini). No repro on our side either. These crashes started and ramped up with iOS 9 release and adoption. iOS v9.0.1 does not seem to fix it.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!