Random Array Out Of Bounds Error in sensor data callback

Former Member
Former Member
Hello,

i have an issue i am unable to debug...

I have implemented a b2b recorder that is part of an CIQ3 App i am working on.
In general my App works as i want it to but sometimes the App crashes randomly and i have no idea why.

Log and code follows...
  • Former Member
    Former Member over 6 years ago
    Ok! So now i see what i wanted to know, that if an error appears in my prosessBBI(BBIarray) function, then i will see it in the stack in my error log as above!


    So the only peace of code left in onSensorData is

    function onSensorData(sensorData){


    var BBI = sensorData.heartRateData.heartBeatIntervals;

    if( BBI != null){

    prosessBBI(BBI);

    }

    }





  • Former Member
    Former Member over 6 years ago
    And it still randomly crashes. I also tried it on several watches with the same result.


    So as i understand it right the only place where the error can pop up is var BBI = sensorData.heartRateData.heartBeatIntervals;



    Any other idea?


    Thanks for the support!


    Mike


  • It can be any time you reference BBI or hrvDataArray It doesn't need to be in onSensorData.

    How big is your array getting? Could you be running out of memory or objects?
  • Former Member
    Former Member over 6 years ago
    The array is not getting bigger than about maximum 10 entries. Arrays are written in a fit file every second with max 5 entries and then initialized with
    empty array like hrvDataArray = new [0]; after all that data is stored in the fit file. So it does not grow endless. It gets bigger than 5 sometimes but in most cases it is the same size as the arrays that come out of the sensor. I also check for max size of 5 bevore writing into fit to avoid the to big for allocated space error and split in sub arrays but this works fine.

    Is there a way to debug this one layer deeper somehow?
    Why in this case it does not show in stack where the error is?
  • Does this occur in the sim or only on a watch?

    On a watch you could add Sys.println() calls to help narrow things down. You just have to create a <your sideload name>.txt file is apps\logs
  • Former Member
    Former Member over 6 years ago
    Could not manage the app to crash in simulator. But on the watch yes.

    What do you mean by sideload name?

    If i can println in the textfile as in simulator and console this could definitely help.

  • What do you mean by sideload name?


    He means the filename of the app (without the ".PRG" extension). If you copied the app to the watch manually ("sideloading") using the cable then this is probably the name of your project. If you used the store to install the app, then it's a generated sequence of letters and numbers, in which case you could look at GarminDevice.xml to see the mapping from your app to the filename, or inspect the contents of the PRGs in APPS\ (your app name will be in there), or just look to see which one was most recently modified.

  • Former Member
    Former Member over 6 years ago
    Ok, got it! I am using the cable. Thanks for the very quick replies!
  • Former Member
    Former Member over 6 years ago
    So, i did as you said, printed my array states on any interesting position in the code.

    Everything seems fine, array look good and the code runs until random crash in sensor data callback!

    As this drove me nuts, i implemented a Test App that does nothing more than init sensor on App start:

    Sensor.unregisterSensorDataListener();

    var options = {

    :heartBeatIntervals => {:enabled => true},

    :period => 1

    };

    Sensor.registerSensorDataListener(method(:onSensorData), options);



    and then

    function onSensorData(sensorData){

    var BBI = sensorData.heartRateData.heartBeatIntervals;
    }



    without any further processing on the BBI array and after about half an half an hour running it crashes with same error message!

    Error: Array Out Of Bounds Error
    Details: Error in sensor data callback
    Time: 2018-11-02T22:03:14Z
    Part-Number: 006-B2888-00
    Firmware-Version: '4.00'
    Language-Code: deu
    ConnectIQ-Version: 3.0.4
    Filename: XXX
    Appname: XXX
    Stack:


    As i do not get any more information about what is happening inside garmins sensor read functions i have no idea what to do anymore at this point!
  • I wish I had seen this earlier. I found and fixed this issue last weekend. I *think* the fix should go out with the 3.0.5 release, but I'm not certain about that. It is an issue in the VM, so it will exist on devices until they pull in the fix.