Acknowledged

bug: System Error when calling Session.start()

I see a few errors like:

Error Name: System Error
Devices:
    Forerunner® 965: 19.18
    Forerunner® 245: 13.70
Backtrace:
    MyView.startTimer:184

code:

MyView {
 function startTimer() as Void {
  session.start();
 }
}

However I don't understand what can cause System Error. I mean according to the documentation there's no mention of any condition that start is not supposed to be called, and I would expect it never to fail (but maybe return false):

------------------------- 8< --------------------------------------

start() as Lang.Boolean

Begin recording a FIT file on the system.

Returns:

  • Lang.Boolean  

    true if recording was successfully started, otherwise false

Since:

API Level 1.0.0

------------------------ >8 ----------------------------------------

I suspect that what happens is the user saves the session (calls session.save()), and then accidentally clicks the start button, and my code tries to start the session again.

It would be nice to have something about this in the documentation (and maybe there could be a better name for the error), together with the recommended way to avoid this (I mean I can add some booleans to my code and keep track of things, but is it necessary? Maybe there could be another function, similar to session.isRecording? Or is it isRecording() I should call: if (!session.isRecording()) {session.start();}

  • I don't see how the user pressing a button by "accident" comes into play here.

    To be clear, I”m not saying that the user is incapable of making a mistake, but only that any mistake the app allows should also correspond to a deliberate action.

    For example, I can lap my activity by accident by pressing the lap button, but I could’ve also taken a lap on purpose.

    If such an action has serious consequences for the user, that’s where it would help if the app allows the user to undo the action (e.g. in the case of taking or lap) or asks for confirmation (e.g. in the case of saving or discarding an activity).

    Otoh, if it’s possible in principle for the user to “accidentally” trigger code that shouldn’t even run in principle, that’s where I think an app should constrain the user so they can’t take that action. For example, a native activity won’t let you take a lap before the timer has started. The user is constrained to only be able to take laps while the timer is running (with the lap button) or while the timer is stopped (via the menu).

  • > I suspect that what happens is the user saves the session (calls session.save()), and then accidentally clicks the start button, and my code tries to start the session again.

    That's correct, you can't call start() on the same Session object twice. If you've already called start(), you should prevent your code from from calling start() again. If your app has a way to start a 2nd session after the 1st is ended, then the existing session object should be destroyed and a new instance should be created, after discard() or save() is called.

    I agree that this should be documented.

    Speaking of issues with Session, a long time ago there was a serious bug on an old watch where starting a new Session too quickly after saving a different Session would cause the device to crash and endlessly vibrate. I think the only way to recover was to force a shutdown. That problem was fixed, but ever since then I've been a little wary of this feature.

    > user saves the session (calls session.save()), and then accidentally clicks the start button

    I don't understand this wording. You make it sound like this is partially user error? The word "accidentally" would imply that the user did something they shouldn't do or that doesn't entirely make sense (otherwise why couldn't it be intentional?), but it's up to your app to constrain the actions of the user appropriately.

    If it doesn't make sense to press Start after the previous session is saved (without, say, some explicit action to "reset" the app state, perhaps through a menu option, or maybe even closing and re-opening the app), then the app should simply ignore the Start button in that case. Or if it's supposed to work like a native activity on most (or all watches) and exit after the session is saved or discarded, then the app should do that instead.

    Otoh, if it's a feature of the app that the app stays open after the previous session ends, and pressing Start should start a new session, then the app should simply handle that situation properly.

    I don't see how the user pressing a button by "accident" comes into play here.