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

iOS: RemovingEventListener in Location event will freeze App

    Details

    • Type: Bug
    • Status: Open
    • Resolution: Unresolved
    • Affects Version/s: Release 9.2.2
    • Fix Version/s: None
    • Component/s: iOS
    • Labels:

      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
            • Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:

                Backbone Issue Sync

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

                  Git Integration