Strange crashes on Edge datafields lately

After many weeks of no ERA reports, I have now received several messages for data fields for 2 weeks - only on Edge 1040 and 1050 devices. All of them refer to the initial loading - or rather “not loading” of variables. I know that with data fields “onCompute” and “onUpdate” do not necessarily work synchronously - or rather - in a continuous sequence. But since the last software updates of both devices, there are suddenly problems.
-With System.getDeviceSettings() screenHeight is only successfully queried in the second run. However, since this variable is already required in the first run of onUpdate, this leads to problems there.
-The same with the loading of consumer fonts. This leads to crashes with dc.drawText because the font is only loaded in the second second.
None of this has been a problem so far. The code has not changed.
Now I have to come up with security routines to avoid the crashes.
Has anyone else noticed anything like this?

(the consumer font crashes do occure only on few devices. They are not reproducable on my devices… and do not happen on the simulator)

(on my devices I was able to reproduce the „too late reading“ of screenHeight. It also does not happen on the simulator)

  • The second issue I described is based on ERA crash report and I cannot reproduce the issue on my device. It happens rarely, but only on Edge 1040 and 1050:

    I load a custom font in initialize (whithout crash):

    ie:  ( one more time, I cannot insert code...)

    function initialize() {
    DataField.initialize();

    mySettings = System.getDeviceSettings();
    distEinheit = mySettings.distanceUnits; // metric = 0 / statute = 1
    hoeEinheit = mySettings.elevationUnits; // metric = 0 / statute = 1
    timeEinheit = mySettings.is24Hour; // true...24h / false ...12h // ist oben initialisiert!
    scrWidth = mySettings.screenWidth;
    scrHeight = mySettings.screenHeight;

    if ( scrWidth == 480 ) {            // Edge 1050
       myFont = WatchUi.loadResource(Rez.Fonts.id_font_myFont5);
       myArrows = WatchUi.loadResource(Rez.Fonts.id_font_myArrows5);
    } else if ( scrWidth == 282 ) {            // Edge 1040
       myFont = WatchUi.loadResource(Rez.Fonts.id_font_myFont);
       myArrows = WatchUi.loadResource(Rez.Fonts.id_font_myArrows);
    }

    Cannot continue due to forum software problems...
    see next post

  • But on the first use of "myFont" in onUpdate, ERA reports a crash:

    3235:      dc.drawText(fieldWidth - 40*fx, 209*fx, myFont, curPo.format("%0d"), textCenter);  
    fieldWidth, fx, curPo and textCenter cannot be the culprit. These values are used before this line without crash.

    And - besides - this works since many month and occurs only rarely on some devices.
    I cannot reproduce it, neither on simulator nor on my devices...
    ERA says:
    Error Name: Symbol Not Found Error
    Occurrences: 2
    First Occurrence: 2024-12-20
    Last Occurrence: 2024-12-21
    Devices:
    Edge® 1050: 11.24
    App Versions: 1.2.8
    Languages: chs, por
    Backtrace:
    EdgeAllinOne1View.onUpdate:3235
  • On the first run of onUpdate() the value hi (which should be 1/4 of screenHeight) stays 0, because scrHeight = mySettings.screenHeight stays 0.

    Interesting. Is there a need to call getDeviceSettings() on every onUpdate() just to get the screenHeight and screenWidth?

    Ofc it seems that with this bug (or unexpected behavior), it might be necessary. But in a perfect world, it shouldn't be.

    What happens if you only call getDeviceSettings() in your AppBase-derived class's initialize() or your View class's initialize?

    I wonder if getDeviceSettings() is returning 0 for screenHeight when it's called during the scrolling of a data page? I mean, that wouldn't make sense, but I guess it's a possible explanation.

    I would try to create a very simple example to reproduce this specific issue on a real device, and file a bug report with the code.

    All it should do is demonstrate that screenHeight (and maybe screenWidth) are 0, for some call of getDeviceSettings().

  • Why do you use the screenheight and not the dc.getHeight()?

  • I don't use dc.getHeight() because my data field is split into 4 graphs with height/4. If a user uses a wrong field layout, my data field would look squashed and overwrite labels. If I use screenHeight, the top part is visible and ok, if a user intentionally uses 1/2 layout, he would see 2 graphs correctly.

  • I see. If that's the case, then in theory you could have a constant with the screen height, width.

    Of course it's a bit work to set it up... I generate my monkey.jungle and these device specific constants with a python script, using the JSON files in the SDK Devices directories...

  • I see. If that's the case, then in theory you could have a constant with the screen height, width.

    For newer devices (which support Personality UI) this is available via Rez.Styles:

    Rez.Styles.system_size__screen.width
    Rez.Styles.system_size__screen.height

    Rez.Styles.device_info also has other useful constants, which can be seen in the personality.mss file, in the relevant device folder.

    e.g. ConnectIQ\devices\fr955\personality.mss

    device_info {
        hasTouchScreen: true;
        hasNightMode: false;
        hasEnhancedReadabilityMode: false;
        hasGpu: true;
        screenWidth: 260;
        screenHeight: 260;
        screenShape: Toybox.System.SCREEN_SHAPE_ROUND;
    }
    
    system_size__screen {
        width: 260;
        height: 260;
    }
    

    It's too bad this stuff doesn't seem to be formally documented anywhere, unless I'm mistaken. (You can see the values and types in bin\...\Rez.mir after you build an app.)