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

PlatformException on hot reload #514

Open JanWeidenhammer opened 1 month ago

JanWeidenhammer commented 1 month ago

Platforms

iOS

Version of flutter maplibre_gl

0.20.0

Bug Description

When hot reloading the app on a IPhone XR an Platform Exception is thrown and the Map is blank this has also happend in Production when the App runs for a long time.

Steps to Reproduce

  1. Hot reload App

Expected Results

App should restart as normal

Actual Results

throws exceptiond and shows blank Map

[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: PlatformException(recreating_view, trying to create an already created view, view id: '0', null)

0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:646:7)

1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)

#2 PlatformViewsService.initUiKitView (package:flutter/src/services/platform_views.dart:248:5) #3 _DarwinViewState._createNewUiKitView (package:flutter/src/widgets/platform_view.dart:921:36) ### Code Sample ```dart MapLibreMap( logoViewMargins: const Point(0, double.maxFinite), compassViewMargins: Point(12, Debug.debugOrAdmin ? 260 + ApplicationSizes.topPadding : 95 + ApplicationSizes.topPadding), trackCameraPosition: true, initialCameraPosition: preCamPos ?? MapManager.cameraHandler.initialCameraPosition, doubleClickZoomEnabled: true, onMapClick: (point, coordinates) { if (widget.onMapClicked != null) { widget.onMapClicked!(point, coordinates); } MapManager.instance.clearHighlightedSymbol(); FlingBoxManager.instance.close(); }, dragEnabled: true, myLocationEnabled: false, tiltGesturesEnabled: false, onMapCreated: (controller) async { Debug.map("Map Created!", force: true); await MapManager.instance.setController(controller); if (ApplicationConfig.instance.useCupertino) { final newInsets = EdgeInsets.only( bottom: useMobileLayout ? ApplicationSizes.flingboxBaseHeaderHeight : 0, left: useMobileLayout ? 0 : ApplicationSizes.flingBoxWidth, ); MapManager.instance.controller?.updateContentInsets(newInsets); } }, styleString: snapshot.data!, onStyleLoadedCallback: () { Debug.map("Style changed..."); MapManager.instance.reloadManager(); }, annotationOrder: const [ AnnotationType.circle, AnnotationType.line, AnnotationType.fill, AnnotationType.symbol, ], ) ```