I am seeing a crash in AppDelegate. I believe it is related to a song ending just as I go to make an in-app purchase or possibly the sound effect that I play when an in-app purchase completes (sort of a coin sound), as it happens occasionally but not frequently.
The crash log (below below) points to this in particular as the last thing called before the crash:
4 SpriteKit 0x233882e3c -[SKSoundSource purgeCompletedBuffers] + 155
I handle stopping and starting audio with code as follows:
func applicationWillResignActive(_ application: UIApplication)
{
// Nil out the system clock variables
if GameData.sharedInstance.isValidSystemClock != nil && GameData.sharedInstance.isValidSystemClock!
{
GameData.sharedInstance.isValidSystemClock = nil
}
GameData.sharedInstance.currentServerTime = nil
// Capture the last time the user was in the app, so we can catch if they rewind their system clock while offline
GameData.sharedInstance.timeOfLastAppLaunch = CFAbsoluteTimeGetCurrent()
// Save game data to file
GameData.sharedInstance.saveGameToFile()
//schedule notifications for user to come back soon!
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "scheduleNotificationFreeChest"), object: nil)
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "scheduleNotificationReminders"), object: nil)
NotificationCenter.default.post(name: NSNotification.Name(rawValue: "scheduleNotificationLivesFull"), object: nil)
//pause background music if it's playing
if AssetsSounds.sharedInstance.bgmTitlePlayer?.isPlaying ?? false
{
AssetsSounds.sharedInstance.bgmTitlePlayer?.pause()
needToPlayTitleMusic = true
}
//pause game music if it's playing
if AssetsSounds.sharedInstance.bgmGamePlayer?.isPlaying ?? false
{
AssetsSounds.sharedInstance.bgmGamePlayer?.pause()
needToPlayGameMusic = true
}
if AssetsSounds.sharedInstance.bgmBonusLoop?.isPlaying ?? false
{
AssetsSounds.sharedInstance.bgmBonusLoop?.pause()
needToPlayBonusLoop = true
}
if AssetsSounds.sharedInstance.bgmBonusLeadIn?.isPlaying ?? false
{
AssetsSounds.sharedInstance.bgmBonusLeadIn?.pause()
needToPlayBonusLeadIn = true
}
if AssetsSounds.sharedInstance.bgmFiveMovesLeft?.isPlaying ?? false
{
AssetsSounds.sharedInstance.bgmFiveMovesLeft?.pause()
needToPlayFiveMovesLeft = true
}
if AssetsSounds.sharedInstance.bgmRainWithBirds?.isPlaying ?? false
{
AssetsSounds.sharedInstance.bgmRainWithBirds?.pause()
needToPlayRainWithBirds = true
}
}
And, upon return from the interruption:
func applicationDidBecomeActive(_ application: UIApplication)
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
// kill notifications scheduled since user is back
UNUserNotificationCenter.current().removeAllPendingNotificationRequests()
// Clears app badge number; we put a 1 when we send a notification
UIApplication.shared.applicationIconBadgeNumber = 0
if AVAudioSession.sharedInstance().secondaryAudioShouldBeSilencedHint
{
AssetsSounds.sharedInstance.bgmGamePlayer?.stop()
AssetsSounds.sharedInstance.bgmGamePlayer = nil
needToPlayGameMusic = false
AssetsSounds.sharedInstance.bgmTitlePlayer?.stop()
AssetsSounds.sharedInstance.bgmTitlePlayer = nil
needToPlayTitleMusic = false
AssetsSounds.sharedInstance.bgmBonusLeadIn?.stop()
AssetsSounds.sharedInstance.bgmBonusLeadIn = nil
needToPlayBonusLeadIn = false
AssetsSounds.sharedInstance.bgmBonusLoop?.stop()
AssetsSounds.sharedInstance.bgmBonusLoop = nil
needToPlayBonusLoop = false
AssetsSounds.sharedInstance.bgmFiveMovesLeft?.stop()
AssetsSounds.sharedInstance.bgmFiveMovesLeft = nil
needToPlayFiveMovesLeft = false
AssetsSounds.sharedInstance.bgmRainWithBirds?.stop()
AssetsSounds.sharedInstance.bgmRainWithBirds = nil
needToPlayRainWithBirds = false
}
else if needToPlayGameMusic || needToPlayTitleMusic || needToPlayRainWithBirds || needToPlayBonusLoop || needToPlayBonusLeadIn || needToPlayFiveMovesLeft
{
//play background music if it needs to be played
if needToPlayTitleMusic
{
AssetsSounds.sharedInstance.bgmTitlePlayer?.play()
needToPlayTitleMusic = false
}
//play game music if it needs to be played
if needToPlayGameMusic
{
AssetsSounds.sharedInstance.bgmGamePlayer?.play()
needToPlayGameMusic = false
}
if needToPlayBonusLoop
{
AssetsSounds.sharedInstance.bgmBonusLoop?.play()
needToPlayBonusLoop = false
}
if needToPlayBonusLeadIn
{
AssetsSounds.sharedInstance.bgmBonusLeadIn?.play()
needToPlayBonusLeadIn = false
}
if needToPlayFiveMovesLeft
{
AssetsSounds.sharedInstance.bgmFiveMovesLeft?.play()
needToPlayFiveMovesLeft = false
}
if needToPlayRainWithBirds
{
AssetsSounds.sharedInstance.bgmRainWithBirds?.play()
needToPlayRainWithBirds = false
}
} // end else if
else
{
if viewController.mapScreen != nil
{
AssetsSounds.sharedInstance.bgmTitlePlayer = AssetsSounds.sharedInstance.loadAudioPlayer(SongType.title1, loops: 0)
AssetsSounds.sharedInstance.bgmTitlePlayer?.play()
}
else if viewController.scene != nil && viewController.gameState != .gameover && viewController.gameState != .lost && viewController.gameState != .won && viewController.level != nil && viewController.level.songType != nil
{
AssetsSounds.sharedInstance.bgmGamePlayer = AssetsSounds.sharedInstance.loadAudioPlayer(viewController.level.songType!, loops: 0)
AssetsSounds.sharedInstance.bgmGamePlayer?.play()
viewController.scene.addMusicCredits()
} // end else if
}
}
Have others seen similar crashes related to sound / interruptions? What is the proper way to handle this?
I have seen another post: Sprite Kit & playing sound leads to app termination that references this, but I am not sure if my issue is the same or if the answer here is valid.
Below is the symbolic crash log from my phone:
OS Version: iPhone OS 12.3.1 (16F203)
Baseband Version: 3.60.01
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Application Specific Information:
abort() called
Last Exception Backtrace:
0 CoreFoundation 0x21cb4927c __exceptionPreprocess + 228
1 libobjc.A.dylib 0x21bd239f8 objc_exception_throw + 55
2 CoreFoundation 0x21cac2ce8 _CFThrowFormattedException + 111
3 CoreFoundation 0x21ca34298 -[__NSArrayM removeObjectsInRange:] + 2235
4 SpriteKit 0x233882e3c -[SKSoundSource purgeCompletedBuffers] + 155
5 SpriteKit 0x2338830d4 -[SKSoundSource dealloc] + 47
6 CoreFoundation 0x21caa9ed4 cow_cleanup + 111
7 CoreFoundation 0x21ca334d4 -[__NSArrayM dealloc] + 67
8 SpriteKit 0x233883434 SKCRendererRemoveCompletedSoundSources+ 836660 () + 331
9 SpriteKit 0x2337f12d0 -[SKScene _update:] + 751
10 SpriteKit 0x233816114 -[SKView _update:] + 835
11 SpriteKit 0x2338117f4 __51-[SKView _vsyncRenderForTime:preRender:postRender:]_block_invoke.351 + 387
12 SpriteKit 0x233810bf8 -[SKView _vsyncRenderForTime:preRender:postRender:] + 519
13 SpriteKit 0x233813c54 __29-[SKView setUpRenderCallback]_block_invoke + 207
14 SpriteKit 0x233856c18 -[SKDisplayLink _callbackForNextFrame:] + 163
15 QuartzCore 0x220ed0f90 CA::Display::DisplayLink::dispatch_items+ 69520 (unsigned long long, unsigned long long, unsigned long long) + 635
16 QuartzCore 0x220f9ab10 display_timer_callback+ 895760 (__CFMachPort*, void*, long, void*) + 271
17 CoreFoundation 0x21cab4a8c __CFMachPortPerform + 187
18 CoreFoundation 0x21cadb690 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 55
19 CoreFoundation 0x21cadaddc __CFRunLoopDoSource1 + 439
20 CoreFoundation 0x21cad5c00 __CFRunLoopRun + 2095
21 CoreFoundation 0x21cad50b0 CFRunLoopRunSpecific + 435
22 GraphicsServices 0x21ecd579c GSEventRunModal + 103
23 UIKitCore 0x249341978 UIApplicationMain + 211
24 Pandamonium! 0x100bdd8ec main + 22764 (AppDelegate.swift:19)
25 libdyld.dylib 0x21c59a8e0 start + 3
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 libsystem_kernel.dylib 0x000000021c6e60dc __pthread_kill + 8
1 libsystem_pthread.dylib 0x000000021c7639b0 pthread_kill$VARIANT$armv81 + 296
2 libsystem_c.dylib 0x000000021c63fea8 abort + 140
3 libc++abi.dylib 0x000000021bd0c788 __cxa_bad_cast + 0
4 libc++abi.dylib 0x000000021bd0c934 default_unexpected_handler+ 6452 () + 0
5 libobjc.A.dylib 0x000000021bd23e00 _objc_terminate+ 24064 () + 124
6 libc++abi.dylib 0x000000021bd18838 std::__terminate(void (*)+ 55352 ()) + 16
7 libc++abi.dylib 0x000000021bd18434 __cxa_rethrow + 144
8 libobjc.A.dylib 0x000000021bd23bc8 objc_exception_rethrow + 44
9 CoreFoundation 0x000000021cad511c CFRunLoopRunSpecific + 544
10 GraphicsServices 0x000000021ecd579c GSEventRunModal + 104
11 UIKitCore 0x0000000249341978 UIApplicationMain + 212
12 Pandamonium! 0x0000000100bdd8ec main + 22764 (AppDelegate.swift:19)
13 libdyld.dylib 0x000000021c59a8e0 start + 4
Thread 1 name: com.apple.uikit.eventfetch-thread
Thread 1:
0 libsystem_kernel.dylib 0x000000021c6db0f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x000000021c6da5a0 mach_msg + 72
2 CoreFoundation 0x000000021cadaa10 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x000000021cad5920 __CFRunLoopRun + 1360
4 CoreFoundation 0x000000021cad50b0 CFRunLoopRunSpecific + 436
5 Foundation 0x000000021d4a2fac -[NSRunLoop+ 32684 (NSRunLoop) runMode:beforeDate:] + 300
6 Foundation 0x000000021d4a2e3c -[NSRunLoop+ 32316 (NSRunLoop) runUntilDate:] + 96
7 UIKitCore 0x0000000249427494 -[UIEventFetcher threadMain] + 136
8 Foundation 0x000000021d5cf6a4 __NSThread__start__ + 984
9 libsystem_pthread.dylib 0x000000021c7682c0 _pthread_body + 128
10 libsystem_pthread.dylib 0x000000021c768220 _pthread_start + 44
11 libsystem_pthread.dylib 0x000000021c76bcdc thread_start + 4
Thread 2 name: AVAudioSession Notify Thread
Thread 2:
0 libsystem_kernel.dylib 0x000000021c6db0f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x000000021c6da5a0 mach_msg + 72
2 CoreFoundation 0x000000021cadaa10 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x000000021cad5920 __CFRunLoopRun + 1360
4 CoreFoundation 0x000000021cad50b0 CFRunLoopRunSpecific + 436
5 AVFAudio 0x00000002229bd334 GenericRunLoopThread::Entry+ 574260 (void*) + 156
6 AVFAudio 0x00000002229e7c60 CAPThread::Entry+ 748640 (CAPThread*) + 88
7 libsystem_pthread.dylib 0x000000021c7682c0 _pthread_body + 128
8 libsystem_pthread.dylib 0x000000021c768220 _pthread_start + 44
9 libsystem_pthread.dylib 0x000000021c76bcdc thread_start + 4
Thread 3 name: com.apple.NSURLConnectionLoader
Thread 3:
0 libsystem_kernel.dylib 0x000000021c6db0f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x000000021c6da5a0 mach_msg + 72
2 CoreFoundation 0x000000021cadaa10 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x000000021cad5920 __CFRunLoopRun + 1360
4 CoreFoundation 0x000000021cad50b0 CFRunLoopRunSpecific + 436
5 CFNetwork 0x000000021d0ee74c -[__CoreSchedulingSetRunnable runForever] + 216
6 Foundation 0x000000021d5cf6a4 __NSThread__start__ + 984
7 libsystem_pthread.dylib 0x000000021c7682c0 _pthread_body + 128
8 libsystem_pthread.dylib 0x000000021c768220 _pthread_start + 44
9 libsystem_pthread.dylib 0x000000021c76bcdc thread_start + 4
Thread 4 name: com.apple.coreaudio.AQClient
Thread 4:
0 libsystem_kernel.dylib 0x000000021c6db0f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x000000021c6da5a0 mach_msg + 72
2 CoreFoundation 0x000000021cadaa10 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x000000021cad5920 __CFRunLoopRun + 1360
4 CoreFoundation 0x000000021cad50b0 CFRunLoopRunSpecific + 436
5 AudioToolbox 0x0000000220b527d8 GenericRunLoopThread::Entry+ 2299864 (void*) + 156
6 AudioToolbox 0x0000000220de14f8 CAPThread::Entry+ 4982008 (CAPThread*) + 88
7 libsystem_pthread.dylib 0x000000021c7682c0 _pthread_body + 128
8 libsystem_pthread.dylib 0x000000021c768220 _pthread_start + 44
9 libsystem_pthread.dylib 0x000000021c76bcdc thread_start + 4
Thread 5 name: com.squareup.SocketRocket.NetworkThread
Thread 5:
0 libsystem_kernel.dylib 0x000000021c6db0f4 mach_msg_trap + 8
1 libsystem_kernel.dylib 0x000000021c6da5a0 mach_msg + 72
2 CoreFoundation 0x000000021cadaa10 __CFRunLoopServiceMachPort + 236
3 CoreFoundation 0x000000021cad5920 __CFRunLoopRun + 1360
4 CoreFoundation 0x000000021cad50b0 CFRunLoopRunSpecific + 436
5 Foundation 0x000000021d4a2fac -[NSRunLoop+ 32684 (NSRunLoop) runMode:beforeDate:] + 300
6 Pandamonium! 0x0000000100f08d4c -[_FSRRunLoopThread main] + 3345740 (FSRWebSocket.m:1843)
7 Foundation 0x000000021d5cf6a4 __NSThread__start__ + 984
8 libsystem_pthread.dylib 0x000000021c7682c0 _pthread_body + 128
9 libsystem_pthread.dylib 0x000000021c768220 _pthread_start + 44
10 libsystem_pthread.dylib 0x000000021c76bcdc thread_start + 4
Thread 6 name: com.apple.CFSocket.private
Thread 6:
0 libsystem_kernel.dylib 0x000000021c6e6328 __select + 8
1 CoreFoundation 0x000000021cae36f4 __CFSocketManager + 620
2 libsystem_pthread.dylib 0x000000021c7682c0 _pthread_body + 128
3 libsystem_pthread.dylib 0x000000021c768220 _pthread_start + 44
4 libsystem_pthread.dylib 0x000000021c76bcdc thread_start + 4
Thread 7:
0 libsystem_pthread.dylib 0x000000021c76bcd0 start_wqthread + 0
Thread 8:
0 libsystem_pthread.dylib 0x000000021c76bcd0 start_wqthread + 0
Thread 9:
0 libsystem_pthread.dylib 0x000000021c76bcd0 start_wqthread + 0
Thread 10:
0 libsystem_pthread.dylib 0x000000021c76bcd0 start_wqthread + 0
Related
I am tracking crashes in my app. This particular crash gives me the error "Terminating app due to an uncaught exception 'NSInternalInconsistencyException', reason: 'Only run on the main thread!'". The weird thing is i can't seem to recreate the crash using my device or simulator but in my analytics it shows that this crash happens a lot. I was told this was happening because you can only do UI updates on the main thread so i updated my code but this crash keeps happening and i still can't recreate the crash on my phone or simulator.
This is code where the crash is happening:
indicator.startAnimation()
let audioData = NSData(contentsOfURL: EditSongViewController.url.urlComplete!)
let dataImage: NSData = UIImageJPEGRepresentation(songImage.image!, 1.0)!
let imageFile = PFFile(name: "photo.jpg", data: dataImage)
let audioFile = PFFile(name: "song.mp4", data: audioData)
audioFile.saveInBackground()
imageFile.saveInBackground()
let testObject = PFObject(className: "PrivateSongs")
testObject["songFile"] = audioFile
testObject["image"] = imageFile
testObject["username"] = PFUser.currentUser().username
testObject["user"] = PFUser.currentUser()
testObject["title"] = self.songTitleText.text
testObject["songInfo"] = self.songInfoText.text
if RecordViewController.fileURL.songLyrics != nil {
testObject["lyrics"] = RecordViewController.fileURL.songLyrics
}
if (isPrivate == true) {
testObject["isPrivate"] = true
} else {
testObject["isPrivate"] = false
}
testObject.saveInBackgroundWithBlock ({ (success, error) -> Void in
if (success) {
if self.chartsSwitch.on {
let chart = PFObject(className: "Songs")
chart["artistName"] = PFUser.currentUser().username
chart["songFile"] = audioFile
chart["title"] = self.songTitleText.text
chart["picture"] = imageFile
chart["user"] = PFUser.currentUser()
chart["likes"] = 0
if RecordViewController.fileURL.songLyrics != nil {
chart["lyrics"] = RecordViewController.fileURL.songLyrics
}
chart.saveInBackground()
}
PostViewControler.share.shareUrl = audioFile.url!
dispatch_async(dispatch_get_main_queue(), ^{
/* Your UI code */
self.postButton.hidden = true
self.addPictureButton.hidden = true
self.indicator.stopAnimation(false, completion: nil)
self.navigationController!.pushViewController(self.storyboard!.instantiateViewControllerWithIdentifier("ShareViewController") , animated: true)
});
} else {
dispatch_async(dispatch_get_main_queue(), ^{
/* Your UI code */
self.indicator.stopAnimation(false, completion: nil)
self.helper.showErrorAlert("Couldn't save your song please try again.")
});
}
})
Crash:
Terminating app due to an uncaught exception 'NSInternalInconsistencyException', reason: 'Only run on the main thread!' Error symbolicating crash report.
Last Exception Backtrace
0 CoreFoundation 0x2409068b
1 libobjc.A.dylib 0x3558ee17 objc_exception_throw + 38
2 CoreFoundation 0x24090561 <redacted> + 0
3 Foundation 0x24e1b0e3 <redacted> + 86
4 UIFoundation 0x323d5a6f <redacted> + 398
5 UIFoundation 0x323d57b3 <redacted> + 1510
6 UIFoundation 0x32404989 <redacted> + 724
7 UIFoundation 0x32404a7d <redacted> + 52
8 UIFoundation 0x324277a3 <redacted> + 122
9 UIFoundation 0x32427339 <redacted> + 400
10 UIFoundation 0x32426f2b <redacted> + 78
11 UIKit 0x28203227 <redacted> + 262
12 UIKit 0x28203107 <redacted> + 178
13 meipmusic 0x145e74 meipmusic + 437876
14 meipmusic 0x146e20 meipmusic + 441888
15 meipmusic 0x147144 meipmusic + 442692
16 meipmusic 0x13c994 meipmusic + 399764
17 meipmusic 0x14d760 meipmusic + 468832
18 meipmusic 0x19d810 meipmusic + 796688
19 AVFoundation 0x228625e7 <redacted> + 558
20 libdispatch.dylib 0x35c90d2b <redacted> + 10
21 libdispatch.dylib 0x35c9d92b <redacted> + 1758
22 libdispatch.dylib 0x35c9cf69 <redacted> + 284
23 libdispatch.dylib 0x35c9f665 <redacted> + 396
24 libdispatch.dylib 0x35c9f4d5 <redacted> + 96
25 libsystem_pthread.dylib 0x35e4ab45 _pthread_wqthread + 1024
26 libsystem_pthread.dylib 0x35e4a734 start_wqthread + 8
Crashed Thread 20 :
0 CoreFoundation 0x240909c7
1 libobjc.A.dylib 0x3558f09f
2 libc++abi.dylib 0x34c63e17
3 libc++abi.dylib 0x34c638f9
4 libobjc.A.dylib 0x3558ef5f
5 AVFoundation 0x22862651
6 libdispatch.dylib 0x35c90d2b <redacted> + 10
7 libdispatch.dylib 0x35c9d92b <redacted> + 1758
8 libdispatch.dylib 0x35c9cf69 <redacted> + 284
9 libdispatch.dylib 0x35c9f665 <redacted> + 396
10 libdispatch.dylib 0x35c9f4d5 <redacted> + 96
11 libsystem_pthread.dylib 0x35e4ab45 _pthread_wqthread + 1024
12 libsystem_pthread.dylib 0x35e4a734 start_wqthread + 8
Thread 0 :
0 libsystem_kernel.dylib 0x35d96164
1 CoreFoundation 0x24053905
2 CoreFoundation 0x24051c8d
3 CoreFoundation 0x23fa5249
4 CoreFoundation 0x23fa5035
5 GraphicsServices 0x2d058ad1
6 UIKit 0x281ba899
7 meipmusic 0x1849f0
8 libdyld.dylib 0x35cda873
Thread 1 :
0 libsystem_kernel.dylib 0x35dab3c0
1 libdispatch.dylib 0x35ca4f27
Thread 2 (AXSpeech):
0 libsystem_kernel.dylib 0x35d96164
1 CoreFoundation 0x24053905
2 CoreFoundation 0x24051c8d
3 CoreFoundation 0x23fa5249
4 CoreFoundation 0x23fa5035
5 Foundation 0x24d8f975
6 libAXSpeechManager.dylib 0x34694791
7 Foundation 0x24e60635
8 libsystem_pthread.dylib 0x35e4c873
9 libsystem_pthread.dylib 0x35e4c7e7
10 libsystem_pthread.dylib 0x35e4a740
Thread 3 (AVAudioSession Notify Thread):
0 libsystem_kernel.dylib 0x35d96164
1 CoreFoundation 0x24053905
2 CoreFoundation 0x24051c8d
3 CoreFoundation 0x23fa5249
4 CoreFoundation 0x23fa5035
5 libAVFAudio.dylib 0x2298a16d
6 libAVFAudio.dylib 0x2295ec87
7 libsystem_pthread.dylib 0x35e4c873
8 libsystem_pthread.dylib 0x35e4c7e7
9 libsystem_pthread.dylib 0x35e4a740
Thread 4 :
0 libsystem_kernel.dylib 0x35d96164
1 CoreFoundation 0x24053905
2 CoreFoundation 0x24051c8d
3 CoreFoundation 0x23fa5249
4 CoreFoundation 0x23fa5035
5 Foundation 0x24d8f975
6 Foundation 0x24dde58d
7 libdispatch.dylib 0x35c90d2b <redacted> + 10
8 libdispatch.dylib 0x35c9b535
9 libdispatch.dylib 0x35c9faf1
10 libdispatch.dylib 0x35c9f4d5 <redacted> + 96
11 libsystem_pthread.dylib 0x35e4ab45 _pthread_wqthread + 1024
12 libsystem_pthread.dylib 0x35e4a734 start_wqthread + 8
Thread 5 :
0 libsystem_kernel.dylib 0x35da9a60
1 libsystem_pthread.dylib 0x35e4ccb1
2 Foundation 0x24ddac27
3 meipmusic 0x41b6bb
4 Foundation 0x24e60635
5 libsystem_pthread.dylib 0x35e4c873
6 libsystem_pthread.dylib 0x35e4c7e7
7 libsystem_pthread.dylib 0x35e4a740
Thread 6 (com.apple.NSURLConnectionLoader):
0 libsystem_kernel.dylib 0x35d96164
1 CoreFoundation 0x24053905
2 CoreFoundation 0x24051c8d
3 CoreFoundation 0x23fa5249
4 CoreFoundation 0x23fa5035
5 CFNetwork 0x23917ee7
6 Foundation 0x24e60635
7 libsystem_pthread.dylib 0x35e4c873
8 libsystem_pthread.dylib 0x35e4c7e7
9 libsystem_pthread.dylib 0x35e4a740
Thread 7 (PF_AFNetworking):
0 libsystem_kernel.dylib 0x35d96164
1 CoreFoundation 0x24053905
2 CoreFoundation 0x24051c8d
3 CoreFoundation 0x23fa5249
4 CoreFoundation 0x23fa5035
5 Foundation 0x24d8f975
6 Foundation 0x24dde58d
7 meipmusic 0x4495c3
8 Foundation 0x24e60635
9 libsystem_pthread.dylib 0x35e4c873
10 libsystem_pthread.dylib 0x35e4c7e7
11 libsystem_pthread.dylib 0x35e4a740
Thread 8 (com.apple.CFSocket.private):
0 libsystem_kernel.dylib 0x35da9fb4
1 libsystem_pthread.dylib 0x35e4c873
2 libsystem_pthread.dylib 0x35e4c7e7
3 libsystem_pthread.dylib 0x35e4a740
Thread 9 (WebThread):
0 libsystem_kernel.dylib 0x35d96164
1 CoreFoundation 0x24053905
2 CoreFoundation 0x24051c8d
3 CoreFoundation 0x23fa5249
4 CoreFoundation 0x23fa5035
5 WebCore 0x32e7f287
6 libsystem_pthread.dylib 0x35e4c873
7 libsystem_pthread.dylib 0x35e4c7e7
8 libsystem_pthread.dylib 0x35e4a740
Thread 10 (JavaScriptCore::Marking):
0 libsystem_kernel.dylib 0x35da9a60
1 libsystem_pthread.dylib 0x35e4ccb1
2 libc++.1.dylib 0x34c0786d
3 JavaScriptCore 0x2565c0f5
4 JavaScriptCore 0x2565c15f
5 JavaScriptCore 0x2546dd51
6 JavaScriptCore 0x2546dcaf
7 libsystem_pthread.dylib 0x35e4c873
8 libsystem_pthread.dylib 0x35e4c7e7
9 libsystem_pthread.dylib 0x35e4a740
Thread 11 (WebCore: CFNetwork Loader):
0 libsystem_kernel.dylib 0x35d96164
1 CoreFoundation 0x24053905
2 CoreFoundation 0x24051c8d
3 CoreFoundation 0x23fa5249
4 CoreFoundation 0x23fa5035
5 WebCore 0x32ea308d
6 JavaScriptCore 0x2546dd51
7 JavaScriptCore 0x2546dcaf
8 libsystem_pthread.dylib 0x35e4c873
9 libsystem_pthread.dylib 0x35e4c7e7
10 libsystem_pthread.dylib 0x35e4a740
Thread 12 (AXSpeech):
0 libsystem_kernel.dylib 0x35d96164
1 CoreFoundation 0x24053905
2 CoreFoundation 0x24051c8d
3 CoreFoundation 0x23fa5249
4 CoreFoundation 0x23fa5035
5 Foundation 0x24d8f975
6 libAXSpeechManager.dylib 0x34694791
7 Foundation 0x24e60635
8 libsystem_pthread.dylib 0x35e4c873
9 libsystem_pthread.dylib 0x35e4c7e7
10 libsystem_pthread.dylib 0x35e4a740
Thread 13 :
0 libsystem_kernel.dylib 0x35daa0c4
1 libc++.1.dylib 0x34c468b9
2 JavaScriptCore 0x25819ee3
3 JavaScriptCore 0x25819cab
4 JavaScriptCore 0x2581b807
5 JavaScriptCore 0x2581b7a1
6 libsystem_pthread.dylib 0x35e4c873
7 libsystem_pthread.dylib 0x35e4c7e7
8 libsystem_pthread.dylib 0x35e4a740
Thread 14 (com.apple.coremedia.player.async):
0 libsystem_kernel.dylib 0x35d961b4
1 MediaToolbox 0x25c3479d
2 CoreMedia 0x2485ab41
3 libsystem_pthread.dylib 0x35e4c873
4 libsystem_pthread.dylib 0x35e4c7e7
5 libsystem_pthread.dylib 0x35e4a740
Thread 15 (WebCore: LocalStorage):
0 libsystem_kernel.dylib 0x35da9a60
1 libsystem_pthread.dylib 0x35e4ccb1
2 JavaScriptCore 0x25471577
3 WebKitLegacy 0x33ad8f7d
4 WebKitLegacy 0x33ad889d
5 JavaScriptCore 0x2546dd51
6 JavaScriptCore 0x2546dcaf
7 libsystem_pthread.dylib 0x35e4c873
8 libsystem_pthread.dylib 0x35e4c7e7
9 libsystem_pthread.dylib 0x35e4a740
Thread 16 :
0 libsystem_kernel.dylib 0x35d96164
1 CoreFoundation 0x24053905
2 CoreFoundation 0x24051c8d
3 CoreFoundation 0x23fa5249
4 CoreFoundation 0x23fa5035
5 TTSSpeechBundle 0x3512009
6 libsystem_pthread.dylib 0x35e4c873
7 libsystem_pthread.dylib 0x35e4c7e7
8 libsystem_pthread.dylib 0x35e4a740
Thread 17 (com.apple.coreaudio.AQClient):
0 libsystem_kernel.dylib 0x35d96164
1 CoreFoundation 0x24053905
2 CoreFoundation 0x24051c8d
3 CoreFoundation 0x23fa5249
4 CoreFoundation 0x23fa5035
5 AudioToolbox 0x2342c5ad
6 AudioToolbox 0x2341551f
7 libsystem_pthread.dylib 0x35e4c873
8 libsystem_pthread.dylib 0x35e4c7e7
9 libsystem_pthread.dylib 0x35e4a740
Thread 18 :
0 libsystem_kernel.dylib 0x35daa92c
1 libsystem_pthread.dylib 0x35e4a734 start_wqthread + 8
Thread 19 (com.apple.coremedia.player.async):
0 libsystem_kernel.dylib 0x35d961b4
1 MediaToolbox 0x25c3479d
2 CoreMedia 0x2485ab41
3 libsystem_pthread.dylib 0x35e4c873
4 libsystem_pthread.dylib 0x35e4c7e7
5 libsystem_pthread.dylib 0x35e4a740
Thread 21 :
0 libsystem_kernel.dylib 0x35daa92c
1 libsystem_pthread.dylib 0x35e4a734 start_wqthread + 8
Thread 22 :
0 libsystem_kernel.dylib 0x35daa92c
1 libsystem_pthread.dylib 0x35e4a734 start_wqthread + 8
At a minimum, this is UI code that is definitely running on a background queue:
if self.chartsSwitch.on {
I assume this line is as well:
chart["title"] = self.songTitleText.text
You cannot access UIKit on a background queue. You must collect all this data on the main queue, and pass it to things that run in the background.
I assume this entire block is actually on a background queue (since you load an NSData from an URL which should not be done on the main queue). In that case, this is a mutating UI change on a background queue:
indicator.startAnimation()
I wouldn't be surprised if there is more of this. You have to separate your model code and networking code from your UI code.
I wanted to publish my game app today(using Swift - xCode GTM and Sprite kit framework). My app works fine on the simulator but when I tried it on a real device - iPhone 4 iOS 7, it crashes on start:
class func unarchiveFromFile(file : NSString) -> SKNode? {
let path = NSBundle.mainBundle().pathForResource(file, ofType: "sks")//CRASH!
var sceneData = NSData.dataWithContentsOfFile(path!, options: .DataReadingMappedIfSafe, error: nil)
var archiver = NSKeyedUnarchiver(forReadingWithData: sceneData)
archiver.setClass(self.classForKeyedUnarchiver(), forClassName: "SKScene")
let scene = archiver.decodeObjectForKey(NSKeyedArchiveRootObjectKey) as GameScene
archiver.finishDecoding()
return scene
}
}
here is my Crash log:
Exception Type: EXC_BREAKPOINT (SIGTRAP)
Exception Codes: 0x0000000000000001, 0x000000000000defe
Triggered by Thread: 0
Thread 0 Crashed:
0 libswiftCore.dylib 0x003347d0 0x1b6000 + 1566672
1 libswiftCore.dylib 0x001f3a64 0x1b6000 + 252516
2 MyApp 0x000d2904 0xc4000 + 59652
3 MyApp 0x000d36d8 0xc4000 + 63192
4 MyApp 0x000d4214 0xc4000 + 66068
5 MyApp 0x000d4dc4 0xc4000 + 69060
6 UIKit 0x3079e5fe -[UIViewController loadViewIfRequired] + 514
7 UIKit 0x3079e3bc -[UIViewController view] + 20
8 UIKit 0x307a5088 -[UIWindow addRootViewControllerViewIfPossible] + 60
9 UIKit 0x307a275e -[UIWindow _setHidden:forced:] + 302
10 UIKit 0x3080da50 -[UIWindow makeKeyAndVisible] + 56
11 UIKit 0x3080a80c -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1652
12 UIKit 0x30804d0e -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 710
13 UIKit 0x3079f6a2 -[UIApplication handleEvent:withNewEvent:] + 3126
14 UIKit 0x3079e9a4 -[UIApplication sendEvent:] + 68
15 UIKit 0x308044f8 _UIApplicationHandleEvent + 660
16 GraphicsServices 0x32c3670a _PurpleEventCallback + 606
17 GraphicsServices 0x32c362f2 PurpleEventCallback + 30
18 CoreFoundation 0x2dff39e4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32
19 CoreFoundation 0x2dff397e __CFRunLoopDoSource1 + 342
20 CoreFoundation 0x2dff2152 __CFRunLoopRun + 1394
21 CoreFoundation 0x2df5cce2 CFRunLoopRunSpecific + 518
22 CoreFoundation 0x2df5cac6 CFRunLoopRunInMode + 102
23 UIKit 0x30803794 -[UIApplication _run] + 756
24 UIKit 0x307fea3c UIApplicationMain + 1132
25 MyApp 0x000da594 0xc4000 + 91540
26 MyApp 0x000da5d0 0xc4000 + 91600
27 libdyld.dylib 0x38858ab4 start + 0
Thread 1:
0 libsystem_kernel.dylib 0x388fc83c kevent64 + 24
1 libdispatch.dylib 0x38847e08 _dispatch_mgr_invoke + 228
2 libdispatch.dylib 0x388373ee _dispatch_mgr_thread$VARIANT$up + 34
Thread 2:
0 libsystem_kernel.dylib 0x3890fc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38975dc6 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38975c80 start_wqthread + 4
Thread 3:
0 libsystem_kernel.dylib 0x3890fc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38975dc6 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38975c80 start_wqthread + 4
Thread 4 name: WebThread
Thread 4:
0 libsystem_kernel.dylib 0x3890efa8 __psynch_mutexwait + 24
1 libsystem_pthread.dylib 0x38975f0a _pthread_mutex_lock + 302
2 WebCore 0x35e2f138 _WebTryThreadLock(bool) + 104
3 WebCore 0x35e2f0ba WebRunLoopLock(__CFRunLoopObserver*, unsigned long, void*) + 42
4 CoreFoundation 0x2dff41d2 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
5 CoreFoundation 0x2dff1b74 __CFRunLoopDoObservers + 280
6 CoreFoundation 0x2dff1f84 __CFRunLoopRun + 932
7 CoreFoundation 0x2df5cce2 CFRunLoopRunSpecific + 518
8 CoreFoundation 0x2df5cac6 CFRunLoopRunInMode + 102
9 WebCore 0x35e2dbae RunWebThread(void*) + 414
10 libsystem_pthread.dylib 0x38977c1a _pthread_body + 138
11 libsystem_pthread.dylib 0x38977b8a _pthread_start + 98
12 libsystem_pthread.dylib 0x38975c8c thread_start + 4
Thread 5 name: com.apple.NSURLConnectionLoader
Thread 5:
0 libsystem_kernel.dylib 0x388fca8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x388fc888 mach_msg + 44
2 CoreFoundation 0x2dff37c6 __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x2dff1eec __CFRunLoopRun + 780
4 CoreFoundation 0x2df5cce2 CFRunLoopRunSpecific + 518
5 CoreFoundation 0x2df5cac6 CFRunLoopRunInMode + 102
6 Foundation 0x2e996492 +[NSURLConnection(Loader) _resourceLoadLoop:] + 314
7 Foundation 0x2ea0be22 __NSThread__main__ + 1058
8 libsystem_pthread.dylib 0x38977c1a _pthread_body + 138
9 libsystem_pthread.dylib 0x38977b8a _pthread_start + 98
10 libsystem_pthread.dylib 0x38975c8c thread_start + 4
Thread 6:
0 libsystem_kernel.dylib 0x388fca8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x388fc888 mach_msg + 44
2 CoreFoundation 0x2dff37c6 __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x2dff1eec __CFRunLoopRun + 780
4 CoreFoundation 0x2df5cce2 CFRunLoopRunSpecific + 518
5 CoreFoundation 0x2df5cac6 CFRunLoopRunInMode + 102
6 libAVFAudio.dylib 0x2cfe1584 GenericRunLoopThread::Entry(void*) + 124
7 libAVFAudio.dylib 0x2cfd5a94 CAPThread::Entry(CAPThread*) + 176
8 libsystem_pthread.dylib 0x38977c1a _pthread_body + 138
9 libsystem_pthread.dylib 0x38977b8a _pthread_start + 98
10 libsystem_pthread.dylib 0x38975c8c thread_start + 4
Thread 7:
0 libsystem_kernel.dylib 0x3890fc7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x38975dc6 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x38975c80 start_wqthread + 4
Thread 8 name: JavaScriptCore::BlockFree
Thread 8:
0 libsystem_kernel.dylib 0x3890ef38 __psynch_cvwait + 24
1 libsystem_pthread.dylib 0x38977224 _pthread_cond_wait + 536
2 libsystem_pthread.dylib 0x38978040 pthread_cond_timedwait + 40
3 JavaScriptCore 0x2ef80eb8 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 104
4 JavaScriptCore 0x2ef80ce4 JSC::BlockAllocator::blockFreeingThreadMain() + 88
5 JavaScriptCore 0x2ef7e3a8 WTF::wtfThreadEntryPoint(void*) + 12
6 libsystem_pthread.dylib 0x38977c1a _pthread_body + 138
7 libsystem_pthread.dylib 0x38977b8a _pthread_start + 98
8 libsystem_pthread.dylib 0x38975c8c thread_start + 4
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0x00000000 r1: 0x00000000 r2: 0x00362ac4 r3: 0x000000b6
r4: 0x00362ac4 r5: 0x00000000 r6: 0x145c97b0 r7: 0x27d3d364
r8: 0x1456eb50 r9: 0x00000fff r10: 0x145c97b0 r11: 0x00362ac0
ip: 0x3a5431d0 sp: 0x27d3d354 lr: 0x00334183 pc: 0x003347d0
cpsr: 0x60000030
The pathForResource() function returns a String?, indicating that (because it's an optional) there's a chance no value will be returned. I'm guessing the method is returning nil, but because you're assigning it using a let statement, the app is crashing.
I'm a little surprised it's crashing directly on that line though. You should be able to assign nil using the let keyword. In any case, if the value is nil, you'd definitely encounter a crash on your next line when you force unwrap the optional:
var sceneData = NSData.dataWithContentsOfFile(path!, options: .DataReadingMappedIfSafe, error: nil)
^ here
Try this:
if let path = NSBundle.mainBundle().pathForResource(file, ofType: "sks") {
/* ... (your code using path) ... */
} else {
NSLog("Unable to locate path for resource: \(file)")
}
I have a feeling you'll see that NSLog() output at launch.
I relaunches the ios app from bacground to foreground - iphone restarts and says backbaordd crash
Please find the below crash logs for your reference
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0x0000000000000001
Triggered by Thread: 5
Thread 0:
0 libsystem_kernel.dylib 0x0000000192a7dca0 mach_msg_trap + 8
1 CoreFoundation 0x0000000185e5ed20 __CFRunLoopServiceMachPort + 180
2 CoreFoundation 0x0000000185e5cf14 __CFRunLoopRun + 932
3 CoreFoundation 0x0000000185d9ddcc CFRunLoopRunSpecific + 448
4 backboardd 0x00000001000e7a60 0x1000e0000 + 31328
5 libdyld.dylib 0x000000019299ba9c start + 0
Thread 1:
0 libsystem_kernel.dylib 0x0000000192a7daa8 kevent64 + 8
1 libdispatch.dylib 0x0000000192981998 _dispatch_mgr_thread + 48
Thread 2 name: com.apple.CoreAnimation.render-server
Thread 2:
0 libsystem_kernel.dylib 0x0000000192a7dca0 mach_msg_trap + 8
1 QuartzCore 0x0000000188b02a18 CA::Render::Server::server_thread(void*) + 236
2 QuartzCore 0x0000000188b9422c thread_fun + 24
3 libsystem_pthread.dylib 0x0000000192b17e18 _pthread_body + 164
4 libsystem_pthread.dylib 0x0000000192b17d70 _pthread_start + 136
5 libsystem_pthread.dylib 0x0000000192b15550 thread_start + 0
Thread 3:
0 libsystem_kernel.dylib 0x0000000192a7dca0 mach_msg_trap + 8
1 CoreFoundation 0x0000000185e5ed20 __CFRunLoopServiceMachPort + 180
2 CoreFoundation 0x0000000185e5ceb0 __CFRunLoopRun + 832
3 CoreFoundation 0x0000000185d9ddcc CFRunLoopRunSpecific + 448
4 CoreFoundation 0x0000000185df3454 CFRunLoopRun + 108
5 IOMobileFramebuffer 0x000000018bf3e484 iomfb_runloop_thread + 312
6 libsystem_pthread.dylib 0x0000000192b17e18 _pthread_body + 164
7 libsystem_pthread.dylib 0x0000000192b17d70 _pthread_start + 136
8 libsystem_pthread.dylib 0x0000000192b15550 thread_start + 0
Thread 4 name: com.apple.CoreAnimation.IOMFB.wireless
Thread 4:
0 libsystem_kernel.dylib 0x0000000192a7dca0 mach_msg_trap + 8
1 CoreFoundation 0x0000000185e5ed20 __CFRunLoopServiceMachPort + 180
2 CoreFoundation 0x0000000185e5ceb0 __CFRunLoopRun + 832
3 CoreFoundation 0x0000000185d9ddcc CFRunLoopRunSpecific + 448
4 CoreFoundation 0x0000000185df3454 CFRunLoopRun + 108
5 QuartzCore 0x0000000188b58a20 CA::WindowServer::IOMFBServer::thread_body(void*) + 344
6 QuartzCore 0x0000000188b9422c thread_fun + 24
7 libsystem_pthread.dylib 0x0000000192b17e18 _pthread_body + 164
8 libsystem_pthread.dylib 0x0000000192b17d70 _pthread_start + 136
9 libsystem_pthread.dylib 0x0000000192b15550 thread_start + 0
Thread 5 name: com.apple.CoreAnimation.IOMFB.primary
Thread 5 Crashed:
0 libGPUSupportMercury.dylib 0x000000018b658694 gpus_ReturnContextErrorKillClient + 12
1 AGXGLDriver 0x0000000184a77248 SubmitPackets + 196
2 AGXGLDriver 0x0000000184a6c3a0 glrSetPrivateInteger + 284
3 GLEngine 0x000000018870427c gliSetInteger + 4592
4 OpenGLES 0x00000001887f11e8 -[EAGLContext swapNotification:forTransaction:onLayer:] + 152
5 QuartzCore 0x0000000188b562c0 CA::WindowServer::IOMFBDisplay::finish_update(CA::Render::Update*, unsigned int) + 1348
6 QuartzCore 0x0000000188b5c0a8 CA::WindowServer::Server::render_for_time(double, CVTimeStamp const*) + 1536
7 QuartzCore 0x0000000188b58bf4 CA::WindowServer::IOMFBServer::vsync_callback(__IOMobileFramebuffer*, unsigned long long, unsigned long long, unsigned long long, void*) + 220
8 IOKit 0x0000000186d9fe70 IODispatchCalloutFromCFMessage + 360
9 CoreFoundation 0x0000000185e50a8c __CFMachPortPerform + 188
10 CoreFoundation 0x0000000185e5f03c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
11 CoreFoundation 0x0000000185e5ef9c __CFRunLoopDoSource1 + 440
12 CoreFoundation 0x0000000185e5d1c0 __CFRunLoopRun + 1616
13 CoreFoundation 0x0000000185d9ddcc CFRunLoopRunSpecific + 448
14 CoreFoundation 0x0000000185df3454 CFRunLoopRun + 108
15 QuartzCore 0x0000000188b58a20 CA::WindowServer::IOMFBServer::thread_body(void*) + 344
16 QuartzCore 0x0000000188b9422c thread_fun + 24
17 libsystem_pthread.dylib 0x0000000192b17e18 _pthread_body + 164
18 libsystem_pthread.dylib 0x0000000192b17d70 _pthread_start + 136
19 libsystem_pthread.dylib 0x0000000192b15550 thread_start + 0
Thread 6 name: IOHIDService - RunLoopCompatibilityThread
Thread 6:
0 libsystem_kernel.dylib 0x0000000192a7dca0 mach_msg_trap + 8
1 CoreFoundation 0x0000000185e5ed20 __CFRunLoopServiceMachPort + 180
2 CoreFoundation 0x0000000185e5ceb0 __CFRunLoopRun + 832
3 CoreFoundation 0x0000000185d9ddcc CFRunLoopRunSpecific + 448
4 CoreFoundation 0x0000000185df3454 CFRunLoopRun + 108
5 IOKit 0x0000000186dc23bc __IOHIDServiceRunLoopCompatibilityThread + 184
6 libsystem_pthread.dylib 0x0000000192b17e18 _pthread_body + 164
7 libsystem_pthread.dylib 0x0000000192b17d70 _pthread_start + 136
8 libsystem_pthread.dylib 0x0000000192b15550 thread_start + 0
Totally what causes this issue and also kindly suggest me how to debug this issue..
Your app gets terminated by the ios for any one of the reason below,
High memory usage or the springboard crashes( springboard is application that manages the other applications like home screen, app icon etc).
Testing your application in jail broken devices.
Try to pause your animation stuff while resigning the application and resume them while user entering back to the application. Something like this,
- (void)applicationWillResignActive:(UIApplication *)application
{
// pause sprite kit
SKView *view = (SKView *)self.window.rootViewController.view;
view.paused = YES;
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// resume sprite kit
SKView *view = (SKView *)self.window.rootViewController.view;
view.paused = NO;
}
Do you use OpenGL? Or some kind of framework, that works with camera.
Rendering surfaces is forbidden in background.
Try to handle background/foreground state changes to pause/resume rendering.
You can user UIApplicationDidEnterBackgroundNotification and UIApplicationWillEnterForegroundNotification for this.
I am getting weird crash in my application running in iOS 7 but in iOS 6 app is working fine. I am performing some operations. After 5-6 operations are completed I am experiencing this crash. This number can go till 20 also or 1 also. Attaching crash log with this.
Incident Identifier: 6702CA20-9832-4305-B723-588C6B33C199
CrashReporter Key: 0370a1a51d424d34102c66389c6b00b12585aa57
Hardware Model: iPad2,5
Process: mobile [2958]
Path:
Identifier:
Version: 2.0.0.401
Code Type: ARM (Native)
Parent Process: launchd [1]
Date/Time: 2014-06-02 13:35:50.243 +0530
OS Version: iOS 7.0.6 (11B651)
Report Version: 104
Exception Type: EXC_BAD_ACCESS (SIGSEGV)
Exception Subtype: KERN_INVALID_ADDRESS at 0xef264ee9
Triggered by Thread: 0
Thread 0 Crashed:
0 libobjc.A.dylib 0x3af9eb22 objc_msgSend + 2
1 UIFoundation 0x38384d5e -[NSParagraphStyle _deallocExtraData] + 54
2 UIFoundation 0x383858ca -[NSParagraphStyle dealloc] + 22
3 CoreFoundation 0x3073d650 CFRelease + 552
4 CoreFoundation 0x30749a1e -[__NSDictionaryM dealloc] + 130
5 libobjc.A.dylib 0x3afaeb06 objc_object::sidetable_release(bool) + 170
6 UIKit 0x3304be68 -[UILabel dealloc] + 116
7 UIKit 0x32f80402 -[UIView dealloc] + 362
8 UIKit 0x3305223a -[UIScrollView dealloc] + 830
9 UIKit 0x33051cb4 -[UIScrollView removeFromSuperview] + 60
10 UIKit 0x32f80402 -[UIView dealloc] + 362
11 UIKit 0x33199088 -[_UIModalItemContentView dealloc] + 116
12 UIKit 0x3323d432 -[_UIModalItemAlertContentView dealloc] + 70
13 libobjc.A.dylib 0x3afa0002 (anonymous namespace)::AutoreleasePoolPage::pop(void*) + 354
14 CoreFoundation 0x3074097c _CFAutoreleasePoolPop + 12
15 CoreFoundation 0x307d80dc __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 12
16 CoreFoundation 0x307d7cf2 __CFRunLoopDoTimer + 778
17 CoreFoundation 0x307d608e __CFRunLoopRun + 1206
18 CoreFoundation 0x30740c22 CFRunLoopRunSpecific + 518
19 CoreFoundation 0x30740a06 CFRunLoopRunInMode + 102
20 GraphicsServices 0x3543427e GSEventRunModal + 134
21 UIKit 0x32fe4044 UIApplicationMain + 1132
22 mobile 0x0005d2c2 main (main.m:15)
23 libdyld.dylib 0x3b4abab4 start + 0
Thread 1:
0 libsystem_kernel.dylib 0x3b54f83c kevent64 + 24
1 libdispatch.dylib 0x3b490210 _dispatch_mgr_invoke + 228
2 libdispatch.dylib 0x3b48ff96 _dispatch_mgr_thread$VARIANT$mp + 34
Thread 2 name: WebThread
Thread 2:
0 libsystem_kernel.dylib 0x3b54fa8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3b54f888 mach_msg + 44
2 CoreFoundation 0x307d77be __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x307d5ee4 __CFRunLoopRun + 780
4 CoreFoundation 0x30740c22 CFRunLoopRunSpecific + 518
5 CoreFoundation 0x30740a06 CFRunLoopRunInMode + 102
6 WebCore 0x3894e266 RunWebThread(void*) + 414
7 libsystem_pthread.dylib 0x3b5cac1a _pthread_body + 138
8 libsystem_pthread.dylib 0x3b5cab8a _pthread_start + 98
9 libsystem_pthread.dylib 0x3b5c8c8c thread_start + 4
Thread 3:
0 libsystem_kernel.dylib 0x3b54fa8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3b54f888 mach_msg + 44
2 CoreFoundation 0x307d77be __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x307d5ee4 __CFRunLoopRun + 780
4 CoreFoundation 0x30740c22 CFRunLoopRunSpecific + 518
5 CoreFoundation 0x30740a06 CFRunLoopRunInMode + 102
6 libAVFAudio.dylib 0x2f7c3584 GenericRunLoopThread::Entry(void*) + 124
7 libAVFAudio.dylib 0x2f7b799c CAPThread::Entry(CAPThread*) + 176
8 libsystem_pthread.dylib 0x3b5cac1a _pthread_body + 138
9 libsystem_pthread.dylib 0x3b5cab8a _pthread_start + 98
10 libsystem_pthread.dylib 0x3b5c8c8c thread_start + 4
Thread 4 name: com.apple.CFSocket.private
Thread 4:
0 libsystem_kernel.dylib 0x3b562440 __select + 20
1 CoreFoundation 0x307db680 __CFSocketManager + 480
2 libsystem_pthread.dylib 0x3b5cac1a _pthread_body + 138
3 libsystem_pthread.dylib 0x3b5cab8a _pthread_start + 98
4 libsystem_pthread.dylib 0x3b5c8c8c thread_start + 4
Thread 5 name: GCDAsyncSocket-CFStream
Thread 5:
0 libsystem_kernel.dylib 0x3b54fa8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3b54f888 mach_msg + 44
2 CoreFoundation 0x307d77be __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x307d5ee4 __CFRunLoopRun + 780
4 CoreFoundation 0x30740c22 CFRunLoopRunSpecific + 518
5 CoreFoundation 0x30740a06 CFRunLoopRunInMode + 102
6 Foundation 0x3112e3d6 -[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250
7 Foundation 0x3117f30c -[NSRunLoop(NSRunLoop) run] + 76
8 mobile 0x000f6228 +[GCDAsyncSocket cfstreamThread] (GCDAsyncSocket.m:6741)
9 Foundation 0x311f0c82 __NSThread__main__ + 1058
10 libsystem_pthread.dylib 0x3b5cac1a _pthread_body + 138
11 libsystem_pthread.dylib 0x3b5cab8a _pthread_start + 98
12 libsystem_pthread.dylib 0x3b5c8c8c thread_start + 4
Thread 6 name: com.apple.NSURLConnectionLoader
Thread 6:
0 libsystem_kernel.dylib 0x3b54fa8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3b54f888 mach_msg + 44
2 CoreFoundation 0x307d77be __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x307d5ee4 __CFRunLoopRun + 780
4 CoreFoundation 0x30740c22 CFRunLoopRunSpecific + 518
5 CoreFoundation 0x30740a06 CFRunLoopRunInMode + 102
6 Foundation 0x3117b2f2 +[NSURLConnection(Loader) _resourceLoadLoop:] + 314
7 Foundation 0x311f0c82 __NSThread__main__ + 1058
8 libsystem_pthread.dylib 0x3b5cac1a _pthread_body + 138
9 libsystem_pthread.dylib 0x3b5cab8a _pthread_start + 98
10 libsystem_pthread.dylib 0x3b5c8c8c thread_start + 4
Thread 7:
0 libsystem_kernel.dylib 0x3b54fa8c mach_msg_trap + 20
1 libsystem_kernel.dylib 0x3b54f888 mach_msg + 44
2 CoreFoundation 0x307d77be __CFRunLoopServiceMachPort + 150
3 CoreFoundation 0x307d5ee4 __CFRunLoopRun + 780
4 CoreFoundation 0x30740c22 CFRunLoopRunSpecific + 518
5 CoreFoundation 0x30784736 CFRunLoopRun + 94
6 CoreMotion 0x30df7230 ___lldb_unnamed_function1404$$CoreMotion + 724
7 libsystem_pthread.dylib 0x3b5cac1a _pthread_body + 138
8 libsystem_pthread.dylib 0x3b5cab8a _pthread_start + 98
9 libsystem_pthread.dylib 0x3b5c8c8c thread_start + 4
Thread 8:
0 libsystem_kernel.dylib 0x3b562c7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3b5c8dc6 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x3b5c8c80 start_wqthread + 4
Thread 9:
0 libsystem_kernel.dylib 0x3b562c7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3b5c8dc6 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x3b5c8c80 start_wqthread + 4
Thread 10:
0 libsystem_kernel.dylib 0x3b562c7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3b5c8dc6 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x3b5c8c80 start_wqthread + 4
Thread 11:
0 libsystem_kernel.dylib 0x3b562440 __select + 20
1 ExternalAccessory 0x31119352 -[EAInputStream _readInputFromAccThread] + 342
2 Foundation 0x311f0c82 __NSThread__main__ + 1058
3 libsystem_pthread.dylib 0x3b5cac1a _pthread_body + 138
4 libsystem_pthread.dylib 0x3b5cab8a _pthread_start + 98
5 libsystem_pthread.dylib 0x3b5c8c8c thread_start + 4
Thread 12:
0 libsystem_kernel.dylib 0x3b562c7c __workq_kernreturn + 8
1 libsystem_pthread.dylib 0x3b5c8dc6 _pthread_wqthread + 306
2 libsystem_pthread.dylib 0x3b5c8c80 start_wqthread + 4
Thread 0 crashed with ARM Thread State (32-bit):
r0: 0xef264ee9 r1: 0x33566b29 r2: 0x3cf673f0 r3: 0x00000001
r4: 0x160815a0 r5: 0x33566b29 r6: 0x0000002c r7: 0x27dc88ac
r8: 0x160815a4 r9: 0x158af438 r10: 0x14e8846c r11: 0x14e88430
ip: 0x3cf59864 sp: 0x27dc88a0 lr: 0x38384d63 pc: 0x3af9eb22
cpsr: 0x20000030
Your app crashes while a UILabel inside a UIScrollView inside an alert is deallocated. I'd suspect that either your app overwrites memory somewhere and this is just a symptom, or you are using some alert in a non-standard way, possibly changing a paragraph style somewhere in the alert in a way that's wrong.
First step would be to turn all reasonable warnings on in the compiler, use the static analyser to find problems, and fix all of them.
I couldn't understand where is my problem. My apps crash on launch with this crash log.
iOS 7.0.2 (11A501) Report Version: 104
Exception Type: 00000020 Exception Codes: 0x000000008badf00d
Highlighted Thread: 0
Application Specific Information: com.myapps failed
to launch in time
Elapsed total CPU time (seconds): 4.420 (user 4.420, system 0.000),
10% CPU Elapsed application CPU time (seconds): 0.714, 2% CPU
Thread 0: 0 libsystem_kernel.dylib 0x3878ead4
semaphore_wait_trap + 8 1 libdispatch.dylib 0x386dbdec
_dispatch_semaphore_wait_slow + 172 2 CFNetwork 0x2dabab16 CFURLConnectionSendSynchronousRequest + 266 3 Foundation
0x2e883a4e +[NSURLConnection
sendSynchronousRequest:returningResponse:error:] + 110 4 Foundation
0x2e8d8c80 -[NSString initWithContentsOfURL:encoding:error:] + 188 5
QuizPatente! 0x0004d980 0x3e000 + 63872 6
QuizPatente! 0x00048820 0x3e000 + 43040 7
QuizPatente! 0x00048644 0x3e000 + 42564 8 UIKit
0x306fc020 -[UIApplication _stopDeactivatingForReason:] + 376 9
UIKit 0x306e762c -[UIApplication
_runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 1092 10 UIKit 0x30681be2 -[UIApplication handleEvent:withNewEvent:] + 3138 11 UIKit
0x30680ed8 -[UIApplication sendEvent:] + 68 12 UIKit
0x306e6c9c _UIApplicationHandleEvent + 660 13 GraphicsServices
0x32b6276a _PurpleEventCallback + 606 14 GraphicsServices
0x32b62352 PurpleEventCallback + 30 15 CoreFoundation
0x2dec177c CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION
+ 32 16 CoreFoundation 0x2dec1716 __CFRunLoopDoSource1 + 342 17 CoreFoundation 0x2debfee2 __CFRunLoopRun + 1402 18 CoreFoundation
0x2de2a53c CFRunLoopRunSpecific + 520 19 CoreFoundation
0x2de2a31e CFRunLoopRunInMode + 102 20 UIKit
0x306e5f3e -[UIApplication _run] + 758 21 UIKit
0x306e11e0 UIApplicationMain + 1132 22 QuizPatente!
0x00045a28 0x3e000 + 31272 23 libdyld.dylib
0x386eaab4 start + 0
Thread 1: 0 libsystem_kernel.dylib 0x3878e838 kevent64 + 24
1 libdispatch.dylib 0x386dd0d0 _dispatch_mgr_invoke +
228 2 libdispatch.dylib 0x386d763e _dispatch_mgr_thread
+ 34
Thread 2: 0 libsystem_kernel.dylib 0x3878ead4
semaphore_wait_trap + 8 1 libdispatch.dylib 0x386dbf90
_dispatch_group_wait_slow + 168 2 GameCenterFoundation 0x2ea86dc4 __35-[GKDaemonProxy buildServiceLookup]_block_invoke + 628
3 libdispatch.dylib 0x386d6100
_dispatch_call_block_and_release + 8 4 libdispatch.dylib 0x386dae72 _dispatch_queue_drain + 370 5 libdispatch.dylib
0x386d7f96 _dispatch_queue_invoke + 38 6 libdispatch.dylib
0x386db74e _dispatch_root_queue_drain + 74 7 libdispatch.dylib
0x386db9cc _dispatch_worker_thread2 + 52 8 libsystem_pthread.dylib
0x38805dfc _pthread_wqthread + 296 9 libsystem_pthread.dylib
0x38805cc0 start_wqthread + 4
Thread 3: 0 libsystem_kernel.dylib 0x387a1c7c
__workq_kernreturn + 8 1 libsystem_pthread.dylib 0x38805e06 _pthread_wqthread + 306 2 libsystem_pthread.dylib 0x38805cc0 start_wqthread + 4
Thread 4: 0 libsystem_kernel.dylib 0x387a1c7c
__workq_kernreturn + 8 1 libsystem_pthread.dylib 0x38805e06 _pthread_wqthread + 306 2 libsystem_pthread.dylib 0x38805cc0 start_wqthread + 4
Thread 5: 0 libsystem_kernel.dylib 0x387a0f38
psynch_cvwait + 24 1 libsystem_pthread.dylib 0x38807262 _pthread_cond_wait + 538 2 libsystem_pthread.dylib 0x3880803c pthread_cond_wait + 36 3 Foundation 0x2e86574a
-[NSCondition wait] + 190 4 QuizPatente! 0x0026c5b0 0x3e000 + 2287024 5 Foundation
0x2e8dadc2 _NSThread_main + 1058 6 libsystem_pthread.dylib
0x38807c5a _pthread_body + 138 7 libsystem_pthread.dylib
0x38807bca _pthread_start + 98 8 libsystem_pthread.dylib
0x38805ccc thread_start + 4
Thread 6: 0 libsystem_kernel.dylib 0x3878ea84 mach_msg_trap
+ 20 1 libsystem_kernel.dylib 0x3878e87c mach_msg + 36 2 CoreFoundation 0x2dec155c CFRunLoopServiceMachPort +
152 3 CoreFoundation 0x2debfc7c __CFRunLoopRun + 788
4 CoreFoundation 0x2de2a53c CFRunLoopRunSpecific +
520 5 CoreFoundation 0x2de6e1a6 CFRunLoopRun + 94 6
QuizPatente! 0x001ec3b4 0x3e000 + 1762228 7
Foundation 0x2e8dadc2 _NSThread_main + 1058 8
libsystem_pthread.dylib 0x38807c5a _pthread_body + 138 9
libsystem_pthread.dylib 0x38807bca _pthread_start + 98 10
libsystem_pthread.dylib 0x38805ccc thread_start + 4
Thread 7 name: com.apple.NSURLConnectionLoader Thread 7: 0
libsystem_kernel.dylib 0x3878ea84 mach_msg_trap + 20 1
libsystem_kernel.dylib 0x3878e87c mach_msg + 36 2
CoreFoundation 0x2dec155c CFRunLoopServiceMachPort +
152 3 CoreFoundation 0x2debfc7c __CFRunLoopRun + 788
4 CoreFoundation 0x2de2a53c CFRunLoopRunSpecific +
520 5 CoreFoundation 0x2de2a31e CFRunLoopRunInMode +
102 6 Foundation 0x2e86564c
+[NSURLConnection(Loader) _resourceLoadLoop:] + 316 7 Foundation 0x2e8dadc2 _NSThread_main + 1058 8 libsystem_pthread.dylib
0x38807c5a _pthread_body + 138 9 libsystem_pthread.dylib
0x38807bca _pthread_start + 98 10 libsystem_pthread.dylib
0x38805ccc thread_start + 4
Thread 8: 0 libsystem_kernel.dylib 0x3878ea84 mach_msg_trap
+ 20 1 libsystem_kernel.dylib 0x3878e87c mach_msg + 36 2 CoreFoundation 0x2dec155c CFRunLoopServiceMachPort +
152 3 CoreFoundation 0x2debfc7c __CFRunLoopRun + 788
4 CoreFoundation 0x2de2a53c CFRunLoopRunSpecific +
520 5 CoreFoundation 0x2de2a31e CFRunLoopRunInMode +
102 6 Foundation 0x2e818822
-[NSRunLoop(NSRunLoop) runMode:beforeDate:] + 250 7 Foundation 0x2e869664 -[NSRunLoop(NSRunLoop) run] + 76 8 QuizPatente!
0x000e9fd4 0x3e000 + 704468 9 Foundation
0x2e8dadc2 _NSThread_main + 1058 10 libsystem_pthread.dylib
0x38807c5a _pthread_body + 138 11 libsystem_pthread.dylib
0x38807bca _pthread_start + 98 12 libsystem_pthread.dylib
0x38805ccc thread_start + 4
Thread 9: 0 libsystem_kernel.dylib 0x3878ea84 mach_msg_trap
+ 20 1 libsystem_kernel.dylib 0x3878e87c mach_msg + 36 2 CoreFoundation 0x2dec155c __CFRunLoopServiceMachPort +
152 3 CoreFoundation 0x2debfc7c _CFRunLoopRun + 788
4 CoreFoundation 0x2de2a53c CFRunLoopRunSpecific +
520 5 CoreFoundation 0x2de6e1a6 CFRunLoopRun + 94 6
CoreMotion 0x2e4e2394
__lldb_unnamed_function1407$$CoreMotion + 724 7 libsystem_pthread.dylib 0x38807c5a _pthread_body + 138 8
libsystem_pthread.dylib 0x38807bca _pthread_start + 98 9
libsystem_pthread.dylib 0x38805ccc thread_start + 4
I update my app today. The strange behavior has come only when the app is updated. If users reinstall the app it work fine.
Based on:
Application Specific Information: com.myapps failed to launch in time
Elapsed total CPU time (seconds): 4.420 (user 4.420, system 0.000),
10% CPU Elapsed application CPU time (seconds): 0.714, 2% CPU
it looks like your app is not returning from application:didFinishLaunchingWithOptions: in time.
You are probably doing something in that method that is blocking the thread and preventing it from returning.