flutter-mapbox-gl / maps

A Mapbox GL flutter package for creating custom maps
Other
1.04k stars 503 forks source link

Fix flutter 3.x crashes #1293

Closed felix-ht closed 1 year ago

felix-ht commented 1 year ago

This finally seems to fix the crashes we were getting with version 3.x of flutter - i only tested with version 3.7.8 - but it might be fine on lower versions as well. I could also remove the delayed disposal hack.

I found this by checking the how the new offical mapbox flutter lib was doing the map onDestroy. Turns out they call the onStop before the onDestory

https://github.com/mapbox/mapbox-maps-flutter/blob/47e0ec050aac30f7052e1090a61c5a8d5295d01e/android/src/main/kotlin/com/mapbox/maps/mapbox_maps/MapboxMapController.kt#L78-L79

felix-ht commented 1 year ago

@srmanc please take a look as well

srmncnk commented 1 year ago

That's great! I'll test it out ASAP.

felix-ht commented 1 year ago

We did a partial roll out with this fix and have yet to see a crash (19 users active users today)

srmncnk commented 1 year ago

@felix-ht To me it looks good, our tests have also shown no crashes. Great work!

felix-ht commented 1 year ago

Bigger roll out - two days no more crashes seems like its gone :)

srmncnk commented 1 year ago

👏 Now let's focus on some other PRs as well. ;)

samderlust commented 1 year ago

altho this runs fine on real android device. but it throw lots of error on my android simulator PlatformException(STYLE IS NULL, The style is null. Has onStyleLoaded() already been invoked?, null, null) java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.maps.Style.addImage(java.lang.String, android.graphics.Bitmap, boolean)' on a null object reference E/MethodChannel#plugins.flutter.io/mapbox_maps_1( 5106): Failed to handle method call E/MethodChannel#plugins.flutter.io/mapbox_maps_1( 5106): java.lang.NullPointerException: Attempt to invoke virtual method 'void com.mapbox.mapboxsdk.maps.Style.addImage(java.lang.String, android.graphics.Bitmap, boolean)' on a null object reference

adityamputra27 commented 1 year ago

hello i have same problem, im still can't understand what is the solution, my current flutter version is 3.16.0-2.0.pre.20 and mapbox_gl: ^0.16.0 so, my app is still crashed when i put myLocationEnabled to true.