SKSpriteNode & iOS 9

I've just installed iOS 9 & SDK and am having serious issues with SpriteKit.


I think this might relate to another issue I posted earlier about, not realising I was dealing with a potentially larger issue:

https://forums.developer.apple.com/message/36471#36471


The issue I've now encountered is SKSpriteNode's which were loading fine in iOS 8 are not loading/rendering correctly in iOS 9.


Issues i've seen so far include:


- The app will launch and in some instances sprites will flash on screen for a frame, then dissapear.

- If removing a sprite from parent, the previously loaded sprite of the same type will then become visible.

- Whilt the app is running, sprites will occationally/randomly flash on screen for a frame at random scales, looking seriously messed up.

- This is affecting SKSprites loaded from asset and directly via "spriteNodeWithImageNamed".


The strange thing is - none of the game breaking issues are aparrent in the iOS Simulator, only when running on my iOS devices (iPhone 6+ & iPad Air).


I have had no issues like this using SpriteKit in iOS 7 & 8, only since moving to iOS 9.

Has anyone had similar issues or have any suggestions?

Answered by PaulSolt in 36854022

I've had numerous issues with SpriteKit in iOS 9. It's pretty impossible to do anything with SpriteKit right now in Swift 2.


I would recommend you submit bug reports for it. http://bugreport.apple.com


I submitted several bugs – SKEffectNode doesn't work on the Simulator, but it seemed to work on the Device. That caused some of my nodes to disappear.


Anything that's using imageNamed doesn't work like it used to. It requires that I append the .png extension for the asset, even though it's in the Asset Catalog. Another workaround is to remove the item from the asset catalog and readd it. Then it seems to work without the extension.


Bug # 21525497 - SpriteKit SKSpriteNode images from Asset Catalog do not load without extension – breaking Xcode 6 behavior

Bug # 21509174 - SKEffectNode doesn't render on the iOS Simulator for Xcode 7 and Swift 2

Accepted Answer

I've had numerous issues with SpriteKit in iOS 9. It's pretty impossible to do anything with SpriteKit right now in Swift 2.


I would recommend you submit bug reports for it. http://bugreport.apple.com


I submitted several bugs – SKEffectNode doesn't work on the Simulator, but it seemed to work on the Device. That caused some of my nodes to disappear.


Anything that's using imageNamed doesn't work like it used to. It requires that I append the .png extension for the asset, even though it's in the Asset Catalog. Another workaround is to remove the item from the asset catalog and readd it. Then it seems to work without the extension.


Bug # 21525497 - SpriteKit SKSpriteNode images from Asset Catalog do not load without extension – breaking Xcode 6 behavior

Bug # 21509174 - SKEffectNode doesn't render on the iOS Simulator for Xcode 7 and Swift 2

Does the adding *.png fix for iOS 9 also break iOS 8 apps, or would they still function?

Thanks for your reply Paul, appreciate it.


I can only assume this is not intended behaviour on Apple's behalf for SpriteKit and will submit bug reports hoping it all gets ironed out before iOS 9 is released.


Cheers.

I am also having similiar issues, All animations are flickering and flacky, sometimes certain images will load. Other times they load in the wrong z-index order. Everything works perfectly on the simulator.

I have only one apparent issue with the spritekit on ios9 (simulator) right now: masknodes are rendered as black rectangles (same nodes work 100% correct on ios8 devices.


Does anyone has similar issues? I'm not totally sure it is not a problem on my side.

Filed the bug 22301219 for the SKCropNode behaviour in ios 9 simulator.

I have problem on my SKCropNode too. It works in simulator of iPhones (iOS9), but it renders black rectangle in simulator of iPads (iOS9).


They both work in iOS8 devices.

I am having the exact same issue. I have no idea what to do. Is there an easy fix to this that I could do? or is Apple working on things, and should I just wait to see if they fix the bugs?

Have you explicitly set all of the zPositions of the SKSpriteNodes? I was running into the exact same problem where a few of my SKSpriteNodes randomly appeared, and I had never given them a zPosition value. High zPositions get displayed on top of lower zPositions.

I have filed Apple a bug on August 17, which they have acknowledged but failed to correct in the iOS 9 GM released to the public :

22311428 SpriteKit: SKSpriteNodes only appearing if sprites are Universal and not device-specific


I have created a repository to better communicate the bug to Apple.

https://github.com/f8th/SpriteKit_iOS9_Bug/tree/master

I'd be glad to accept any help with case #2, I can't seem to reproduce it.

The rendering is now different so if you don't add a z-position for your node it will flashes because every time(e.g. 60 FPS) when the system render your screen the z nil become random.

Same problem for me, also found difference in behavior:


1. If using SKShapeNode rect with corner radius the roundness of sprite in cropped area looks not so round as it should be, there is big performance slowing down and strange flickering. On device is better performance, roundness as it should be but still some flickering.

2. If I set my sprits to be just a rectangle without roundness performance is bit better and no flickering but still not great overall.

3. if sprite is a texture performance is even better but still not so suitable as i only render 12 small sprites and performance is not good still..

This fix is working for me. Thanks! The issue I was having was specific to iOS9, Simulator, iPhone 5 (I'm using Xcode 7.0.1, but don't know if that's relevant). Explicitly adding the .png fixed the issue. Without this, the sprite was not showing up at all. I don't have actual iPhone 5 hardware so haven't been able to try it on an actual device. My question is now: I'd rather not apply this fix to the production app release. What I'd like to do is use it (the fix) only when needed. Haven't been able to programmatically detect the problem with the sprite though. E.g., with a UIImage that failed to load because of a bad image name, I'd get a nil UIImage. In this case, SKSpriteNode(imageNamed: ...) creates a non-nil sprite however.

Hi djarin,


iOS 9.2 Beta 1 and Xcode 7.2 Beta 1 are now available via the Developer Center. Can you verify these issues? Please let us know if any of these issues persist.


Additionally, flickering issues are typically due to ignoresSiblingOrder = true on SKView. When set, sibling nodes with the same z position are not rendered in a deterministic order and can result in one node ocassionally being drawn behind another. This property allows us to apply additional optimizations to improve rendering performance. In Xcode 7, the SpriteKit project template sets this property to true, but you can set it to false if this is not the behavior you'd like.


Thanks.

Hi crspybits,


Have you tried verifying this issue on iOS 9.2 Beta 1? The update has a fix and this workaround should no longer be necessary. If any issues persist, please file a bug report.


Both iOS 9.2 Beta 1 and Xcode 7.2 Beta 1 are available via the Developer Center.


Thanks.

SKSpriteNode & iOS 9
 
 
Q