[TIMOB-11334] iOS: Geolocation - Crash on app launch
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-10-17T23:23:16.000+0000 |
Affected Version/s | Release 3.0.0 |
Fix Version/s | Release 3.0.0, Release 3.1.0, 2012 Sprint 21 API, 2012 Sprint 21 |
Components | iOS |
Labels | ios, module_geolocation, qe-ios100112, qe-testadded, regression |
Reporter | Olga Romero |
Assignee | Sabil Rahim |
Created | 2012-10-09T23:09:16.000+0000 |
Updated | 2012-10-17T23:23:16.000+0000 |
Description
While testing Geolocation Module I noticed crash on launch on *ios 5.1 - 5.1.1* with console [ERROR] The application has crashed with an uncaught exception 'NSRangeException'.
*It is a regression, does not occur on 2.1.3*
Test steps:
1. Run this code below
var win = Titanium.UI.createWindow({
backgroundColor:'#fff',
exitOnClose: true
})
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;
}
win.open();
2. The log returns ERROR] The application has crashed with an uncaught exception 'NSRangeException'.
Reason:
*** -[__NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array
Attachments
File | Date | Size |
---|---|---|
Crash.crash | 2012-10-09T23:09:16.000+0000 | 31459 |
Mea Culpa. PR pending..https://github.com/appcelerator/titanium_mobile/pull/3145
Verified fix with: Titanium Studio, build: 3.0.0.201210151149 Titanium Studio SDK, build3.0.0.v20121017102440 Devices: iPhone5 ios 6.0 iPad2 ios 5.1 Closing the bug.