Weird Session Recording (discard not being honored and others)

This is on an F3.
I'm seeing sort of a weird(?) behaviour on an app I'm writing.

Weird #1
When I StopSession, i expect it to discard the session. But it seems like sometimes I honors it, most times it does not. I still see the session still being saved (from the watch's history page)

Shouldn't it NOT be in the history page?

Weird #2
sometimes, when i stop the app, and supposedly it will discard the session. When I immediately (or couple secs) go to a native app (RUN App for instance), it will show me a Save/Discard/Trackback etc view. The top will read something like 0:00 / _:__ km

I will go and do the "discard" and the watch will just hang there w/ the circling discard animation. (I have to Hard reboot the watch via the LIGHT/POWER Button)

Is there a native Save / Resume / Discard view that we can leverage whenever we stop a recording session?

BTW - for clarification (not entirely clear to me in the manual/API doc)
session.save == we stop and save the session
session.stop == we stop the session (not saving the fit file? or does it save it?)
session.discard == we stop and discard the session. (we do not need to explicitly do a session.stop(); session.discard();)





function StartSession(dc) {
var SS_Start = Sys.getTimer();
if ( session == null ) {
Sys.print("Session CREATE & START");
session = Record.createSession({:name=>"Running", :sport=>Record.SPORT_RUNNING, :subSport=>Record.SUB_SPORT_STREET});
session.start();
} else if( (session != null) && (session.isRecording() == false) ) {
Sys.print("Session RESTART");
session.start();
} else if( session != null && session.isRecording() ) {
Sys.print("Session STOP (PAUSE)");
session.stop();
}
var SS_End = Sys.getTimer();
var SS_Total = SS_End - SS_Start;
Sys.println(" StartSession Total Time: " + SS_Total);
Ui.requestUpdate();
}


function StopSession(dc) {
if( session != null && session.isRecording() ) {
Sys.println("Session STOP & SAVE");
// session.stop();
//session.save();
session.discard();
session = null;
Ui.requestUpdate();
}
}
  • Former Member
    Former Member over 9 years ago
    I am working on Activity Recording at the moment.

    I always stop session before doing a save or discard, it seems to work for me. Here is some snippets of my code I am using at the moment.

    So for a basic recording I would call:

    begin();
    .....
    .....
    pause();

    then either

    save(); or discard();

    depending on what the user has selected to do with the session.




    function begin() {
    Sys.println("workoutView::begin");
    if( Toybox has :ActivityRecording ) {
    if( ( session == null ) || ( session.isRecording() == false ) ) {
    Sys.println("workoutView::createSession");
    session = Record.createSession({:name=>"Run", :sport=>Record.SPORT_RUNNING});
    session.start();
    program_state = PROGRAM_STATE_RECORDING_ACTIVITY;
    }
    }
    }

    //-----------------------------------------------------------------------------
    // pause - called to pause the interval session
    //-----------------------------------------------------------------------------
    function pause() {
    Sys.println("workoutView::pause");
    program_state = PROGRAM_STATE_PAUSED_ACTIVITY;
    if( ( session != null ) && session.isRecording() ) {
    Sys.println("workoutView::session.stop");
    session.stop();
    }
    }

    //-----------------------------------------------------------------------------
    // resume - called to resume an interval session if it has been paused
    //-----------------------------------------------------------------------------
    function resume() {
    Sys.println("workoutView::resume");
    program_state = PROGRAM_STATE_RECORDING_ACTIVITY;
    session.start();
    }

    //-----------------------------------------------------------------------------
    // save - called to save the interval session
    //-----------------------------------------------------------------------------
    function save() {
    Sys.println("workoutView::save");
    if( Toybox has :ActivityRecording ) {
    if( ( session != null ) )
    Sys.println("workoutView::session.save");
    session.save();
    Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:onPosition));
    }
    }
    }

    //-----------------------------------------------------------------------------
    // discard - called to discard the interval session
    //-----------------------------------------------------------------------------
    function discard() {
    Sys.println("workoutView::discard");
    if( Toybox has :ActivityRecording ) {
    if( ( session != null ) )
    Sys.println("workoutView::session.discard");
    session.discard();
    Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:onPosition));
    }
    }
    }
  • Former Member
    Former Member over 9 years ago
    You do need to call stop() before using save() or discard().

    If you do not discard() the activity will automatically be saved when the app exits.

    There is at least one issue when executing activity recording operations too quickly that we are working on fixing on the products. I know you can trigger the behavior you described by starting a session, and then stopping and saving/discarding it very quickly after the start. This can a syncing error in the system timer state, and cause the native app to display the save/discard page when there isn't an active recording. If you see this, you should briefly start and stop the timer before attempting to select discard, which should prevent the device lockup you experienced.
  • 150

    thanks for validating that I am sane. I was about to make a YouTube video and/or send code your way.
    Anyways - here is what I found I can do to NOT have device lockup.

    Use my app
    Start my session recording
    10m later (or such)
    Stop my session. (I discard the session)
    Exit app
    Do nothing or do something does not matter here.
    I go to a native app - run app for eg
    The native save/resume/discard view comes up
    I click resume.
    Start the timer
    Stop the timer
    Get presented with the save/resume/discard view again
    Select discard

    Then all is well. But this dance is just too..... Odd

    Not sure how I will be able to release this app if this "bug??" Is not resolved.
    And is it only me that's suffering this? I tried the GOLF_SC app - don't seem like it has this problem. (Then again I don't think it uses a timer. May be wrong)


    Btw - to exit the app, how / what is the preferred way to present to the user the save/discard view? I see most apps utilizes their own version, some presents a menu with a LONG PRESS of the menu button, some uses the back/lap button.

    Honestly - it's confusing to NOT have a standard view. (My 2c)
  • Former Member
    Former Member over 9 years ago
    I suspect there is something else going on in your app, or another issue that I am not aware of.

    The issue I know of requires calling start(), stop(), and discard() all within about 1 second. If you are calling stop() and discard() 10 minutes later, this should not happen.

    I agree that it would be good to have the native save/discard flow available to ConnectIQ, but I don't think it is going to happen. I recommend using a button for starting and stopping, and displaying a menu for resume/save/discard after the timer has stopped.
  • This is happening w/ 2 apps of mine (unless both are screwed up due to same implementation)
    would you mind having a look at it? Cos I really don't know what's happening
  • Former Member
    Former Member over 9 years ago
    If you would like to send your source to [email][email protected][/email] I would be interested in taking a look. If there is a different bug occurring we will want to address it.
  • If you would like to send your source to [email][email protected][/email] I would be interested in taking a look. If there is a different bug occurring we will want to address it.


    email sent. Thanks. Appreciate the help.
    Btw - I lied. I don't wait 10m (but it still happens. I wait like 5 secs or 10secs before I stop the activity session)
  • It sounds like you are still not calling session.stop() before you save/discard, and this throws the device into a tizzy.
  • Former Member
    Former Member over 9 years ago
    NIKEOW,

    It doesn't look like you are doing anything wrong in your app. This appears to be a device issue on Fenix 3, and I believe the issue will effect Epix as well. I have notified the device teams, and the issue should be resolved in a future device firmware update.
  • thanks for the confirmation. So.... What's my option now?

    Additionally - why is it that I am affected whereas the other apps which I have tried does not seem to have this bug/situation? What is it that they are doing which makes it such that they don't get this weird behavior?