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

iOS: App crashes when asking for location permissions (SDK 8.1.0+)

    Details

    • Type: Bug
    • Status: Closed
    • Priority: High
    • Resolution: Fixed
    • Affects Version/s: Release 8.1.0
    • Fix Version/s: Release 8.1.0
    • Component/s: iOS
    • Labels:
      None
    • Story Points:
      3
    • Sprint:
      2019 Sprint 11, 2019 Sprint 12, 2019 Sprint 13, 2019 Sprint 14

      Description

      Our app crashes when asking for location permissions on SDK 8.1.0. The feature has not changed since a while and we noticed the crash after upgrading to latest master. Error:

      [ERROR] The application has crashed with an uncaught exception 'NSInvalidArgumentException'.
      [ERROR] Reason:
      [ERROR] -[__NSMallocBlock__ value]: unrecognized selector sent to instance 0x60000236eee0
      [ERROR] Stack trace:
      [ERROR] 0   CoreFoundation                      0x000000011403b1bb __exceptionPreprocess + 331
      [ERROR] 1   libobjc.A.dylib                     0x000000010f334735 objc_exception_throw + 48
      [ERROR] 2   CoreFoundation                      0x0000000114059f44 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
      [ERROR] 3   CoreFoundation                      0x000000011403fed6 ___forwarding___ + 1446
      [ERROR] 4   CoreFoundation                      0x0000000114041da8 _CF_forwarding_prep_0 + 120
      [ERROR] 5   Lambus                              0x00000001098366a6 __66-[GeolocationModule locationManager:didChangeAuthorizationStatus:]_block_invoke + 198
      [ERROR] 6   Lambus                              0x00000001098364ef -[GeolocationModule locationManager:didChangeAuthorizationStatus:] + 495
      [ERROR] 7   CoreLocation                        0x000000010e99dd74 CLClientStopVehicleHeadingUpdates + 71531
      [ERROR] 8   CoreLocation                        0x000000010e99da15 CLClientStopVehicleHeadingUpdates + 70668
      [ERROR] 9   CoreLocation                        0x000000010e988210 CLClientInvalidate + 1351
      [ERROR] 10  CoreFoundation                      0x0000000113fa062c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
      [ERROR] 11  CoreFoundation                      0x0000000113f9fde0 __CFRunLoopDoBlocks + 336
      [ERROR] 12  CoreFoundation                      0x0000000113f9ac2b __CFRunLoopRun + 2779
      [ERROR] 13  CoreFoundation                      0x0000000113f99e11 CFRunLoopRunSpecific + 625
      [ERROR] 14  GraphicsServices                    0x0000000118a8d1dd GSEventRunModal + 62
      [ERROR] 15  UIKitCore                           0x000000011cb0381d UIApplicationMain + 140
      [ERROR] 16  Lambus                              0x000000010967fcbc main + 988
      [ERROR] 17  libdyld.dylib                       0x0000000115c13575 start + 1
      

      Some quick research shown that the issue is in the GeolocationModule.m where the callback authorizationCallback (a JSManagedValue type) seems to be deallocated already:

          TiThreadPerformOnMainThread(^{
            NSMutableDictionary *propertiesDict = [TiUtils dictionaryWithCode:code message:errorStr];
            [propertiesDict setObject:NUMINT([CLLocationManager authorizationStatus]) forKey:@"authorizationStatus"];
            [[authorizationCallback value] callWithArguments:@[ propertiesDict ]];
          },
              YES);
      

      JS code to reproduce:

      /* eslint-disable strict */
       
      var win = Ti.UI.createWindow({
      	backgroundColor: '#fff'
      });
       
      var btn = Ti.UI.createButton({
      	title: 'Request location permissions'
      });
       
      btn.addEventListener('click', function () {
      	Ti.Geolocation.requestLocationPermissions(Ti.Geolocation.AUTHORIZATION_WHEN_IN_USE, event => {
      		alert(event);
      	});
      });
       
      win.add(btn);
      win.open();
      

      Notes:

      • We do have the NSLocationWhenInUseUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription plist keys added.
      • We do not use the UIBackgroundModes key location since we only request the location while using the app

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cwilliams Christopher Williams
                Reporter:
                hknoechel Hans Knöchel
              • Watchers:
                3 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 Source Code