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
228 stars 125 forks source link

[BUG] Adding an existing source causes app to crash #512

Open albertmoravec opened 1 month ago

albertmoravec commented 1 month ago

Platforms

iOS

Version of flutter maplibre_gl

0.20.0

Bug Description

Calling controller.addSource() more than once for the same source causes app crash on iOS with MLNRedundantSourceIdentifierException.

Steps to Reproduce

  1. Call controller.addSource('123', VectorSourceProperties(...)).
  2. Call controller.addSource('123', VectorSourceProperties(...)) again with the same ID.

Expected Results

Exception should be returned.

Actual Results

App completely crashes with MLNRedundantSourceIdentifierException, not providing any option to handle the exception.

Code Sample

await controller.addSource('123', VectorSourceProperties());
await controller.addSource('123', VectorSourceProperties());
albertmoravec commented 1 month ago

Not sure if this can be fixed from Swift side, so I opened an issue on MapLibre Native.

danieljosua1 commented 1 month ago

@albertmoravec I’ve also run into this issue multiple times – the same problem also occurs on Android

Rossdex commented 1 month ago

This was also an issue on the mapbox version of this plugin, any platform exceptions cause a full on app crash.

The solution I have been working with is to keep track of which layers you have added to your map in a provider and remove the layer and re-add with the new data. It's not ideal but it works and the performance hit isn't huge.