Complete
over 3 years ago

Bug: Activity has :getCurrentWorkoutStep is true even when no workout is selected

I tried this on my Fenix 5s plus and also a user of one of my datafields experienced this with his Fenix 5 plus. Code where this check is used:

if (Activity has :getCurrentWorkoutStep) {

always returns "true" on these watches. Also when no workout is selected.

In the Garmin simulator this isn't the case and the code runs correct.

  • The expression Activity has :getCurrentWorkoutStep should evaluate to true on devices that have support for this function. The value should not change at runtime for a given device, but it may change when you switch between devices in the simulator. e.g., if you simulate a fenix5spro it should evaluate to true, but if you simulate a fenix3 it should evaluate to false.

    The expression Activity.getCurrentWorkoutStep() should return a WorkoutStep when a workout is active, or null if no workout is active. If the virtual machine evaluates that expression on a platform that doesn't have support (you can tell with the (Activity has :getCurrentWorkoutStep) check mentioned above), the virtual machine will generate a Symbol Not Found error and your app will crash.

    If you believe you are seeing the value of (Activity has :getCurrentWorkoutStep) change at runtime, please post a code snippet or a sample app with specific instructions on how to reproduce.

  • Trying opening your SDK manager and letting the devices update. If I'm not mistaken, Fenix 5 Plus devices only recently got support for 3.2. It may be that you have the older device definitions.

  • Yep, I did expect "Activity has :getCurrentWorkoutStep" to be true only when a workout is selected! Thanks for clarifying this!

    However, it is still strange that the simulator and a real watch act differently when this instruction is used. I would expect them to behave the same.

  • Just to clarify, do you expect "Activity has :getCurrentWorkoutStep" to be true only when a workout is selected?

    Because that just checks that the feature is available. I would expect that check to return false for any device which doesn't support CIQ 3.2, and return true for any device which does support 3.2. I think Fenix 5 Plus now supports CIQ 3.2 in firmware and in the simulator, so I would expect the check to be true.

    I would expect the full code to look like this:

    var currentStep = null;
    
    if (Activity has :getCurrentWorkoutStep) {
      currentStep = Activity.getCurrentWorkoutStep();
    }
    
    if (currentStep != null) {
        //...
    }

    Sorry if that's what you were implying.