Strange error: Simulator and real device behaviour not the same

I am getting an “Unhandled Exception” error occurring on four different device types – 18 times in the last 2 weeks from 300+ downloads of the HRV analysis app. The same line of code in every case which is reading an app property. Now you would have thought this would be easy to debug but this error never happens in the simulator on any device and has never happened on my own device.

The property exists, the key is the same in all uses. The only difference from other calls to Properties.getValue in the same function is that this one is not also a setting.

<properties>

…snip

      <property id="MaxTimerTimeSet" type="number">600</property>

…snip

</properties>

On initialisation one of the functions calls a storageHandler function which reads a long list of properties and settings …

Variable = $._mApp.Properties.getValue("MaxTimerTimeSet").toNumber();

In reality, I could now use a CONST to set this value as the code structure has evolved.

In the simulator I have tried deleting all apps and all data and run the app a number of times. No error happens.

Any suggestions gratefully received.

  • Which devices?  getValue is only available on devices with 2.4.0 or greater

  • Hi Jim,

    I have set the minimum CIQ version to 3.0 and also have a has :Storage test before calling the applicable function for that type of property access. The devices are fēnix® 5X Plus: 11.00,  MARQTm Expedition: 9.00, Forerunner® 245: 4.40 and
    Forerunner® 245 Music: 4.40 .

    Also the other calls to getValue in the function all work fine.

    Regards,

    David

  • I'm betting it's something with the .set file.  In the sim, have you tried changing app settings while it's running.

    Since it has no associated setting, why not use Storage? (comment out the property in the xml and set a default if it's null when you read it)  Or put it in a try/catch and set a default if there's an exception.

  • Hi Jim,

    Thanks for the suggestions. Storage would make sense but for the moment I've set it to a constant. I also added a try/catch previously but it was never triggered in my testing. It's also strange that it's infrequent, random and always the same line of code. I was beginning to think it might be a memory issue on a few devices.

    I'll try updating settings in the simulator on the release and will report back if anything happens.

    Regards,
    David

  • Hi,

    I fixed the code and released it into the wild. I am now seeing another property read in another part of the code giving unhandled exception errors. Could this be some form of memory corruption and if so how do I track it down!

    This error is happening in some of the initialisation code where a property is read to change start-up behaviour.

    Regards

    David

  • Maybe not corruption, but the amount of memory needed.  Are these properties with associated settings? How many total properties?

    You can try putting the calls to Application.Properties in try/catch blocks, and if there is an exception, provide a default in the catch.

  • Hi,

    There are 35 properties. Again the property causing an error was not also a setting. I suspect you'll say make it a storage variable but I would then need to add a try/catch to initialise it correctly. This is part of the trial mode handling code I created so needs to have the default value on first load of the programme.

    I'll add try/catch/finish blocks around all property handling to see if that resolves the issue and any others!

    Regards,

    David

    PS I also had another weird error on real devices where a popview failed with unknown symbol in a menu onDone(). 

  • So you're not using Application.Storage.getValue(), but Application.getApp().getProperty() and there's no property in the xml?  That would put it in the ObjectStore.

    See the new developer FAQ wiki.  There's a function there called readKeyInt that handles having a default for a value.  It was done before Application.Storage or Application.Properties so there's no try/catch.

    I've only seen unhandled exceptions with Appliction.Properties, and then only when a key doesn't exist.

  • Hi,

    Second attempt as I got logged out and lost reply..

    Property is defined in XML as:

    <property id="pTrialMode" type="boolean">false</property>

    I didn't want to use storage as it would have to then be initialised on first ever run which would need another property...

    The property is the read using getValue or getProperty depending on object/storage type

    mTrialMode = $._mApp.Properties.getValue("pTrialMode");  // this is failing type of read

    What bugs me is that this is an infrequent failure ie most of the time it works as it is called every time the app starts.

    Regards,

    David

  • You want your app to be consistent and use Application.Properties OR Application.getApp().getPropery().  I can see where mixing them could cause something odd.  More so with Storage or the objectStore.

    Like I said, it's easy to have a default in your code for something in Storage/the objectStore.

    Generally, you don't want to have a property in the xml unless there's an associated setting, IMHO