Delay when attempting to end an HKWorkoutSession in WatchOS 5
Asked Answered
S

0

7

I'm testing out my code that starts an HKWorkoutSession collects samples and ends then saves the workout using the old HKWorkoutConfiguration API (not the new HKWorkoutBuilder API)....my understanding is that the previous API should still work.

However when testing in the watch simulator, starting and stopping a workout using Xcode 10 Beta 4 and 5, I noticed that I am able to start a workout and query samples, however when I call healthStore.stop there is a 5 or 6 second delay until the workout ends?

// Create workout configuration
        let workoutConfiguration = HKWorkoutConfiguration()
        workoutConfiguration.activityType = .running
        workoutConfiguration.locationType = .outdoor

        do {
            workoutSession = try HKWorkoutSession(configuration: workoutConfiguration)
            workoutSession?.delegate = self

        } catch {
            fatalError(error.localizedDescription) 
        }

func start(_ workoutSession: HKWorkoutSession) {
        healthStore.start(workoutSession)
    }

    func end(_ workoutSession: HKWorkoutSession) {
        healthStore.end(workoutSession)
    }

Update 9/20/18: I filed a radar, it was marked as dup....as of Xcode 10 GM release this bug is still present. Confirmed this does NOT happen on device, only simulator.

Saberio answered 8/8, 2018 at 14:56 Comment(2)
I'd recommend you file a bug with Apple.Brawner
@Brawner will do, wasn't sure if this was part of the HealthKit API deprecationsSaberio

© 2022 - 2024 — McMap. All rights reserved.