Need help/advice about my app crashing on the device but not on the simulator

Former Member
Former Member
I am currently working on a Golf Scorecard counter. The counter as such works fine, but I have problems with the recording of an activity.

In a first attempt from last week it worked and the activity was even automatically uploaded to Garmin connect. In the present version, it works fine on the simulator but it crashes on the fenix 3 and shows the IQ icon with a yellow "!" sign when I start (or try to start) the activity.

The app loads fine, works fine as long as I don't start the recording, but once I select a "Start new round" from the menu and execute the following code, it crashes if it is the first time that the app is executed on the device.
When I open the app again, I can select the same menu item, the app does NOT crash this time, but it doesn't start to record the activity either. It continues to work normally with the inly exception that it refuses to start a recording.

Here is the MenuDelegate:

class Golf_SCMenuDelegate extends Ui.MenuInputDelegate {

function onMenuItem(item) {
if (item == :item_start_rec) {
startRound();
}
return true;
}
}

Now here's the code that is called from the MenuDelegate:

function startRound() {
if( ( session == null ) || ( session.isRecording() == false ) ) {
session = Rec.createSession({:name=>"Golf", :sport=>Rec.SPORT_GENERIC, :subsport=>Rec.SUB_SPORT_GENERIC});
strokes = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ,0 ];
hole = 1;
session.start();
Ui.requestUpdate();
}
}


The Position tracking is switched on already when the app is loaded, without any problems, using
Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));

I would be very grateful if someone could come up with ideas and instructions.
  • If you are getting the IQ crash symbol on the watch, it should be writing an error in CIQ_LOG.txt.

    You might have to create an empty CIQ_LOG.txt file on the watch in GARMIN\APPS\LOGS before it will write the error there (I don't remember if you need the empty file in this case or not). That error message may help direct you to the source of the problem.
  • Former Member
    Former Member over 10 years ago
    If you are getting the IQ crash symbol on the watch, it should be writing an error in CIQ_LOG.txt.

    You might have to create an empty CIQ_LOG.txt file on the watch in GARMIN\APPS\LOGS before it will write the error there (I don't remember if you need the empty file in this case or not). That error message may help direct you to the source of the problem.


    You do need to create the CIQ_LOG.TXT file before error reports will be written out to the file.
  • Former Member
    Former Member over 10 years ago
    CIQ_LOG.txt

    Thank you very much for that advice.

    I have another persisting problem since the last fenix 3 FW update, though: in 80% of the time the fenix is not mounted on my Mac, i.e. it charges but it is not detected as a drive, and I can't get access to any data. The battery charge level jumps erratically to 100%, and the fenix needs to be rebooted. And it "forgets" the installed 3rd party widgets and re-orders the stock widgets. It drives me mad...:mad:

    Anyway: I could mount the fenix ONCE successfully, but there was not CIQ_LOG.txt file at all.

    Will keep trying...

    Garmin, what's wrong with the not-mounting-fenix issue?
  • Former Member
    Former Member over 10 years ago
    OK, I was successful to get an error message in CIQ_LOG.txt:

    [FONT=Courier New] in /Users/karsten/Documents/Research/Code/workspace/Golf_SC/source/Golf_SCView.mc (getRoundData:215)
    in /Users/karsten/Documents/Research/Code/workspace/Golf_SC/source/Golf_SCView.mc (update_single:156)
    in /Users/karsten/Documents/Research/Code/workspace/Golf_SC/source/Golf_SCView.mc (onUpdate:184)
    TVM ERROR:
    Unexpected Type Error
    Failed invoking <symbol>

    TVM ERROR:
    Unexpected Type Error
    failed in cdp_tvm_invoke
    [/FONT]


    Don't know what TVM means.

    The routine that causes the error runs nicely in the simulator. It reads activity.info and (tries to) convert into a string, after some scaling. The offending source line is:
    [FONT=Courier New] dist = ActInfo.elapsedDistance.toLong();[/FONT]

    Here is the rest of the routine:

    [FONT=Courier New]
    function getRoundData() {
    var dist;
    var elapsed;
    var log_slots = 2;

    RoundData = "";
    RoundData = Lang.format("Distance: m \nDuration: min");
    if( Toybox has :ActivityRecording ) {
    if( session != null && session.isRecording() ) {
    ActInfo = Act.getActivityInfo();
    if (ActInfo != null) {
    dist = ActInfo.elapsedDistance.toLong();
    dist = dist % 1000;

    elapsed = ActInfo.elapsedTime.toLong(); //
    elapsed = elapsed / 60000;
    if (log_iterator == 1) {
    RoundData = Lang.format("Distance: $1$ m", [dist]);
    log_iterator = 2;
    } else
    if (log_iterator == 2) {
    RoundData = Lang.format("Duration: $1$ min", [elapsed]);
    log_iterator = 1;
    }

    }
    }
    }
    return RoundData;
    }
    [/FONT]
  • Former Member
    Former Member over 10 years ago
    Problem apparently fixed for now

    Thanks for your patience.

    I do a check whether the objects elapsedTime and elapsedDistance exist, i.e. != null, before I try converting them. Seems to work. Stay tuned.
    :)
  • Former Member
    Former Member over 10 years ago
    I would guess that's the problem. Unexpected type errors tend to mean there's a null value somewhere.
  • Former Member
    Former Member over 10 years ago
    Don't know about your problem. But would you be interested in..

    log_iterator++;
    if(log_iterator % 2){
    //..
    }
    else {
    //..
    }


    also, I'm assuming you've initiated log_iterator somewhere.
  • planetscooter, it would be really nice if you could use tags around your code snippets. This maintains whitespace, which improves readability a lot.
  • Former Member
    Former Member over 10 years ago
    OK, first version uploaded. Awaiting approval.