maplibre / flutter-maplibre-gl

Customizable, performant and vendor-free vector and raster maps, flutter wrapper for maplibre-native and maplibre-gl-js (fork of flutter-mapbox-gl/maps)
https://pub.dev/packages/maplibre_gl
Other
185 stars 106 forks source link

[BUG] Layer Sample Disposing platform view threw an exception #445

Closed kuhnroyal closed 1 week ago

kuhnroyal commented 3 weeks ago

Platforms

android

Version of flutter maplibre_gl

main

Bug Description

Opening layer view from the sample app, changing some layers and closing the view throws.

Steps to Reproduce

  1. Run example
  2. open "Layer"
  3. Apply some changes
  4. Close view

Expected Results

It should not throw.

Actual Results

E/PlatformViewsController(32739): Disposing platform view threw an exception
E/PlatformViewsController(32739): java.lang.IllegalStateException: Calling getLayer when a newer style is loading/has loaded.
E/PlatformViewsController(32739):       at org.maplibre.android.maps.Style.validateState(Style.java:776)
E/PlatformViewsController(32739):       at org.maplibre.android.maps.Style.getLayer(Style.java:239)
E/PlatformViewsController(32739):       at org.maplibre.android.location.SymbolLocationLayerRenderer.setLayerVisibility(SymbolLocationLayerRenderer.java:248)
E/PlatformViewsController(32739):       at org.maplibre.android.location.SymbolLocationLayerRenderer.hide(SymbolLocationLayerRenderer.java:110)
E/PlatformViewsController(32739):       at org.maplibre.android.location.LocationLayerController.hide(LocationLayerController.java:143)
E/PlatformViewsController(32739):       at org.maplibre.android.location.LocationComponent.disableLocationComponent(LocationComponent.java:1243)
E/PlatformViewsController(32739):       at org.maplibre.android.location.LocationComponent.setLocationComponentEnabled(LocationComponent.java:291)
E/PlatformViewsController(32739):       at org.maplibre.maplibregl.MapLibreMapController.destroyMapViewIfNecessary(MapLibreMapController.java:1778)
E/PlatformViewsController(32739):       at org.maplibre.maplibregl.MapLibreMapController.dispose(MapLibreMapController.java:1696)
E/PlatformViewsController(32739):       at io.flutter.plugin.platform.PlatformViewsController$1.dispose(PlatformViewsController.java:238)
E/PlatformViewsController(32739):       at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.dispose(PlatformViewsChannel.java:150)
E/PlatformViewsController(32739):       at io.flutter.embedding.engine.systemchannels.PlatformViewsChannel$1.onMethodCall(PlatformViewsChannel.java:58)
E/PlatformViewsController(32739):       at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:258)
E/PlatformViewsController(32739):       at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:295)
E/PlatformViewsController(32739):       at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:322)
E/PlatformViewsController(32739):       at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
E/PlatformViewsController(32739):       at android.os.Handler.handleCallback(Handler.java:958)
E/PlatformViewsController(32739):       at android.os.Handler.dispatchMessage(Handler.java:99)
E/PlatformViewsController(32739):       at android.os.Looper.loopOnce(Looper.java:205)
E/PlatformViewsController(32739):       at android.os.Looper.loop(Looper.java:294)
E/PlatformViewsController(32739):       at android.app.ActivityThread.main(ActivityThread.java:8177)
E/PlatformViewsController(32739):       at java.lang.reflect.Method.invoke(Native Method)
E/PlatformViewsController(32739):       at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:552)
E/PlatformViewsController(32739):       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:971)

Code Sample

// Paste your code here