Watchface crash on changing settings only in Marq Commander

I am half day scratching my head and cant figure it out.  Having watchface currently supporting F6 family and Marq Commander. So far only one Marq user experiences crash on any app setting change and nothing seems to help.

- error comes only during onsettingChange, app loading is fine
- always crashes on fist line of loadSettings function (according to ERA), which is loading first property from the list with 'Unexpected Type Error'
- this property is supposed to be a number
- developer FAQ #10 implemented
- cannot reproduce in simulator where value seems to be number in all cases
- user reports settings change is not reftlected when changes are done while watchface is not running as well, will load old settings anyway
- app uninstall/install or removing set file does not seem to change the behavior

Would someone have idea where to look at or how to exactly identify what is going wrong ?

ERA trace below:
Error Name: Unexpected Type Error
Occurrences: 2
First Occurrence: 2020-04-17
Last Occurrence: 2020-04-17
Devices:
    MARQTm Commander: 8.10
App Versions: 0.11.97
Languages: cht
Backtrace:
    GarminWatchView.loadSettings:208
    GarminWatchApp.onSettingsChanged:23

  • See the "New Developer FAQ" wiki for a possible cause.

  • My bulletpoint #4 i am trying to hande that FAQ mentioned evantuality, yet i still get error.
    in fact I dont get to the point i could test null or instance of as from my perspective it seems to crash on property read.

    Based on ERA  i am crashing on exactly this:  value = App.Properties.getValue(key);

    and i am crashing also in cases below when i am trying to force variable into various types before reading the property:
    - variable defined on that line using var (var value = App.Properties.getValue(key); )
    - variable predefined as a global   (var value;)
    - variable predefine as global as inital null (var value=null;)
    - variable predefined as global and a number (var value=1;)
    - variable defined as a local right before reading the property (tried integer, float, double and even string)

    Same function is used during app init without issue.

    I am running out of ideas what else i can try. Read some post that it may be potentially related to memory but have no clue how to test that hypotesis. Would you have another hint in your pocket ?



  • I have doubts it relates to how you declare the variable that gets the result of the getValue() call. Given that the error appears to be happening in the call, the result isn't even referenced at that point.

    You should be able to get information on memory usage with System.getSystemStats(). You might try to use System.println() logging along with an app log file to capture the memory usage just before the call to getValue().

  • I've also seen some random crashes by using App.Properties.getValue(), which didn't make sense.

    I think at that point, I moved to use App.getApp().getProperty(), which has worked reliably.

  • Thanks Travis. Did more testing and i am able to reproduce in simulator. I need to do two consecutive settings changes to force the crash in sim with same error, it crashes on first round in real watch.
    My face is also using extensive amount of user settings/properties (299 at the moment). Can this be the issue ? If yes, what could be the reason it works without problem on F6 but not on Marq ?
    Set file has size 8132 bytes.

    Reported memory in same place of code right before the crash:
    Watch face start -> Total memory: 94224 Used memory: 55400 Free memory: 38824     (app runs, with default settings)
    Settings change #1 -> Total memory: 94224 Used memory: 65424 Free memory: 28800  (app runs, no settings applied)
    Settings change #2 -> Total memory: 94224 Used memory: 51256 Free memory: 42968  (crashes on getValue() line)

    error:
    Error: Unexpected Type Error
    Details: Failed invoking <symbol>

  • I think you may have maxed out the .set file (it's limit is 8k), and some things aren't getting saved or the file gets corrupted.  This could show as random, based on the size of different properties

  • You are most probably right.  Why i did not think about it earlier ?
    I thought it is still below 8k binary, but trying now with version2 of my app with reworked settings where amount  of settings is way over 300 but file is just 4.6k i am not able to reproduce the issue anymore.

  • How did you manage to use 300 number of settings if the number of lines in strings.xml is limited to 255?

  • I am using same string for multiple settings. E.g. Position x and position y setting for each object uses same X and Y string.