Search code examples
ioswatchkitapple-watchhealthkit

"Execution of the command buffer was aborted due to an error during execution" on Apple Watch App?


2020-01-18 18:03:02.316685-0500 Watch Extension[529:813076] Execution of the command buffer was aborted due to an error during execution. Insufficient Permission (to submit GPU work from background) (IOAF code 6)

I started getting this console message printing repeatedly when testing 3 HealthKit Apps but I can't figure out what it is related to and previous SO questions are only regarding the iPhone. Specifically it seems like I can trigger it when I simulate workout movements (i.e. jogging). Any idea what could cause this message on the Watch?

EDIT: I believe the problem is an SKScene that I am using to show an animation on the watch app. When I comment out the below, I am not seeing the console warnings anymore:

 @IBOutlet var spriteKitScene1: WKInterfaceSKScene!
    @IBOutlet var spriteKitScene2: WKInterfaceSKScene!

Solution

  • HealthKit must be using Metal, or something in your app is. Metal does not allow background processing.

    To get rid of the warning, you will need to pause or suspend any processes that use Metal.

    In your AppDelegate.swift file, you can implement these two methods:

    func applicationWillResignActive(_ application: UIApplication) {
        //Pause or suspend any operations using Metal
    }
    
    func applicationDidBecomeActive(_ application: UIApplication) {
        //Resume or start operations using Metal
    }
    

    The other way to start/stop operations when entering background/foreground is with notifications. If you prefer that pattern I will post examples.

    Note that what you are seeing is a warning indicating that Metal processing does not occur in the background. If your app is working as expected you can ignore the warning.