Here is my problem: Despite doing these:
1) Preloading all of my texture atlases
2) Having my atlases stored in Singletons so they are not disposed of by ARC
3) Having all my animation arrays stored in Singleton
SpriteKit STILL has a short "lag jitter" when adding enemies to my scene ONLY the first time they are added. After the texture is drawn once, it never lags again when that texture is added to the scene. Memory can be seen going up when the textures are drawn on the screen finally, which looks like they aren't getting preloaded.
I am currently preloading ALL of my texture atlases in my AppDelegate on startup using...
SKTextureAtlas.preloadTextureAtlases(primaryAtlas, withCompletionHandler: { () -> Void in
})
primaryAtlas is an array of all 4 of my atlases which are stored in a Singleton.
Let me point out some things I have already tried and what my current setup is.
1) The array of frames for my animations are stored in Singletons and get their images from the Atlases which are in a different singleton. They used to be in the same Singleton.
2) I've tried storing ALL my textures in a Singleton which were all loaded from the atlases. But currently my animations are stored, while my single textures are functions that fetch that texture from the atlases.
3) I've turned off all animations for enemies (don't run the SKAction) and the jitter still happens when they're added and not animating.
I've been trying to fix this for a very long time and there honestly doesn't seem to be a solution.
There seems to be a similar StackOverflow question I found here with no answer: Spritekit: First texture draw slow (preloaded)