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

  • I tried a modified version of CYBERMAN54's code and it compiles fine with strict type checking, so I'm not sure where the "not initialized" error message is coming from:

    class TestView extends WatchUi.SimpleDataField {
        var _fitRecording as FitContributor.Field;
        public function initialize() {
            SimpleDataField.initialize();
    
            label = "Forumslader";
    
            getUserSettings();
    
            // Create the custom FIT data field we want to record
            _fitRecording = createField(
                "Forumslader", 0, FitContributor.DATA_TYPE_FLOAT,
                {:mesgType=>FitContributor.MESG_TYPE_RECORD, :units=>"FL"}
            ) as Field;
    
            _fitRecording.setData(0.0);
        }
    
        function getUserSettings() as Void {
        }
    }

  • I think you wrote a comment about try/catch but then you deleted it? (I see it in my email, but not in the forum)

    Anyway, that might explain the problem: if you have foo = createField(..) inside a try block then the compiler might think it's possible an exception is being thrown before the foo is given a value. 

  • I think you wrote a comment about try/catch but then you deleted it? (I see it in my email, but not in the forum)

    Anyway, that might explain the problem: if you have foo = createField(..) inside a try block then the compiler might think it's possible an exception is being thrown before the foo is given a value. 

    Yeah I edited it because OP's code has try/catch but CYBERMAN54's doesn't. I also mentioned that createField() doesn't throw an exception (as per the documentation), and system errors can't be caught, so try/catch should be unnecessary anyway.

    Just to rehash it, the following code compiles with strict type checking.

    class Foo {
      var bar as Number;

      function initialize() {
        bar = 42;
      }
    }

    And this code doesn't.

    class Foo {
      var bar as Number;

      function initialize() {
        try {
          bar = 42;
        } catch (e) {
        }
      }
    }

  • If i try to declare but not initialize

    class ForumsladerView extends WatchUi.SimpleDataField {
    private var _fitRecording as FitContributor.Field;
    ...
    this does not compile under strict typing:
    ERROR: edge1030plus: Unknown:-1: Member '_fitRecording' not initialized but does not accept Null.
     
  • If i try to declare but not initialize

    class ForumsladerView extends WatchUi.SimpleDataField {
    private var _fitRecording as FitContributor.Field;
    ...
    this does not compile under strict typing:
    ERROR: edge1030plus: Unknown:-1: Member '_fitRecording' not initialized but does not accept Null.

    As discussed you can either initialize member variables directly (as part of the declaration) or in unconditional code within the class's initialize() function, which you have done in the code you previously posted here.

    Do you have a different version of your code which is producing this error? (Can you reproduce this problem with a simpler, self-contained version of your code which we can try directly?)

  • Indeed i had a conditional around the initialization inside the initialize function. Took this out, now it compiles.

    Thus, back to the root problem, that createField crashes during runtime with the symbol error. I still found no solution. It's crazy...

  • Indeed i had a conditional around the initialization inside the initialize function. Took this out, now it compiles.

    That's good, it proves that strict type checking is working is exactly as intended (in this case). If there was any chance that the member variable was not initialized, then you would've been forced to add "or Null" to the type declaration, in order to use strict type checking.

  • I've added -l 3 option and still everything is ok.

    I think a bug can be in another place in your code, check getUserSettings()

  • I've tried to reproduce problems here and have had no luck.

    If you still have test code that you're using to produce this error, please send the source and instructions to reproduce to [email protected].