Unsupported Texture Atlas Format Exception

The game is fine as play, but sometimes will crash and exit the game.

the shoot.mp3 cannot be found suddenly. I don't know what's happing.

Please help. Thanks.



The following is the full expection:


2017-05-31 14:31:06.864732+0800 Cloud War[4771:1325039] SKAction: Error loading sound resource: "shoot.mp3"

2017-05-31 14:31:06.865343+0800 Cloud War[4771:1325039] SKAction: Error loading sound resource: "shoot.mp3"

2017-05-31 14:31:08.387153+0800 Cloud War[4771:1325039] *** Terminating app due to uncaught exception 'Unsupported Texture Atlas Format', reason: 'Unsupported Texture Atlas Format Code 1'

*** First throw call stack:

(0x190ceafe0 0x18f74c538 0x190ceaf28 0x1a0415b04 0x1a0416788 0x1a0416998 0x1000f4098 0x10018da98 0x10018b930 0x10010b140 0x10010be08 0x1a041f730 0x196e5017c 0x196e4b728 0x196e1c33c 0x197616014 0x197610770 0x197610b9c 0x190c9942c 0x190c98d9c 0x190c969a8 0x190bc6da4 0x192630074 0x196e81058 0x1001a65a8 0x18fbd559c)

libc++abi.dylib: terminating with uncaught exception of type NSException

(lldb)

Replies

Did you delete the mp3 and add it back in again? usually works.

I've got similar problem, after approximately 4-5 minutes, the app crashed and exit.


Hereafter what is reported in the debugger shell:


2018-02-04 19:06:19.836867+0100 AlienStarship[344:73204] SKAction: Error loading sound resource: "photongun.mp3"

2018-02-04 19:06:19.837404+0100 AlienStarship[344:73204] SKAction: Error loading sound resource: "photongun.mp3"

2018-02-04 19:06:20.037843+0100 AlienStarship[344:73204] SKAction: Error loading sound resource: "bonus.mp3"

2018-02-04 19:06:20.038063+0100 AlienStarship[344:73204] SKAction: Error loading sound resource: "bonus.mp3"

2018-02-04 19:06:21.791066+0100 AlienStarship[344:73204] *** Terminating app due to uncaught exception 'Unsupported Texture Atlas Format', reason: 'Unsupported Texture Atlas Format Code 1'

*** First throw call stack:

(0x18369f164 0x1828e8528 0x18369f0ac 0x19a0b1e14 0x19a0b2aa8 0x19a0b2cb8 0x104eefa18 0x104eec7c8 0x104f0480c 0x104f05174 0x18409c5b8 0x183647dc0 0x183647ae4 0x1836472e4 0x183644ecc 0x183564c58 0x185410f84 0x18ccbd5c4 0x104f39144 0x18308456c)

libc++abi.dylib: terminating with uncaught exception of type NSException

if a set a breapoint on Exception on throw, the execution in most of the cases stops at the following line of code:


let atlas = SKTextureAtlas(named: "\(array.first).atlas")


And of course the String "\(array.first).atlas" is always a valid atlas reference, already used several time before the crash.

One more consideration: looking at the timestamps, in a couple of seconds the problem appear and the iOS seems not capable to ensure the load of the resources properly.


This error happen on all devices I've tested till now: iPhoneSE, iPhoneX, iPadPro (Xcode9.2, iOS 11.2)


Q?

Is the audio file deallocated from memory after the following action is executed and completed?

self.run(SKAction.playSoundFileNamed("bonus.mp3", waitForCompletion: false))


Q?

What's the meaning of the error reported by the message: 'Unsupported Texture Atlas Format Code 1'?


Q?

Could it be a bug in the SpriteKit library or is uncorrelated?

Thanks

I've found a possible reason of the random crash mentioned in my previous comment. It seems that SKAction.playSoundFileName is the source of the runtime issue that rises an exception because of a conflict accessing that resource. This is also consistent with the first runtime error/warning that always happened in loading a sound resource and resulting later in a crash.

Having substituted that method with one using the AVFoundation framework, the proplems disappeared.

Yeah you hear a lot of complaints about SKAction.playSoundFileName here. I tend to only use that with short .caf files (short being 1-2 seconds), then anything else I'll use AVFoundation.

I arrived to the conclusion that in the method SKAction.playSoundFileNamed() there is something weird.

The problem is most likely related to audio files when loaded multiple time. Example with the following statement:


let sound = SKAction.playSoundFileNamed("sound.mp3", waitForCompletion: false)


The only way I've found to avoid random runtime crashes it is to load the files once:


class Sounds

{

static let sound = SKAction.playSoundFileNamed("sound.mp3", waitForCompletion: false)

...

}


then use it as:


let sound = Sounds.sound

let remove = SKAction.removeFromParent()

let group = SKAction.group([sound, remove])

self.run(SKAction.sequence([group]))


No more chrashes and memory leakage neither!