mapbox / mapbox-gl-native-android

Interactive, thoroughly customizable maps in native Android powered by vector tiles and OpenGL
https://mapbox.com/mobile
Other
218 stars 116 forks source link

Use weak references for Layer and Source API #234

Open tobrun opened 5 years ago

tobrun commented 5 years ago

Follow up from https://github.com/mapbox/mapbox-gl-native/issues/15333#issuecomment-525209827, current Android codebase uses references for Layer and Source API's. This is an issue as we aren't able to determine if a source/layer is still valid. We are currently working around this by flagging (boolean) if a source/layer is detached. With the weak reference setup we can check the weak reference itself to determine if that component is still valid.

cc @mapbox/maps-android @pozdnyakov @alexshalamov

tobrun commented 5 years ago

In code this refers to sources here and layers here

tobrun commented 5 years ago

An example of to determine if a source/layer is still valid is when a underlying style is reloaded but the user still holds a reference to an old source/layer.