Skip to content

getManager() in AnnotationController.kt Crashes #1059

@darshan-cygnet

Description

@darshan-cygnet

We are using the Mapbox library in our Flutter application, along with Firebase Crashlytics integration.

During app usage, we encountered a crash that appears to originate from a Mapbox library method and likely requires attention from the Mapbox team.

The crash occurs in the getManager() method while fetching the manager for PointAnnotationController. Ideally, the code should first verify whether a manager exists for the given ID before attempting to fetch it. If the manager is not found, it should return an appropriate message or handle the case gracefully instead of throwing an exception — since this crash also affects the overall stability of the application.

Problem Description
Expected Behavior (according to SDK documentation):
Annotations (markers, shapes, or other overlays) should be safely created and managed only after the Mapbox map instance is fully initialized.

Actual Behavior:
The app crashes with a RuntimeException – “No manager found” – when annotations are created before the Mapbox map is fully initialized.
The crash occurs within AnnotationController.getManager, indicating that the annotation manager is null or not yet registered.

Logs:
System logs (Logcat):

Fatal Exception: java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:614)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Caused by java.lang.reflect.InvocationTargetException:
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Caused by java.lang.Throwable: No manager found with id: 2
at com.mapbox.maps.mapbox_maps.annotation.AnnotationController.getManager(AnnotationController.kt:227)
at com.mapbox.maps.mapbox_maps.annotation.PointAnnotationController.delete(PointAnnotationController.kt:137)
at com.mapbox.maps.mapbox_maps.pigeons._PointAnnotationMessenger$Companion.setUp$lambda$15$lambda$14(PointAnnotationMessenger.kt:1483)
at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:261)
at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0(DartMessenger.java:319)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8762)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

Also, attached below are the screenshots of the code section where the crash occurs and the corresponding Crashlytics logs.

Image Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions