Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-28275

iOS: RemovingEventListener in Location event will freeze App

    Details

    • Story Points:
      5
    • Sprint:
      2021 Sprint 6, 2021 Sprint 10

      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.

        Attachments

          Activity

            People

            • Assignee:
              vijaysingh Vijay Singh
              Reporter:
              michael Michael Gangolf
              Reviewer:
              Christopher Williams
              Tester:
              Satyam Sekhri
            • Watchers:
              8 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Backbone Issue Sync is enabled for your project, but we do not have any synchronization info for this issue.

                  Git Integration