Execution of the command buffer was aborted due to an error during execution. Insufficient Permission (to submit GPU work from background)

I have a SpriteKit project in which I'm seeing the following error repeatedly printed to the logs when testing on a real device:

Execution of the command buffer was aborted due to an error during execution. Insufficient Permission (to submit GPU work from background)

This happens when the app is in the background state.

Now, it's pretty obvious what's going on: SpriteKit uses Metal, and the latter is committing new work to the GPU when the app is backgrounded (which is something you can't do).

I've confirmed this theory by not loading my SpriteKit scenes. If I don't load the scenes, the problem does not occur.

This is a strange problem because, according to Apple's documentation, SpriteKit is paused/resumed automatically when the app goes from/to the background:

When an application moves from an active to an inactive state, isPaused is automatically set to true. When an application returns to an active state, isPaused is automatically set to its previous value.

So, I would expect new work to stop being sent to the GPU.

Question:
How do I resolve this error?

Answered by JoeWest in 675486022
After filing a TSI, it was confirmed by Apple that this is a bug related to the use of playSoundFileNamed(_:waitForCompletion:), which is somehow causing the "update" function to be called when the app is in the background (despite the scene being automatically paused!). It was suggested that I use AVAudioPlayer or AVAudioPlayerNode instead.

I filed bug FB9107848
Accepted Answer
After filing a TSI, it was confirmed by Apple that this is a bug related to the use of playSoundFileNamed(_:waitForCompletion:), which is somehow causing the "update" function to be called when the app is in the background (despite the scene being automatically paused!). It was suggested that I use AVAudioPlayer or AVAudioPlayerNode instead.

I filed bug FB9107848
Execution of the command buffer was aborted due to an error during execution. Insufficient Permission (to submit GPU work from background)
 
 
Q