josxha / flutter-maplibre

Permissive and performant mapping library that supports Mapbox Vector Tiles (MVT) powered by MapLibre SDKs.
https://flutter-maplibre.pages.dev
Other
17 stars 3 forks source link

[BUG] JNI exceptions in console when having a lot of rebuilds or controller calls at once #136

Open josxha opened 3 days ago

josxha commented 3 days ago

Platforms

Android

Version of flutter-maplibre

0.1.2

Bug Description

When rebuilding the MapLibreMap widget a lot in a short amount of times the console shows JNI related exceptions.

E/flutter (26853): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Use after release error
E/flutter (26853): #0      JReference.pointer (package:jni/src/jreference.dart:56:21)
E/flutter (26853): #1      MapLibreMap.moveCamera (package:maplibre/src/native/jni/org/maplibre/android/maps/MapLibreMap.dart:5280:27)
E/flutter (26853): #2      MapLibreMapStateJni.moveCamera.<anonymous closure> (package:maplibre/src/native/widget_state_jni.dart:221:14)
E/flutter (26853): #3      _platformIsolateMain.<anonymous closure> (dart:ui/platform_isolate.dart:142:51)
E/flutter (26853): #4      _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (26853): 

When hot restarting the app, another exception gets logged in the console:

E/flutter (26880): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformIsolate shutdown unexpectedly

Steps to Reproduce

Using the MapLibreLayer in flutter_map_maplibre, see bug report here: https://github.com/josxha/flutter_map_plugins/issues/54

Expected Results

Don't throw any exceptions

Actual Results

Exceptions in the console and future calls are partly unresponsive.

Code Sample

// Paste your code here