NSGenericException reason Collection

I get the same exception on occasion. It’s been around for a while and I’ve been trying to pinpoint it for weeks.

My suspicion is that it may occur due to preloading textures, either manually or triggered automatically by Sprite Kit while at the same time some other code causes textures to be loaded or accessed.

I have reduced my preloadTextures: calls to a single one but I still get the issue, just less often. I have tried to performSelector:onMainThread: whenever I run a selector that accesses or loads images (or just might internally) from within a completionBlock or other code that runs on a different thread.

I haven’t had this crash the entire day today after I moved my user interface code to the main thread (it was called from a completion handler). I can’t say 100% for sure whether this fixed it though.

I hope this helps a little. There’s definitely something finicky going on, and if you do po 0x1459da60 (in lldb’s command window, using the address provided by the exception) you’ll see that it is the SKTextureAtlas texture list that is being modified. I hope that helps you pinpoint where the issue is coming from on your side.

Leave a Comment