Complete
over 4 years ago

Nonsensical ERA report : Vivoactive 4

Hi,

Although this might be related to : Sensor.setEnabledSensors exception on Venu, Vivoactive 4 - Connect IQ Bug Reports - Connect IQ - Garmin Forums 

I think it is a separate issue!

Over the past three or four days, I have been seeing several ERA reports along the lines of this one:

Error Name: Symbol Not Found Error
Occurrences: 12
First Occurrence: 2020-11-26
Last Occurrence: 2020-11-26
Devices:
    vívoactive® 4: 5.10
App Versions: 0.0.45
Languages: fre
Backtrace:

The line number is a conditional where I check sub-sport based on Activity enumerators: 

function checkEnabledSensors() {
		var subSport = collectSportInfo()[1];
	    var needsGps = storeData;
	    if(	subSport == ActivityRecording.SUB_SPORT_CARDIO_TRAINING || // @@ CRASH ON THIS LINE @@
			subSport == ActivityRecording.SUB_SPORT_INDOOR_CYCLING || 
			subSport == ActivityRecording.SUB_SPORT_SPIN ||
			subSport == ActivityRecording.SUB_SPORT_TREADMILL) {
			needsGps = false;
		}    
        if(needsGps) {		Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));		}
		try {
			//https://forums.garmin.com/developer/connect-iq/i/bug-reports/sensor-setenabledsensors-exception-on-venu-vivoactive-4
			if(Sensor has :enableSensorType) {
				Sensor.enableSensorType(Sensor.SENSOR_HEARTRATE);
				Sensor.enableSensorType(Sensor.SENSOR_BIKECADENCE);
				Sensor.enableSensorType(Sensor.SENSOR_BIKEPOWER);
				Sensor.enableSensorType(Sensor.SENSOR_FOOTPOD);
			} else {
				Sensor.setEnabledSensors([Sensor.SENSOR_HEARTRATE,Sensor.SENSOR_BIKECADENCE,Sensor.SENSOR_BIKEPOWER,Sensor.SENSOR_FOOTPOD]);
			}
		} catch(e) {}
    }

So far, I have only seen it on French devices, and only on Vivoactive 4. However, I share this method across two or three apps, and I have observed a similar bug in each of them. 

As you can see, I have already significantly safety checked my "checkEnabledSensors" method as per the previous bug report. 

I can see no way for this to be failing, and certainly no way for it to be failing on that specific line.

G

  • Sport / subsport is simply a setting - integer selected by user from a list. 

  • Hello, .  Would you mind giving us the code for the collectSportInfo() function or telling us how you determined the subSport? 

  • (With the "return sensors" replaced with "return out" obviously - can't seem to edit posts on this thread for some reason.

  • How's this for hyper paranoid:

    function collectSensors() {
    		var sensors = [:SENSOR_HEARTRATE,:SENSOR_BIKESPEED,:SENSOR_BIKECADENCE,:SENSOR_BIKEPOWER,:SENSOR_FOOTPOD];
    		var out = [];
    		var i,len = sensors.size();
    		for(i=0;i<len;i++) {
    			if(Sensor has sensors[i]) {		out.add(Sensor[sensors[i]]);		}
    		}
    		return sensors;
    	}
        function checkEnabledSensors() {
    		var subSport = collectSportInfo()[1];
    	    var needsGps = storeData;
    		if(	subSport == 26 ||  //ActivityRecording.SUB_SPORT_CARDIO_TRAINING ||
    			subSport == 6 || //ActivityRecording.SUB_SPORT_INDOOR_CYCLING || 
    			subSport == 5 || //ActivityRecording.SUB_SPORT_SPIN ||
    			subSport == 1 || //ActivityRecording.SUB_SPORT_TREADMILL) {
    			needsGps = false;
    		}    
            if(needsGps) {		Position.enableLocationEvents(Position.LOCATION_CONTINUOUS, method(:onPosition));		}
    		try {
    			//https://forums.garmin.com/developer/connect-iq/i/bug-reports/sensor-setenabledsensors-exception-on-venu-vivoactive-4
    			var sensors = collectSensors(), len = sensors.size();	
    			if(Sensor has :enableSensorType) {
    				for(var i=0;i<len;i++) {			Sensor.enableSensorType(sensors[i]);	}
    			} else {
    				Sensor.setEnabledSensors(sensors);
    			}
    		} catch(e) {}
        }
        function disableSensors() {
            Position.enableLocationEvents(Position.LOCATION_DISABLE, method(:onPosition));
    		try {
    			//https://forums.garmin.com/developer/connect-iq/i/bug-reports/sensor-setenabledsensors-exception-on-venu-vivoactive-4
    			if(Sensor has :disableSensorType) {
    				var sensors = collectSensors(), len = sensors.size();	
    				for(var i=0;i<len;i++) {			Sensor.enableSensorType(sensors[i]);	}
    			} else {
    				Sensor.setEnabledSensors([]);
    			}
    		} catch(e) {}
    	}

  • Yes, but they are all ActivityRecording.SUB_SPORT_* constants.

    I'm going to add a hyper paranoid check in case.