I've been running my SceneKit game for many weeks in Xcode without performance issues. The game itself is finished, so I thought I could go on with publishing it on the App Store, but when archiving it in Xcode and running the archived app, I noticed that it seriously hangs.
The hangs only seem to happen when I run the game in fullscreen mode. I tried disabling game mode, but the hangs still happen. Only when I run in windowed mode the game runs smoothly.
Instruments confirms that there are many serious hangs, but it also reports that CPU usage is quite low during those hangs, on average about 15%. From what I know, hangs happen when the main thread is busy, but how can that be when CPU usage is so low, and why does it only happen in fullscreen mode for release builds?
It looks like we've provided a response:
"SceneKit doesn't require modification to be performed on the main thread. Quite the opposite. Doing work in the renderer delegation callbacks allows for direct access to the presentation tree and doesn't go through a transaction. Dispatching to the main thread (with a Swift Task) is an anti-pattern in this case."