mapbox / mapbox-maps-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL.
https://www.mapbox.com/mobile-maps-sdk
Other
475 stars 132 forks source link

Mapbox SDK memory leak detected! MapboxMap object (accessing getStyle) should not be stored and used after MapView is destroyed. #1715

Closed swathysreenivas closed 1 week ago

swathysreenivas commented 2 years ago

Environment

Observed behavior and steps to reproduce

Integrated map SDK and react native bridging done. Unfortunately, the app got stuck and got an error as Mapbox SDK memory leak detected!

Expected behavior

Map view with navigation should be displayed

Notes / preliminary analysis

It was working fine when placed as an initial screen. Error got when used as an inner component of another view.

Additional links and references

IsaacTrevino commented 2 years ago

Getting a similar issue,

E/Mapbox: [maps-android\Mbgl-Style]: Mapbox SDK memory leak detected! Style object (accessing setStyleLayerProperty) should not be stored and used after MapView is destroyed or a new style has been loaded.
E/Mapbox: [maps-android\Mbgl-Style]: Mapbox SDK memory leak detected! Style object (accessing styleLayerExists) should not be stored and used after MapView is destroyed or a new style has been loaded.

My guess is, styleLayer is not being destroyed along with the map

Edit:

I just realized the error goes away when I remove the UserLocation Puck. It seems that the setStyle is not disabled somehow?

ZiZasaurus commented 2 years ago

@IsaacTrevino, @swathysreenivas are you able to reproduce this issue on our most recent SDK, v10.9.0?

IsaacTrevino commented 2 years ago

@ZiZasaurus Yes, I have just finished testing it with 10.9.0 and the bug persists. Screenshot_20221024_113908_2

I have narrowed down where the call may be coming from: plugin/locationcomponent/LocationLayerWrapper.kt

kiryldz commented 1 week ago

Stale, outdated. Reproducible example will be appreciated if this is still the case with latest version of the SDK.