-
-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Labels
androidAndroid specific issueAndroid specific issuebugSomething isn't workingSomething isn't workingquestionFurther information is requestedFurther information is requested
Description
Platforms
Android
Version of flutter-maplibre
0.3.3+2
Bug Description
onStyleLoaded (and MapEventStyleLoaded) never fires on Android. The map loads visually but the callback is never invoked.
Ai was able to resolve this issue by this code change
- Missing onStyleLoaded$async = true
The JNI bridge defaults to onStyleLoaded$async = false, which attempts to call Dart synchronously from the Android main thread. Since Dart runs on a separate isolate, this is undefined behavior and silently fails.
Compare: _CameraMovementCallback correctly sets onCancel$async = true and onFinish$async = true, but _StyleLoadedCallback was missing the equivalent.
- WeakReference wrapping a method tearoff
// Before (broken)
_StyleLoadedCallback(WeakReference(onStyleLoaded))
onStyleLoaded written this way creates a temporary tearoff object with no strong holder. Dart's GC collects it almost immediately. By the time MapLibre fires the callback asynchronously (after downloading/parsing the style), weakCallback.target is null and the callback does nothing.
Steps to Reproduce
- Run on an Android device or emulator
- Wait for the map to fully render
- Observe that onStyleLoaded is never called — no print, no state update, nothing
Expected Results
It should call onStyleLoaded
Actual Results
It never call onStyleLoaded
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
androidAndroid specific issueAndroid specific issuebugSomething isn't workingSomething isn't workingquestionFurther information is requestedFurther information is requested
Projects
Status
Backlog