DataField - System Error - Failed to Invoke <symbol> on Initialize

I am getting a System Error when trying to createField on initialize (to add FIT contributor). Error only happens on some devices (like Fenix7) 
Error: System Error
Details: 'Failed invoking <symbol>'
Time: 2022-05-19T14:38:19Z
Part-Number: 006-B3907-00
Firmware-Version: '8.21'
Language-Code: eng
ConnectIQ-Version: 4.0.10
Filename: C5I65603
 
The stack trace indicates the error is happening on the first createField  call.
 function initialize(dataField) {
        try {
            mCurrentInclineField = dataField.createField("inclineRunn", INCLINE_FIELD_ID, FitContributor.DATA_TYPE_FLOAT, { :nativeNum=>NATIVE_NUM_FIT_RECORD_GRADE, :mesgType=>FitContributor.MESG_TYPE_RECORD, :units=>"%" });
            mTotalAscentLapField = dataField.createField("total_ascent", TOTAL_ASCENT_LAP_FIELD , FitContributor.DATA_TYPE_FLOAT, { :nativeNum=>NATIVE_NUM_FIT_LAP_TOTAL_ASCENT , :mesgType=>FitContributor.MESG_TYPE_LAP, :units=>"m" });
            mTotalAscentSessionField = dataField.createField("total_ascent", TOTAL_ASCENT_SESSION_FIELD , FitContributor.DATA_TYPE_FLOAT, {:nativeNum=>NATIVE_NUM_FIT_SESSION_TOTAL_ASCENT, :mesgType=>FitContributor.MESG_TYPE_SESSION, :units=>"m" });
            mTotalDescentLapField = dataField.createField("total_descent", TOTAL_DESCENT_LAP_FIELD , FitContributor.DATA_TYPE_FLOAT, { :nativeNum=>NATIVE_NUM_FIT_LAP_TOTAL_DESCENT , :mesgType=>FitContributor.MESG_TYPE_LAP, :units=>"m" });
            mTotalDescentSessionField = dataField.createField("total_descent", TOTAL_DESCENT_SESSION_FIELD , FitContributor.DATA_TYPE_FLOAT, { :nativeNum=>NATIVE_NUM_FIT_SESSION_TOTAL_DESCENT, :mesgType=>FitContributor.MESG_TYPE_SESSION, :units=>"m" });
    
            mTotalDistanceLapField = dataField.createField("total_distance", TOTAL_DISTANCE_LAP_FIELD , FitContributor.DATA_TYPE_FLOAT, { :nativeNum=>NATIVE_NUM_FIT_LAP_TOTAL_DISTANCE , :mesgType=>FitContributor.MESG_TYPE_LAP, :units=>"m" });
            mTotalDistanceSessionField = dataField.createField("total_distance", TOTAL_DISTANCE_SESSION_FIELD , FitContributor.DATA_TYPE_FLOAT, { :nativeNum=>NATIVE_NUM_FIT_SESSION_TOTAL_DISTANCE, :mesgType=>FitContributor.MESG_TYPE_SESSION, :units=>"m" });
            mCurrentInclineField.setData(0);
            mTotalAscentLapField.setData(0);
            mTotalAscentSessionField.setData(0);
            mTotalAscentLapField.setData(0);
            mTotalAscentSessionField.setData(0);
            mTotalDescentSessionField.setData(0);
            mTotalDescentLapField.setData(0);
        }
        catch(exception) {
             System.println("FIT Init Exception " + exception);
        }

    }
Runs fine in the emulator for all devices. 
Anyone have any ideas?


Top Replies

  • However, in ERA I see a lot of "System Error" issues for other users. But what is really strange - these errors point not to the first line with FIT field creation but to the field…
  • On watches where you can only have 2 CIQ DFs in an activity, if every DF used less than 1/2 of the possible fields, that would be a work around. 

    Not to state the obvious, but that only works…

All Replies

  • Maybe it's something with the initialization. I'm using strict typing. If i declare in the class

    private var _fitRecording as FitContributor.Field;

    the compiler complains

    ERROR: edge1030plus: Unknown:-1: Member '_fitRecording' not initialized but does not accept Null.

    But how to initialize the var?

  • No, I have the same code, and it works for 11000 downloads, only failed 2 days ago on venu 4 times. I'm pretty sure it's some local glitch in the venu. And The strict compiler would only give you compile time errors, that doesn't really change the code it produces.

    _fitRecording should be ok as long as it gets a value in initialize()

  • And The strict compiler would only give you compile time errors, that doesn't really change the code it produces.

    I can't emphasize this enough. I'm seeing some posts along the lines of "this runtime error should be impossible if I use strict typing". Type checking, if used correctly, prevents certain kinds of runtime type errors -- it's not a magic bullet for avoiding runtime errors, and if used incorrectly (i.e. with excessive type casts), it can actually lead to a false sense of security.

    Maybe it's something with the initialization. I'm using strict typing. If i declare in the class

    private var _fitRecording as FitContributor.Field;

    the compiler complains

    ERROR: edge1030plus: Unknown:-1: Member '_fitRecording' not initialized but does not accept Null.

    But how to initialize the var?

    (edited to expand above quote for clarity)

    You would have to declare the type as FitContributor.Field or Null. But then, in order to make your code work with strict typing, you would have to either:

    1) Add "if (_fitRecording != null)" checks everywhere you use _fitRecording, which adds to the memory footprint of your code. Maybe not a problem with most newer devices that have lots of memory, but possibly an issue for older devices or any semi-new device that still has 32 KB for data fields.

    or

    2) Cast to _fitRecording to FitContributor.Field everywhere you use it, which actually detracts from type safety and defeats the purpose of type checking.

  • Bot are unnecessary because he sets _fitRecording in initialize.

  • Bot are unnecessary because he sets _fitRecording in initialize.

    I was specifically responding to this:

    Maybe it's something with the initialization. I'm using strict typing. If i declare in the class

    private var _fitRecording as FitContributor.Field;

    the compiler complains

    ERROR: edge1030plus: Unknown:-1: Member '_fitRecording' not initialized but does not accept Null.

    But how to initialize the var?

    My point is if you want to declare the type of _fitRecording, then you have to declare it as Field or Null. And if you declare it as Field or Null, then you need null checks or type casts.

    (And if you're using strict type checking, then you have to declare the type of member variables, IIRC.)

  • No you don't have to, in fact it's better not to if you can. Just initialize the variable in the constructor.

  • (And if you're using strict type checking, then you have to declare the type of member variables, IIRC.)

    No you don't have to, in fact it's better not to if you can. Just initialize the variable in the constructor.

    So you're telling me that if I enable strict type checking in the compiler (-L 3), and I have the following code...

    class Foo {
      var bar;
    }

    ...I don't get the following error?

    Member '$.Foo.bar' is untyped.

    Note that I am not saying it is necessary to enable strict type checking. I am saying that if you choose to enable strict type checking, then you have to declare the type of member variables.

  • You're mixing some comments IMHO. I'm talking about this one:

    class Foo extends DataField {
        private var _fitRecording as FitContributor.Field;
        function initialize() {
            _fitRecording = createField(...)

    then you don't have to check for null in every place you use it, and you don't have to cast it to Field everywhere you use it, because both are already taken care of. And it works with -l 3.

  • You're mixing some comments IMHO. I'm talking about this one:

    class Foo extends DataField {
        private var _fitRecording as FitContributor.Field;
        function initialize() {
            _fitRecording = createField(...)

    then you don't have to check for null in every place you use it, and you don't have to cast it to Field everywhere you use it, because both are already taken care of. And it works with -l 3.

    You're right -- it works when you initialize a strongly typed member variable in the initialize() function. Sorry, my bad. I assumed it wouldn't work based on CYBERMAN54's comment.

    Maybe it's something with the initialization. I'm using strict typing. If i declare in the class

    private var _fitRecording as FitContributor.Field;

    the compiler complains

    ERROR: edge1030plus: Unknown:-1: Member '_fitRecording' not initialized but does not accept Null.

    But how to initialize the var?