0

I am getting these crash reports from crashlytics for my iOS app. The crash happens sometimes and not always so it is hard to reproduce.

    Thread : Fatal Exception: NSInvalidArgumentException
    0  CoreFoundation                 0x2b57d137 __exceptionPreprocess
    1  libobjc.A.dylib                0x398d3c77 objc_exception_throw
    2  CoreFoundation                 0x2b57d07d -[NSException initWithCoder:]
    3  SpriteKit                      0x2eaadc6f +[SKPlaySound playSoundFileNamed:atPosition:waitForCompletion:]
    4  SpriteKit                      0x2ea47f17 +[SKAction(SKActions) playSoundFileNamed:waitForCompletion:]
    5  my_project                     0x00150ef0 function signature specialization  of my_project.GameScene.CreateScene (my_project.GameScene)() -> () (GameScene.swift:125)
    6  my_project                     0x00142a10 my_project.GameScene.CreateScene (my_project.GameScene)() -> () (GameScene.swift)
    7  my_project                     0x00150e24 function signature specialization  of my_project.GameScene.init (my_project.GameScene.Type)(size : C.CGSize) -> my_project.GameScene (GameScene.swift:120)
    8  my_project                     0x00182b30 function signature specialization  of my_project.GameViewController.viewDidLoad (my_project.GameViewController)() -> () (GameViewController.swift:48)
    9  my_project                     0x0017ec78 @objc my_project.GameViewController.viewDidLoad (my_project.GameViewController)() -> () (GameViewController.swift)
    10 UIKit                          0x2ebdd74d -[UIViewController loadViewIfRequired]
    11 UIKit                          0x2ebdd4bd -[UIViewController view]
    12 UIKit                          0x2ebe35e7 -[UIWindow addRootViewControllerViewIfPossible]
    13 UIKit                          0x2ebe0f5f -[UIWindow _setHidden:forced:]
    14 UIKit                          0x2ec4c081 -[UIWindow makeKeyAndVisible]
    15 UIKit                          0x2ee3f507 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:]
    16 UIKit                          0x2ee41acf -[UIApplication _runWithMainScene:transitionContext:completion:]
    17 UIKit                          0x2ee4c7a9 __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke
    18 UIKit                          0x2ee40287 -[UIApplication workspaceDidEndTransaction:]
    19 FrontBoardServices             0x32028ec1 __31-[FBSSerialQueue performAsync:]_block_invoke_2
    20 CoreFoundation                 0x2b543255 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__
    21 CoreFoundation                 0x2b542519 __CFRunLoopDoBlocks
    22 CoreFoundation                 0x2b541073 __CFRunLoopRun
    23 CoreFoundation                 0x2b48c9a1 CFRunLoopRunSpecific
    24 CoreFoundation                 0x2b48c7b3 CFRunLoopRunInMode
    25 UIKit                          0x2ec42a57 -[UIApplication _run]
    26 UIKit                          0x2ec3d635 UIApplicationMain
    27 my_project                     0x00187db8 main (AppDelegate.swift:14)
    28 libdyld.dylib                  0x39ea1aaf start.my_project

Here is the code on how I am using SKAction to load and play the sound

var jump_Sound:SKAction?
func jumpSound(){
        self.runAction(jump_Sound)
//        runAction(SKAction.playSoundFileNamed("jump.mp3", waitForCompletion: false))
    }

override init(size: CGSize) {
        super.init(size: size)
        self.CreateScene()
}

func CreateScene(){
    jump_Sound = SKAction.playSoundFileNamed("jump.caf", waitForCompletion: false)
}

Currently game is crashing at CreateScene function where I am loading jump_sound. Please suggest me if there is a better way to play sound effects in SpriteKit project.

Rohit Goyal
  • 1,521
  • 3
  • 24
  • 49
  • did you started `AVAudioSession`? or jump.caf is working or not? please check – Ashish Kakkad Aug 17 '15 at 10:29
  • @AshishKakkad No AVAudioSession as such. jump.caf works though sometime times there is a freeze moment when it plays for the first time but after that it works perfectly. The crash happens sometimes. – Rohit Goyal Aug 17 '15 at 11:03
  • Please check this question : http://stackoverflow.com/questions/18976813/sprite-kit-playing-sound-leads-to-app-termination – Ashish Kakkad Aug 17 '15 at 11:08
  • @AshishKakkad Thanks a lot for that. Are you sure this might resolve the "resource can not be loaded" issue? As I told you I am not able to reproduce the issue just not sure whether the issue is fixed or not. Added your suggested code though and looks sensible to me. :) – Rohit Goyal Aug 17 '15 at 11:28
  • @iAshish It didn't solve my issue. I am still getting the same crash reports. – Rohit Goyal Aug 31 '15 at 14:08

0 Answers0