Mapbox-gl-native: [iOS] Mapbox continuously asks for permission to access location on first launch.

Created on 16 Feb 2018  路  8Comments  路  Source: mapbox/mapbox-gl-native

Platform: iOS (only on Device not in Simulator)
Mapbox SDK version: 3.7.4

Steps to trigger behavior

  1. Configure the App to support MapBox and set NSLocationWhenInUseUsageDescription and NSLocationAlwaysUsageDescription in its Info.plist.
  2. Instantiate a new MGLMapView.
  3. Set showsUserLocation to true.

Expected behavior

When a user opens the map the first time I want the popup Allow "AppName" to access your location? to appear exactly once.

Actual behavior

When a user opens the map the first time the popup Allow "AppName" to access your location? appears in an infinite loop and I cannot tap any button like Only While Using the App, Always Allows or Don't Allow. The popup is visible for about 1 second and then reappears.

Workaround

Downgrading to version 3.7.3 solves the issue on our devices.

Screenshot

2018-02-16 22 10 58

bug iOS

Most helpful comment

Fixed by #11229, which is now available in Mapbox Maps SDK for iOS 3.7.5. Thanks again for reporting this issue and helping us fix it, @rweindl. 馃檱

All 8 comments

A few questions:

  • Which iOS version(s) are you seeing this on?
  • Which are you specifying: NSLocationAlwaysUsageDescription or NSLocationAlwaysAndWhenInUseUsageDescription? Both?
  • Does the app a separate CLLocationManager that could be requesting permission?

Hi @friedbunny thanks for taking such a quick look on that issue. To your questions:

  • iOS Version is 11.2.5.
  • Device is iPhone 6s / iPhone 7 and iPhone 8.
  • Both NSLocationAlwaysUsageDescription and NSLocationAlwaysAndWhenInUseUsageDescription are specified.
  • App is not using another CLLocationManager. The App also uses Firebase SDK which might use CLLocationManager in their SDK but this is only a hypothesis.

@rweindl Hrm, so I can鈥檛 reproduce this 鈥斅爊either by enabling showsUserLocation in viewDidLoad nor in a storyboard, with any combination of usage descriptions.

Oh, and if you have a test app that you can share that鈥檇 be greatly appreciated. 馃檱

I can reproduce this with the Mapbox Studio Preview app.

giphy 1

Hi @friedbunny I created a small test project for you illustrating this behavior. The only dependency is Mapbox 3.7.4. One note: The home button seems no longer to work as soon this behavior starts.

Execution:

  1. pod install
  2. Set MGLMapboxAccessToken in the Info.plist
  3. Select a Developer Team to deploy on device.
  4. Build on Device.

Zip File of the Test project:

MapBoxCrash.zip

Screenshot:

2018-02-16 23 06 14

Thanks for your help @rweindl and @captainbarbosa 鈥斅爐his is happening because #11151 re-added a listener for UIApplicationWillResignActiveNotification in 3.7.4.

After a bit of preliminary digging, it looks like this is the sequence of events leading to the loop:

  • The app gets UIApplicationWillResignActiveNotification when the permission dialog appears.
  • We catch the notification and call sleepGL:, which disables location services.
  • The dialog disappears, because location services have been disabled and the permissions request effectively cancelled.
  • With the dialog gone, the app gets UIApplicationDidBecomeActiveNotification and calls wakeGL:, which re-enables location services and asks for permission.

The quick fix would be to just remove the listener for UIApplicationWillResignActiveNotification (which we鈥檝e evidently judged to be unnecessary in the past: https://github.com/mapbox/mapbox-gl-native/pull/2988), but perhaps we should also reevaluate wakeGL:/sleepGL:.

/cc @julianrex @1ec5 @akitchen @lilykaiser

Thanks for identifying the issue that quickly and keeping us in the loop! We're using 3.7.3 in the meantime.

Fixed by #11229, which is now available in Mapbox Maps SDK for iOS 3.7.5. Thanks again for reporting this issue and helping us fix it, @rweindl. 馃檱

Was this page helpful?
0 / 5 - 0 ratings