Datafield works on simulator but not on the edge

I have been developing a datafield, but I had the problem that it is working very well on the simulator but there is an issue when I installed into the edge device:

when installing the datafield on my edge I got the screen like a flash and then a white page with the blue "IQ" letters an exclamation mark on the middle.

Normally I just restart the device and after that it worked. However, now that I am adding additional features to my datafield, it is not longer working with this method. 

Same behavior if I installed the datafield using connectIQ or sideload

So I will appreciate your kindly help so that I can understand what I am doing wrong.

I have the code on git, so your guidance will be really appreciated.

link to github

By the way, the errors I got from the log are:

ERROR: Unhandled Exception

DETAILS: NONE

STORE_ID: 19d85c19728443e18683edd87f79b472

CALLSTACK:

UnexpectedTypeException: Expected Number/Float/Long/Double, given null/Number

ERROR: Unexpected Type Error

DETAILS: Failed invoking <symbol>

STORE_ID: 00000000000000000000000000000000

CALLSTACK:

                @PC = 0x10003939

ERROR: Unhandled Exception

DETAILS: NONE

STORE_ID: 00000000000000000000000000000000

CALLSTACK:

UnexpectedTypeException: Expected Number/Float/Boolean/Long/Double, given null

native function

  • If it happens with a sideload, use "build for device wizard", and don't check the "build release version" checkbox.

    When you run it, you should get details in the apps/logs/ciq_log.yml file.

    You'll get the same file with a download from the store too, but it doesn't have the debug info and is a bit more work to interpret.

  • Things like "don't check build release version" is something that is not on Garmin documentation.... Thanks for the tip!

    I clear the log and got the following:

    ERROR: Unhandled Exception
    DETAILS: NONE
    STORE_ID: 00000000000000000000000000000000
    CALLSTACK:
    UnexpectedTypeException: Expected Number/Float/Long/Double, given null/Number
    compute in C:\Users\JVC\eclipse-workspace\MTBHybrid datafield edges\source\noresourcesView.mc:131
    
    ERROR: Unexpected Type Error
    DETAILS: Failed invoking <symbol>
    STORE_ID: 00000000000000000000000000000000
    CALLSTACK:
      C:\Users\JVC\eclipse-workspace\MTBHybrid datafield edges\source\noresourcesView.mc (onUpdate:470)
    

    Looking into my file "noresourcesView.mc line 131 I got the following sentence:

    cadEndX= toNumberCeil(cadX+((ancho-40)/2+5)*Math.cos(Math.toRadians(270-cadrpm*2.25)));

    before that line, a got a very similar sentence, but it is not including the variable "ancho", so I suspect this is the one causing issues. The difference between "cadX" and "ancho" is that I defined cadx as:

    hidden var cadX = 120;

    and ancho was defined just as:

    hidden var ancho;

    So, it looks like I need to assign some value to "ancho" to avoid the error. 

    the error "Failed invoking <symbol>" I don't have an idea what it means.

  • Yes, with just

    hidden var ancho;

    ancho is a null, so it was trying to do "null-40"

    Also, anything you see in the info structure passed to compute in a data field, you also want to null check, because some things will be null before recording begins, some will be null because they aren't available, etc.

    With the "build release version in the wizard you really want to leave it as a debug build so you get more into if there's a crash.  What you run in the sim is also a debug build.

  • I ran into a similar issue with a datafield which had been running on my FR935 without issues but crashed on the FR945.

    In my case I had a variable which got assigned some value (and got null-checked) in the compute(info) function. The variable was used in the onUpdate() function as well. It seems that on the faster 945 the onUpdate() function executed before the compute() function could assign a value to the variable. It worked fine on the simulator, which presumably has a more controlled but unrealistic execution order.

    The lesson I learned from this is to assign an initial value to every variable I declare.

  • I still getting the error "Failed invoking <symbol>", however the datafield runs well after restarting the device.  Any clues how to check what may need to look for or how to look for it?

  • Get the garmin\apps\ciq_log.yml file off the device.  If you're testing a sideload with the debug symbols, you should see an easy to read stack trace.

    If it's not a debug build, you'll have to translate the PC values in that file using the debug.xml file for that build.

  • Jim, Thank you again for your help!

    I got a garmin 1000 which only support upto 2.4.x therefore I don't get a ciq_log.yml file, only a garmin\apps\CIQ_log.txt

    And this is the error I got:

    ERROR: Unexpected Type Error
    DETAILS: Failed invoking <symbol>
    STORE_ID: 00000000000000000000000000000000
    CALLSTACK:
      C:\Users\JVC\eclipse-workspace\MTBHybrid datafield edges\source\noresourcesView.mc (onUpdate:471)
    

  • So what's going on in onUpdate at line 471?

  • This is line 471:

    dc.drawText(25,25,Gfx.FONT_TINY,avgSpeedStr.format("%.1f"), Gfx.TEXT_JUSTIFY_CENTER|Gfx.TEXT_JUSTIFY_VCENTER);

    The only variables created by myself are avgSpeedStr, which i have correct defined as:

    hidden var avgSpeedStr=0;

    and on compute()

    avgSpeedStr = 3600*avgSpeed/kmOrMileInMeters;

    hidden var kmOrMileInMeters = 1000;
    hidden var avgSpeed = 0;

  • I'm almost certain that `avgSpeedStr` is getting set to null. I haven't yet looked at your code, but every indication is pointing to that.