Ticket Created
over 2 years ago

Venu 2 session.start() returns false

Hi,

I have reports from Venu 2 users that my app is unable to start a new workout session, and when that happens the app appears to hang. The only way to recover is to reboot the watch.

I am asking the user for the exact software version / Connect version and will update this thread when I have it.

I have attached the code below which starts the session.  The user I am working with sees 'Failed to Start Session' which means the session.start() returned false. This pop-up Toast screen contains a timer which makes it disappear after 3 seconds but this never happens, the screen remains.  Previous to having this screen handling the 'false' response I was getting reports that the 'started...' screen was hanging. This appears to be the same problem because I was previously showing that screen whether the start() call returned true or false.

Are there any situations under which the device will fail to start an acivity?  The activity code is ActivityRecording.SPORT_WALKING (11) in this specific case.

I am unable to recreate it in the simulator.

 public function createSession(){
        mSession = ActivityRecording.createSession({
                     :name=>"Generic",
                     :sport=>AppConfig.getActivityType()
        });
        resetSessionVariables();
    }

//returns whether the session is recording
    public function startOrPauseSession(){
        
        if (Toybox has :ActivityRecording) {
            if ((mSession == null)) {
                createSession();
                //System.println("New session created..");
                var started = startSession();
                //System.println("started:" + started);
                
                if(started){ 
                    WatchUi.pushView(new ToastView(
                                {
                                    :message => "Started...", 
                                    :textcolour => Graphics.COLOR_GREEN, 
                                    :arccolour => Graphics.COLOR_GREEN, 
                                    :animation => true
                                }), 
                         new ToastDelegate(),
                         WatchUi.SLIDE_IMMEDIATE);
                }
                else{ //some problem creating a session
                    mSession = null;
                    WatchUi.pushView(new ToastView(
                                {
                                    :heading => "Failed to", 
                                    :message =>  "Start Session",
                                    :textcolour => Graphics.COLOR_RED, 
                                    :arccolour => Graphics.COLOR_RED, 
                                    :animation => true
                                }), 
                         new ToastDelegate(),
                         WatchUi.SLIDE_IMMEDIATE);
                }
                return started;
            }
            else{
                if(!mSession.isRecording()) {
                    return startSession();
                }
                else{
                    var paused = pauseSession(false);
                    return !paused;
                }
            }
        }
        return false;
    }
    
    
    
    private function startSession(){
        
        if(!mSession.isRecording()) {
            if(mSession.start()){
                //System.println("session recording:" + mSession.isRecording());
                //System.println("starting session..");
                onForceUpdateHandler.invoke();
                WatchUi.requestUpdate(); 
                isAutoPaused =false; 
                autoPauseSuspended=true; //don't autopause until you've moved some
                Tones.alertStarted();
                return true;
            }
            else{
                System.println("failed to start session..");
                return false;
            }
        }
        return true;
    }