Complete

WERETECH-9596

Cannot Reproduce

SDK 3.2.1 vs SDK 3.1.9 Runtime Error?

Can anyone shed any light on why the code snippet below works fine on SDK 3.1.9 but fails with the error below with SDK 3.2.1.  The last line of code relates to the first error in the list.

private var heartRateZoneDisplayRatio = 0.0;

function initialize() {
    var profile = UserProfile.getProfile();
    var currentSport = profile.getCurrentSport();
    heartRateZones = profile.getHeartRateZones(currentSport);

    //work out the ratio to move the ticker for increase in 1 beat
    heartRateZoneDisplayRatio = 250 / (heartRateZones[5] - heartRateZones[0]).toFloat();
}

Error: Invalid Value
Details: Failed invoking <symbol>
Stack:
- initialize() at C:\Garmin\Git\datafields\Multi\01-BaseMulti\source\BaseMultiView.mc:9 0x10001320
- initialize() at C:\Garmin\Git\datafields\Multi\20-ConfigMulti\source\ConfigMultiView.mc:19 0x10000077
- getInitialView() at C:\Garmin\Git\datafields\Multi\20-ConfigMulti\source\ConfigMultiApp.mc:25 0x1000005e

  • I'm starting to wonder if you've got some sort of corrupt file. If anyone can reproduce this problem, could you please:

    1. close the simulator
    2. locate the %TEMP%\Garmin folder
    3. rename %TEMP%\Garmin TO %TEMP%\Garmin.bak
    4. run the test app again

    If it works, I might want to get a file or two out of that backup folder to see if I can figure out what is going on.

  • Two things.

    First, I can't reproduce the problem with the 3.2.1 or 3.2.2 SDKs. Here is my test code.

    class HeartRateZonesApp extends Application.AppBase {
    
        function initialize() {
            AppBase.initialize();
        }
    
        function onStart(state) {
            var sports = [
                UserProfile.HR_ZONE_SPORT_GENERIC,
                UserProfile.HR_ZONE_SPORT_RUNNING,
                UserProfile.HR_ZONE_SPORT_BIKING,
                UserProfile.HR_ZONE_SPORT_SWIMMING,
            ];
    
            for (var i = 0; i < sports.size(); ++i) {
                var heartRateZones = UserProfile.getHeartRateZones(sports[i]);
                System.println(heartRateZones);
            }
    
            // your code
            var profile = UserProfile.getProfile();
            var currentSport = profile.getCurrentSport();
            var heartRateZones = profile.getHeartRateZones(currentSport);
            System.println(heartRateZones);
        }
        
        // ...
    }
    

    That code generates this output in the simulator.

    [93, 111, 130, 148, 167, 185]
    [93, 111, 130, 148, 167, 185]
    [93, 111, 130, 148, 167, 185]
    [93, 111, 130, 148, 167, 185]
    [93, 111, 130, 148, 167, 185]

    The second issue is that your code is doing something weird and getting away with it. The UserProfile.Profile object returned by getProfile() is just a class with data; it has no functions. You are calling getHeartRateZones on that object.

    var heartRateZones = profile.getHeartRateZones(currentSport);

  • Thanks.  I have added code to default to sensible values if the ones returned are not for the time being.

  • I don't know. I've moved this post to the Bug Reports area.

  • Well that is the route cause.  With the latest eclipse and running the simulator I get..

    With SDK 3.2.1:

    Size of heartRateZones 6
    heartRateZones[0] 32
    heartRateZones[1] 32
    heartRateZones[5] 32

     with SDK 3.1.9:

    Size of heartRateZones 6
    heartRateZones[0] 93
    heartRateZones[1] 111
    heartRateZones[5] 185

    But why?