Unexpected exception from Application.Properties.setValue on Fenix 5X

I've just released a new watchface, and I'm getting some reports of a crash on the Fenix 5X (and possibly the same on D2 Charlie).

I've had one log file to look at so far, and the error is an unhandled exception with message: Key does not exist in Application Properties

It happens on the first line of this function:

using Application.Properties as applicationProperties;

function clearExportImportStrings()
 {
  applicationProperties.setValue("EP", "");
  applicationProperties.setValue("EF", "");
  applicationProperties.setValue("EG", "");
 }

The trouble is it works fine in the simulator and on other real watches, so I'm wondering if there is something different about the Fenix 5X which is causing this exception?

All 3 of those properties are defined in my properties.xml file as strings. Could it be because they are initialised as empty strings that that is causing it?

<property id="EP" type="string"></property>				<!-- export import profile -->
<property id="EF" type="string"></property>				<!-- export import fields 1-3 -->
<property id="EG" type="string"></property>				<!-- export import fields 4-6 -->

  • This is just a guess, but it kind of sounds like when you build for the f5x, you're not including those properties. Do you have anything in your jungles file that might cause a difference?

  • That sounds like a good guess, as if those properties are just not there somehow.

    My jungle file only has one line :-) "project.manifest = manifest.xml"

    I'm not doing any clever inclusion/exclusion tests for different devices. And I'm just using the export wizard to build all device versions at once. My minimum supported SDK version is 3.0.x

    The crash occurs just after settings are changed (from GCM on iOS) - I am trying to set the properties value during the next onUpdate(). I believe it is the first time the code tries to do a properties.setValue (on any property), and also the first time those specific properties are accessed at all (the code hasn't done a getValue on them yet).

    If those properties did not exist, then I'm guessing the user settings they are connected to would not appear in the change settings dialog either? I'll check with the users experiencing the crash whether the settings are visible.

    I can also see a slightly different code path which does a getValue on them before the setValue - so I'll see if they can test that too, and where the crash then occurs.

    If you have any more ideas or guesses please say :-)

  • Ok, next question.  How tight on memory are you?  (look at peak memory in View Memory in the sim...)  And now many properties are you using?

  • So, some more info from users:

    The D2C crash is confirmed in the same place as the Fenix 5X (got a crash log now).

    From my small sample size all the crashes are after changing settings from GCM iOS (none reported from Android so far).

    The D2C user with the crash using GCM, reports that it works fine when using the new GCIQ app instead (which is both interesting and cool!) So it seems like it could be directly related to the settings being changed - maybe a memory issue when copying the new settings over? Maybe not enough memory to copy all of them over, so some don't exist when I try and set them? Or just an issue with GCM?

    Running normally memory usage is approx 75kB (out of 92.1kB) - values from simulator of Fenix 5X

    Peak memory after startup is 78kB and <Application Settings> dictionary is 2384 (3250 or 3316 on 2nd try)

    Peak memory after sending settings (with no changes) is 85.2kB and <Application Settings> dictionary is 2384 (3316)

    There are 71 properties.

  • Running normally memory usage is approx 75kB (out of 92.1kB) - values from simulator of Fenix 5X

    Peak memory after startup is 78kB and <Application Settings> dictionary is 2384 (3250 or 3316 on 2nd try)

    Peak memory after sending settings (with no changes) is 85.2kB and <Application Settings> dictionary is 2384 (3316)

    There are 71 properties.

  • This is the watch face store link by the way if anyone wants to crash (!) it on a Fenix 5X: https://apps.garmin.com/en-US/apps/4f03053e-9ecd-4721-abca-19ca7445f0fe

    Although trying not to advertise it currently, as I am cringing for every download in case it crashes for them!

  • Just an update on this:

    I created and uploaded a test version of my watchface to the store here: https://apps.garmin.com/en-US/apps/cda199b4-9b63-47fa-9b3b-b7f1ddb02368

    I'm grateful to one of my users for testing this on his D2 Charlie watch - thanks!

    First I made a version compiled with the new CIQ SDK 3.0.11 since I saw in the notes that it mentioned: "Reduce memory required to load app settings". Unfortunately this still crashed in the same way.

    Then I made a second version which runs with approximately 10kB less memory usage - this also still crashes in the same way.

    So I'm (fairly) certain this proves it can't be a memory issue.

    It seems like it must be some issue between GCM iOS and only those 2 particular watches (D2C & F5X). No problems reported for Android, it works for other watches with GCM, and it also works with the new GCIQS app on iOS with those 2 watches.

    If I had a D2 Charlie or Fenix 5X myself I'd continue looking into it to narrow things down, but it doesn't seem fair to keep asking a user to test lots of versions, so I will make a post in the Bugs section instead now Slight smile (Edit here: ciq.forums.garmin.com/.../crash-exception-when-calling-application-properties-setvalue-for-a-key-which-exists-but-error-says-it-doesn-t)

    I'm curious about a couple of things though, if anyone with insider knowledge can say!

    - Will CIQ apps & watchfaces eventually be removed from GCM at some point? And only be available through the new GCIQ Store app?

    - What does this change "Reduce memory required to load app settings" in SDK 3.0.11 actually mean? Should the peak memory usage after sending settings be lower than with earlier SDKs? Or could it mean memory gets used differently when switching settings so there is less likely to be fragmentation?

  • What does this change "Reduce memory required to load app settings" in SDK 3.0.11 actually mean? Should the peak memory usage after sending settings

    I think It's meant to reduce the peak on send settings. I was also hopeful when I saw it mentioned but i only noticed a minimal 0.1k change. 

    I suspect you're still too high with your 10k lower... Have you already created a test version of your watch face with just all your settings and a minimal watch code (eg just the sample wf)

  • I haven't tried creating that minimal test version unfortunately. If another developer has a Fenix 5X or a D2 Charlie and is prepared to test some versions I can certainly make some builds and try some more tests - but about 10 different things come to mind to try and narrow this down. I don't want to ask a user to do more tests, when all they originally did was download the watch face, and ended up with it crashing! I'm just grateful for the feedback and help that a few users have given so far. At least there is a workaround - to use the new GCIQ Store app to send settings instead.

    To me the 10kB (out of 92kB for a watchface) sounds a lot lower - especially when it runs on all the other watches at the original value 10kB higher, and it even runs on the Fenix 5X and D2 Charlie at the original value too (but only when using the new GCIQ Store app to send the settings). Normally the watch face runs at 75kB and after sending settings the peak usage is 85kB. When it is 10kB lower, then it runs at 65kB and the peak usage after sending settings is 75kB.

    That's one thing I don't understand - why is it different when sending settings from GCM or from GCIQS? And only for those 2 watches? Is the data format different? Does GCM have special code for those 2 watches?

    So many questions Slight smile

  • That's one thing I don't understand - why is it different when sending settings from GCM or from GCIQS? And only for those 2 watches? Is the data format different? Does GCM have special code for those 2 watches?

    I suspect it could be due to what is in the settings, and not GCM vs the new Connect IQ app.  In the same way that having 10 properties will cause a lower peak than one with 50, having 10 that are boolean, will take less than 10 that are strings of varying lengths.

    Also, I suspect that the number of properties could cause an issue.  Someone posted a while back that they started having some issues with something around 100 properties, with plenty of memory.  You mentioned you had 71 properties which to be honest strikes me as really high.

    I'd do what PeterD suggested.  an ultra simple WF with your settings, but might also try something like your watchface, with say <50 properties.