question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat(user-location): locationManager is not stopped on unmount

See original GitHub issue

Describe the bug I’ve noticed that within the UserLocation components method #setLocationManager locationManager is never really stopped.

https://github.com/react-native-mapbox-gl/maps/blob/9e76f32063762d43a8b8c43b1b7e8aa784f65da6/javascript/components/UserLocation.js#L128-L143

On componentWillUnmount we’re passing { running: false }, however this will simply prevent a restart of locationManager

https://github.com/react-native-mapbox-gl/maps/blob/9e76f32063762d43a8b8c43b1b7e8aa784f65da6/javascript/components/UserLocation.js#L155-L158

Not sure, however this might cause the locationManager running when the map/ userlocation is unmounted.

To Reproduce Have a MapView mount UserLocation component and unmount it again. Notice, that the GPS indicator is still visible in the devices statusbar.

Expected behavior GPS tracking/ indicator is gone once the UserLocation component is unmounted.

Screenshots na

Versions (please complete the following information):

  • Platform: OS X
  • Device: LG Q7
  • Emulator/ Simulator: no
  • OS: Android
  • SDK Version: Android 9
  • React Native Version: 7.2.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ferdicuscommented, Feb 12, 2020

I’ll try give this a chance in the coming weeks - seems like an oversight which might cause people headaches with active GPS, when they’re no longer on the map/ have no userlocation shown.

Thanks for the feedback!

0reactions
mfazekascommented, Feb 12, 2020

Ah, my bad, should’ve checked the history.

Would #dispose be an option?

Looking at native codes on ios and android there doesn’t seems to be a difference in pause and dispose.

.pause is buggy as it should be calling removeListener if it sets isListening to false

https://github.com/react-native-mapbox-gl/maps/blob/9e76f32063762d43a8b8c43b1b7e8aa784f65da6/javascript/modules/location/locationManager.js#L66-L71

Read more comments on GitHub >

github_iconTop Results From Across the Web

locationManager is not stopped on unmount · Issue #663 ...
Describe the bug I've noticed that within the UserLocation components method #setLocationManager locationManager is never really stopped.
Read more >
why self.locationManager stopUpdatingLocation doesn't stop ...
This is because stopUpdatingLocation just tells the LocationManager that your locationManager is no longer interested in location updates.
Read more >
Core Location | Apple Developer Forums
Location Stops When the App is Backgrounded after some time. I am working on an app that requires location to work in the...
Read more >
Turn working location on or off for users - Google Help
If you turn working location off, it may take up to 36 hours to remove the working location feature and delete user working...
Read more >
How to Get User Location on a Map - Swift - YouTube
Head to https://squarespace.com/seanallen to save 10% off your first purchase of a website or domain using code SEANALLEN.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found