Search code examples
swiftsprite-kitcore-animation

Simple SKScene randomly drops to 40fps


I have a simple SKScene generated in code that gets presented from a SKView in a storyboard. This scene contains a single 30x18 pixel art image, no animations, no updates.

For some reason, such a simple scene is randomly falling to 40FPS with no clear explanation. CPU usage is always ~14% or lower in the app, so this seems extremely unnecessary.

I couldn't find many helpful posts on this issue, besides one that claimed CADisplayLink caused this issue. I don't use this framework, however my app utilises CAGradientLayer, leading me to believe Core Animation in general causes this issue.

Disabling it in my app significantly reduced the frequency of this issue. Where I would have seen it 20 times before, I now see it once. However, it's still happening. Does anyone have any suggestions on this issue?

Thanks!


Solution

  • It appears my hunch was correct; Core Animation (and perhaps UIKit Animation) interferes with SpriteKit. Disabling any active instances of CABasicAnimation and UIView.animate in my app when the scene is loaded resolved the issue.

    Hope this helps someone!