mapbox / mapbox/mapbox-maps-android
Using LocationPuck spams with warnings, when style is changed
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 578
- Forks
- 161
- PR merge metrics
- No merged PRs in 30d
Description
## Environment
- Android OS version: 13
- Devices affected: Oneplus Nord CE 5
- Maps SDK Version: 11.1.0
When using the LocationPuck, we get warnings like this when changing the style:
```
[maps-android\Mbgl-Style]: Style object (accessing setStyleLayerProperty) should not be stored and used after MapView is destroyed or new style has been loaded.
[maps-android\Mbgl-Style]: Style object (accessing removeStyleLayer) should not be stored and used after MapView is destroyed or new style has been loaded.
```
I could narrow it down, to location, as when i disable it, it does not show the warning. It seems to be related to the LocationPuck images stored into a style, and when that style changes, it starts logging those warnings.
The warning is only logged, when the LocationPuck moves, for example when an animation is in place it logs multiple times per second.
There is a workaround, to avoid this, which also logs some warnings initially, but then stays quiet:
```
mMapView?.location?.enabled = false
mMapView?.location?.enabled = true
```
When toggling the location from enabled to disabled and back to enabled, it seems to reload the style or images or whatever, and then only the short moment it takes to disable and re-enable the location these warnings are logged. but then it is fine again.
Normally this is probably not a big issue, but for example when changing map style from day to night map, this spamming of logs happens. Not sure if that has an effect on performance, but it should nevertheless be looked into.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue by enabling LocationPuck, changing the map style, and allowing the location to move or animate. Start by tracing LocationPuck image and style handling across the style-change lifecycle. Done means style changes no longer produce repeated stale-style warnings while the LocationPuck remains enabled.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, kotlin
- Domain
- mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100