1

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!
GarySabo
  • 5,806
  • 5
  • 49
  • 124

1 Answers1

1

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.

Jeshua Lacock
  • 5,730
  • 1
  • 28
  • 58
  • I'm using Swift. It's strange these are apps that are in production and have been for years, then suddenly I am seeing these console messages in Xcode 11.3. Specifically where it is occurring is in the delegate I really can pause or suspend any HealthKit operations as the user is in the middle of the workout. It seems to get triggered when I simulate workout activity, i.e. moving my arms around. It also happens across different APIs across HealthKit (i.e. the old HKWorkoutSession API and querying for samples as well as the new WorkoutBuilder API). – GarySabo Jan 30 '20 at 01:20
  • If it's not adversely affecting the app operation you can ignore the message, it just means whatever is using Metal is being suspended while the app is backgrounded. Are you using anything besides HealthKit that could be using Metal? – Jeshua Lacock Jan 30 '20 at 01:25
  • No I don't notice any performance changes in the apps, its just that in the console it literally prints every second so it was a little alarming. No only using WatchKit and HealthKit. – GarySabo Jan 30 '20 at 03:35
  • Try pausing or terminating all WatchKit and HealthKit events on applicationWillResignActive and see if the warning still happens. Should only take a couple minutes to test and see. – Jeshua Lacock Jan 30 '20 at 08:28
  • Well, this is a WatchKit app so it would be the equivalent method, but given that an HKWorkout ongoing always puts your app in the foreground I don't think the method would ever get called until the workout was ended. I am seeing these console logs while I am looking at my app's watch screen during a workout. – GarySabo Jan 30 '20 at 16:29
  • I figured out that what is causing this is an SKSpriteNode I am using to animate a heart beat on the watch (if I comment out the IBAction, the warning doesn't appear) but I can't figure out how to fix and still use it? – GarySabo Feb 14 '20 at 02:11
  • You will need to suspend animation when the app is backgrounded. Can you show the code you are using for SKSpriteNode? – Jeshua Lacock Feb 15 '20 at 03:03
  • There isn't much, it's just an IBOutlet connected to the InterfaceController in the Storyboard, I've edited my question. – GarySabo Feb 16 '20 at 15:50
  • 2
    Since I was using SpriteKitScene for animations in my watch app, I was able to implement a protocol that informed my InterfaceController when the app is inactive or active and use the .`isPaused" property on the SpriteKitScene to pause it. – GarySabo Feb 19 '20 at 00:37
  • 1
    @GarySabo Thanks, your comment saved me lots of time! – vfxdev Jul 10 '20 at 16:10
  • Instead of implement it in appdelegate file, alternately you can do it in your controller by register for the `UIApplicationWillResignActiveNotification` notification for apps enter background, and `didBecomeActiveNotification notification` for apps enter foreground. – titan Aug 11 '20 at 08:56