Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-8460] Android: module events not removed on app close i.e., Geolocation heading

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionInvalid
Resolution Date2017-06-09T17:00:56.000+0000
Affected Version/sRelease 2.0.0, Release 1.8.2
Fix Version/sn/a
ComponentsAndroid
Labelsqe-and031912
ReporterDustin Hyde
AssigneeEric Merriman
Created2012-03-30T14:45:37.000+0000
Updated2017-06-09T17:00:56.000+0000

Description

Module events such as Geolocation heading are not removed on app close. This is not a regression, but the behavior has changed since 1.8.2. In 1.8.2 this resulted in a crash. In 2.0.0 this results in runtime disposed log messages fired after app close. Steps to Reproduce: 1. Run code on device with geolocation support. 2. Press phone 'back' to close app.
var _window = Ti.UI.createWindow({
	backgroundColor:'green'
});

Ti.Geolocation.preferredProvider = "gps";


if(Titanium.Geolocation.locationServicesEnabled === false) {
	Titanium.UI.createAlertDialog({
		title : 'Kitchen Sink',
		message : 'Your device has geo turned off - turn it on.'
	}).show();
} else {
	if(Titanium.Platform.name != 'android') {
		var authorization = Titanium.Geolocation.locationServicesAuthorization;
		
		if(authorization == Titanium.Geolocation.AUTHORIZATION_DENIED) {
			Ti.UI.createAlertDialog({
				title : 'TIMOB_3077',
				message : 'You need to allow geolaction for this test.'
			}).show();
		} 
	}

	//
	// IF WE HAVE COMPASS GET THE HEADING
	//
	if(Titanium.Geolocation.hasCompass) {
		//
		//  TURN OFF ANNOYING COMPASS INTERFERENCE MESSAGE
		//
		Titanium.Geolocation.showCalibration = false;

		//
		// SET THE HEADING FILTER (THIS IS IN DEGREES OF ANGLE CHANGE)
		// EVENT WON'T FIRE UNLESS ANGLE CHANGE EXCEEDS THIS VALUE
		Titanium.Geolocation.headingFilter = 1;

		//
		// EVENT LISTENER FOR COMPASS EVENTS - THIS WILL FIRE REPEATEDLY (BASED ON HEADING FILTER)
		//
		var headingCallback = function(e) {

			var x = e.heading.x;
			var y = e.heading.y;
			var z = e.heading.z;
			var magneticHeading = e.heading.magneticHeading;
			var accuracy = e.heading.accuracy;
			var trueHeading = e.heading.trueHeading;
			var timestamp = e.heading.timestamp;
			
			Ti.API.debug('True heading should be less than 360 and is:' + e.heading.trueHeading);
			
			if(e.heading.trueheading >= 360) {
				alert('True heading should be less than 360 and is:' + e.heading.trueHeading);
			}
		};
		Titanium.Geolocation.addEventListener('heading', headingCallback);
		headingAdded = true;
	} else {
		Titanium.API.info("No Compass on device");
	}

	//
	//  SET ACCURACY - THE FOLLOWING VALUES ARE SUPPORTED
	//
	Titanium.Geolocation.accuracy = Titanium.Geolocation.ACCURACY_BEST;

	//
	//  SET DISTANCE FILTER.  THIS DICTATES HOW OFTEN AN EVENT FIRES BASED ON THE DISTANCE THE DEVICE MOVES
	//  THIS VALUE IS IN METERS
	//
	Titanium.Geolocation.distanceFilter = 10;

	//
	// GET CURRENT POSITION - THIS FIRES ONCE
	//
	Titanium.Geolocation.getCurrentPosition(function(e) {});
	//
	// EVENT LISTENER FOR GEO EVENTS - THIS WILL FIRE REPEATEDLY (BASED ON DISTANCE FILTER)
	//
	var locationCallback = function(e) {};
	Titanium.Geolocation.addEventListener('location', locationCallback);
	locationAdded = true;
}

_window.open();
Expected Result: No runtime disposed console logs. Actual Result: Constant stream of runtime disposed console logs.

Attachments

FileDateSize
1.8.2 sigsegv_log.txt2012-03-30T14:45:37.000+000026742
2.0.0 runtime-disposed_log.txt2012-03-30T14:45:37.000+000035950

Comments

  1. Lee Morris 2017-06-09

    Closing ticket due to time passed, any problems please open a new ticket.

JSON Source