[TIMOB-28275] iOS: RemovingEventListener in Location event will freeze App
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2021-05-18T18:27:27.000+0000 |
Affected Version/s | n/a |
Fix Version/s | Release 10.0.0, Release 9.3.3 |
Components | iOS |
Labels | geolocation, iOS |
Reporter | Michael Gangolf |
Assignee | Vijay Singh |
Created | 2020-11-20T12:57:43.000+0000 |
Updated | 2021-05-18T18:27:31.000+0000 |
Description
When removing the location event inside the event itself the app will freeze:
var win = Ti.UI.createWindow({
backgroundColor: '#fff'
});
function geoL(e) {
Ti.Geolocation.removeEventListener('location', geoL);
alert("after remove");
}
var btn = Ti.UI.createButton({
title: 'Test'
});
btn.addEventListener('click', () => {
Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE, event => {
if (!event.success) {
alert('No permissions');
return;
}
Ti.Geolocation.addEventListener('location', geoL);
});
});
win.add(btn);
win.open();
Tested with 8.3.1.GA and 9.2.2.GA
It looks like a threading issue e.g. in startStopLocationManagerIfNeeded
. A workaround would be
function geoL(e) {
setTimeout(() => {
Ti.Geolocation.removeEventListener('location', geoL);
}, 2000);
alert("after remove");
}
or removing it from a different event e.g. a button click.
https://github.com/appcelerator/titanium_mobile/pull/12542
FR Passed Waiting for Jenkins build
merged to master, 10_0_X and 9_3_X branches.