Skip to content

[maps] MissingPluginException when calling methods on maps instance that has been torn down on the native side #43785

Closed
flutter/packages
#9242

Description

@rafaelsimonassi

Hello, I am experiencing this error below, whenever I use the google map.

Also, please find below the flutter doctor -v output as well.

E/BufferQueueProducer(12362): [SurfaceTexture-0-12362-4] queueBuffer: BufferQueue has been abandoned
E/BufferQueueProducer(12362): [SurfaceTexture-0-12362-4] dequeueBuffer: BufferQueue has been abandoned
E/flutter (12362): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: MissingPluginException(No implementation found for method map#update on channel plugins.flutter.io/google_maps_4)
E/flutter (12362): #0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)
E/flutter (12362): <asynchronous suspension>
E/flutter (12362): #1      GoogleMapController._updateMapOptions (package:google_maps_flutter/src/controller.dart:96:19)
E/flutter (12362): <asynchronous suspension>
E/flutter (12362): #2      _GoogleMapState._updateOptions (package:google_maps_flutter/src/google_map.dart:256:16)
E/flutter (12362): <asynchronous suspension>
E/flutter (12362): #3      _GoogleMapState.didUpdateWidget (package:google_maps_flutter/src/google_map.dart:241:5)
E/flutter (12362): #4      StatefulElement.update (package:flutter/src/widgets/framework.dart:4103:58)
E/flutter (12362): #5      Element.updateChild (package:flutter/src/widgets/framework.dart:2893:15)
E/flutter (12362): #6      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3961:16)
E/flutter (12362): #7      Element.rebuild (package:flutter/src/widgets/framework.dart:3738:5)
E/flutter (12362): #8      ProxyElement.update (package:flutter/src/widgets/framework.dart:4254:5)
E/flutter (12362): #9      Element.updateChild (package:flutter/src/widgets/framework.dart:2893:15)
E/flutter (12362): #10     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3961:16)
E/flutter (12362): #11     Element.rebuild (package:flutter/src/widgets/framework.dart:3738:5)
E/flutter (12362): #12     ProxyElement.update (package:flutter/src/widgets/framework.dart:4254:5)
E/flutter (12362): #13     Element.updateChild (package:flutter/src/widgets/framework.dart:2893:15)
E/flutter (12362): #14     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4852:32)
E/flutter (12362): #15     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5243:17)
E/flutter (12362): #16     Element.updateChild (package:flutter/src/widgets/framework.dart:2893:15)
E/flutter (12362): #17     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3961:16)
E/flutter (12362): #18     Element.rebuild (package:flutter/src/widgets/framework.dart:3738:5)
E/flutter (12362): #19     StatefulElement.update (package:flutter/src/widgets/framework.dart:4120:5)
E/flutter (12362): #20     Element.updateChild (package:flutter/src/widgets/framework.dart:2893:15)
E/flutter (12362): #21     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3961:16)
E/flutter (12362): #22     Element.rebuild (package:flutter/src/widgets/framework.dart:3738:5)
E/flutter (12362): #23     ProxyElement.update (package:flutter/src/widgets/framework.dart:4254:5)
E/flutter (12362): #24     Element.updateChild (package:flutter/src/widgets/framework.dart:2893:15)
E/flutter (12362): #25     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3961:16)
E/flutter (12362): #26     Element.rebuild (package:flutter/src/widgets/framework.dart:3738:5)
E/flutter (12362): #27     StatefulElement.update (package:flutter/src/widgets/framework.dart:4120:5)
E/flutter (12362): #28     Element.updateChild (package:flutter/src/widgets/framework.dart:2893:15)
E/flutter (12362): #29     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5134:14)
E/flutter (12362): #30     Element.updateChild (package:flutter/src/widgets/framework.dart:2893:15)
E/flutter (12362): #31     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3961:16)
E/flutter (12362): #32     Element.rebuild (package:flutter/src/widgets/framework.dart:3738:5)
E/flutter (12362): #33     StatelessElement.update (package:flutter/src/widgets/framework.dart:4016:5)
E/flutter (12362): #34     Element.updateChild (package:flutter/src/widgets/framework.dart:2893:15)
E/flutter (12362): #35     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:5134:14)
E/flutter (12362): #36     Element.updateChild (package:flutter/src/widgets/framework.dart:2893:15)
E/flutter (12362): #37     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3961:16)
E/flutter (12362): #38     Element.rebuild (package:flutter/src/widgets/framework.dart:3738:5)
E/flutter (12362): #39     StatefulElement.update (package:flutter/src/widgets/framework.dart:4120:5)
E/flutter (12362): #40     Element.updateChild (package:flutter/src/widgets/framework.dart:2893:15)
E/flutter (12362): #41     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3961:16)
E/flutter (12362): #42     Element.rebuild (package:flutter/src/widgets/framework.dart:3738:5)
E/flutter (12362): #43     StatefulElement.update (package:flutter/src/widgets/framework.dart:4120:5)
E/flutter (12362): #44     Element.updateChild (package:
E/flutter (12362): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)]
[√] Flutter (Channel stable, v1.9.1+hotfix.2, on Microsoft Windows [versão 10.0.18362.418], locale pt-BR)
    • Flutter version 1.9.1+hotfix.2 at c:\src\flutter
    • Framework revision 2d2a1ffec9 (8 weeks ago), 2019-09-06 18:39:49 -0700
    • Engine revision b863200c37
    • Dart version 2.5.0


[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at C:\Users\rafas\AppData\Local\Android\sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-29, build-tools 29.0.2
    • Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
    • All Android licenses accepted.

[√] Android Studio (version 3.5)
    • Android Studio at C:\Program Files\Android\Android Studio
    • Flutter plugin version 39.0.3
    • Dart plugin version 191.8423
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)

[!] Connected device
    ! No devices available

! Doctor found issues in 1 category.

Activity

  1. ThinkDigitalSoftware commented on Oct 30, 2019

    @ThinkDigitalSoftware
    Contributor

    Have you tried stopping the app and rebuilding it after adding the dependency?

  2. rafaelsimonassi commented on Oct 30, 2019

    @rafaelsimonassi
    Author
  3. BondarenkoStas commented on Oct 30, 2019

    @BondarenkoStas

    @rafaelsimonassi I probably miss something, but I wonder, why is there plugins.flutter.io/google_maps_4 not just plugins.flutter.io/google_maps?
    Does it work normally when you don't add multiple markers?

  4. added
    p: mapsGoogle Maps plugin
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 30, 2019
  5. rafaelsimonassi commented on Oct 30, 2019

    @rafaelsimonassi
    Author
  6. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Oct 30, 2019
  7. JBBx2016 commented on Oct 30, 2019

    @JBBx2016
    Contributor

    I get this too whenever the build function that holds GoogleMap fails. It seems that it causes the map to be removed, and then recreated (with the red error printout). Is there any chance any errors are thrown during build?

  8. KlausJokisuo commented on Nov 20, 2019

    @KlausJokisuo

    To investigate the issue we would need a minimal runnable reproduction as a single file 👍

  9. SalilLuley commented on Dec 19, 2019

    @SalilLuley

    What to do in this case? I am getting this error
    Unhandled Exception: MissingPluginException(No implementation found for method map#update on channel plugins.flutter.io/google_maps_1)

  10. vimalmistry commented on Jan 1, 2020

    @vimalmistry

    Same issue. Any solution found??
    plugins.flutter.io/google_maps_0

  11. KlausJokisuo commented on Jan 1, 2020

    @KlausJokisuo

    What to do in this case? I am getting this error
    Unhandled Exception: MissingPluginException(No implementation found for method map#update on channel plugins.flutter.io/google_maps_1)

    Can you provide us a minimal runnable reproduction as a single file?

  12. klaszlo8207 commented on Jan 6, 2020

    @klaszlo8207
    Non-fatal Exception: java.lang.Exception: MissingPluginException(No implementation found for method camera#move on channel plugins.flutter.io/google_maps_1)
           at MethodChannel.invokeMethod(platform_channel.dart:319)
           at GoogleMapController.moveCamera(controller.dart:175)
           at MapMarkerHelper.jumpToMarker.<fn>(map_marker_helper.dart:133)
    
    

    Hmm, I got a lot of error reporting on this too, in my firebase crashlitycs. But the app not crashing...

    my 133 row:

        Utils.doAfterMilliseconds(50, () {
    133->      _googleMapController.moveCamera(CameraUpdate.newCameraPosition(CameraPosition(
    
    
  13. KlausJokisuo commented on Jan 7, 2020

    @KlausJokisuo
    Non-fatal Exception: java.lang.Exception: MissingPluginException(No implementation found for method camera#move on channel plugins.flutter.io/google_maps_1)
           at MethodChannel.invokeMethod(platform_channel.dart:319)
           at GoogleMapController.moveCamera(controller.dart:175)
           at MapMarkerHelper.jumpToMarker.<fn>(map_marker_helper.dart:133)
    

    Hmm, I got a lot of error reporting on this too, in my firebase crashlitycs. But the app not crashing...

    my 133 row:

        Utils.doAfterMilliseconds(50, () {
    133->      _googleMapController.moveCamera(CameraUpdate.newCameraPosition(CameraPosition(
    

    Can you provide us a minimal runnable reproduction as a single file?

  14. 93 remaining items

  15. stuartmorgan-g commented on May 5, 2025

    @stuartmorgan-g
    Contributor

    I'm saying that there are two potential ways of getting this exception:

    1. Code within the plugin that itself does async things without verifying that the instance still exists
    2. Code that is written by clients of the plugin, which assume that it can unconditionally use a map controller even after the widget and controller have been disposed.

    Any instances of 1 are a valid bug in the plugin, and should be fixed by silently dropping whatever the call is. Any instances of 2 are bugs in the client code.

    Re-reading, it looks like you want to try to make the experience of 2 better, whereas I was thinking about actually fixing 1. For client code, if we want to make the error more explicit, 3 seems like the best option, except that it would be an Error type, not an Exception type, because it's a programming error. I'm not sure what you mean by "a lot of boilerplate around every method call"; could you elaborate on that part?

  16. filiph commented on May 5, 2025

    @filiph
    Contributor

    Thanks for the clarification.

    Yes, I was referring to the second way to get the exception, since it's what most of the commenters on this thread seem to be reporting. It seems you prefer to address the first way instead? That's valid, of course. It would be helpful to know what you think as a maintainer:

    1. Is this issue fixed when both ways are addressed? Only the first one?
    2. Should this issue be split in two?
    3. If I'm to address the first way to get the exception, where do I start? Is there perhaps another (linked) issue that has a stacktrace with way 1?
    4. Or is this a theoretical exception at this point and we want to make sure it never happens in the future by way of defensive coding.

    I'm not sure what you mean by "a lot of boilerplate around every method call"; could you elaborate on that part?

    I was referring to try-catch blocks around every call, or some app state that tracks disposal of the controller (since afaik there is no field or getter on the controller to check whether the instance has been disposed). So, for example:

    final cameraLocation = await controller.getLatLng(screen);

    becomes

    if (controllerDisposed) return;
    final cameraLocation = await _controller.getLatLng(screen);

    Admittedly not a lot of boilerplate in this case, but in more complex cases where we can't just return, it could mean more code than that.

  17. stuartmorgan-g commented on May 5, 2025

    @stuartmorgan-g
    Contributor

    I was referring to try-catch blocks around every call

    There's no scenario where clients should be writing try/catch to handle calling into a disposed object; they should not be making the call in the first place. We would not throw exceptions intentionally, because it's a programming error.

    or some app state that tracks disposal of the controller (since afaik there is no field or getter on the controller to check whether the instance has been disposed).

    I'm not sure I follow. The only way to call a disposed controller would be to have a long-lived controller reference. Why would the client solution not be to simply null out that reference when the controller is disposed? I don't see why additional state would be required.

  18. stuartmorgan-g commented on May 5, 2025

    @stuartmorgan-g
    Contributor
    1. Is this issue fixed when both ways are addressed? Only the first one?
    2. Should this issue be split in two?
    3. If I'm to address the first way to get the exception, where do I start? Is there perhaps another (linked) issue that has a stacktrace with way 1?
    4. Or is this a theoretical exception at this point and we want to make sure it never happens in the future by way of defensive coding.

    If we don't actually have any instances of current errors within the plugin, we can treat this as just covering improving the client error. I may have just misread a stack during triage and thought we did have a plugin error somewhere.

  19. filiph commented on May 6, 2025

    @filiph
    Contributor

    I'm not sure I follow. The only way to call a disposed controller would be to have a long-lived controller reference. Why would the client solution not be to simply null out that reference when the controller is disposed? I don't see why additional state would be required.

    You're right. I thought maybe the client might want to distinguish between controller being null because it hasn't been assigned to yet, and between controller being null because it's been disposed. But I think we can safely assume that all other callbacks (like onCameraMove) will always be called after onMapCreated, so I can't imagine a scenario where this distinction would be useful. Apologies for over-complicating this.

  20. JamesMcIntosh commented on May 8, 2025

    @JamesMcIntosh

    @stuartmorgan-g Looking back at the stack trace for the original issue, it stems from a didUpdateWidget, inside this method there are many calls to update the map using the controller.

      void didUpdateWidget(GoogleMap oldWidget) {
        super.didUpdateWidget(oldWidget);
        _updateOptions();
        _updateClusterManagers();
    ...
      }
    

    Each of these methods follow this pattern

      Future<void> _updateX() async {
        final GoogleMapController controller = await _controller.future;
        unawaited(controller._doSomething()));
      }
    

    Each time there is awaiting for the GoogleMapController it opens the door for the map instance to have been disposed before the controller method is called.

    There should be a mounted check before calling the controller method and I'll also recommend to lookup and reuse the controller by passing it into these update methods.

    I have tested and verified that this is the problem by adding logging to didUpdateWidget and dispose.

    For me this error occurs very often on the web version of our Flutter app as it is easy to switch pages while the map is still initializing.

    I'm just added a PR now to address this - #9227

  21. JamesMcIntosh commented on May 8, 2025

    @JamesMcIntosh

    This is the one of the exceptions caused when the controller has been disposed when calling didUpdateWidget.
    The stack can be any of the update methods inside didUpdateWidget.

    UnknownMapIDError
    Unknown map ID 0
    google_maps_flutter_ios.dart in GoogleMapsFlutterIOS._hostApi at line 73 within google_maps_flutter_ios
    google_maps_flutter_ios.dart in GoogleMapsFlutterIOS.updatePolygons at line 248 within google_maps_flutter_ios
    controller.dart in GoogleMapController._updatePolygons at line 144 within google_maps_flutter
    google_map.dart in _GoogleMapState._updatePolygons at line 477 within google_maps_flutter
    

    This is the other exception which I observed where the controller is looked up after the GoogleMapsController.init future completes and calls _updateTileOverlays

    Assertion failed: file:///Users/james/.pub-cache/hosted/pub.dev/google_maps_flutter_web-0.5.12/lib/src/google_maps_flutter_web.dart:32:12
    controller != null
    "Maps cannot be retrieved before calling buildView!"
    dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 307:3  throw_
    dart-sdk/lib/_internal/js_dev_runtime/private/profile.dart 117:39            assertFailed
    packages/google_maps_flutter_web/src/google_maps_flutter_web.dart 32:22      [_map]
    packages/google_maps_flutter_web/src/google_maps_flutter_web.dart 107:17     <fn>
    dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 622:19          <fn>
    dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 647:23          <fn>
    dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 541:3           _asyncStartSync
    packages/google_maps_flutter_web/src/google_maps_flutter_web.dart 103:16     updateTileOverlays
    packages/google_maps_flutter/src/controller.dart 188:10                      [_updateTileOverlays]
    packages/google_maps_flutter/src/google_map.dart 519:25                      <fn>
    ...
    
    Future<void> onPlatformViewCreated(int id) async {
        final GoogleMapController controller = await GoogleMapController.init(
          id,
          widget.initialCameraPosition,
          this,
        );
        _controller.complete(controller);
        unawaited(_updateTileOverlays());
    
  22. filiph commented on May 12, 2025

    @filiph
    Contributor

    I'm just added a PR now to address this - #9227

    Was this link perhaps garbled? It links to an issue that seems unrelated at first glance.

  23. JamesMcIntosh commented on May 12, 2025

    @JamesMcIntosh

    I'm just added a PR now to address this - #9227

    Was this link perhaps garbled? It links to an issue that seems unrelated at first glance.

    I've fixed up the link as the PR is in the packages repository

    flutter/packages#9227

  24. github-actions commented on Nov 18, 2025

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  25. locked as resolved and limited conversation to collaborators on Nov 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: crashStack traces logged to the consolecustomer: crowdAffects or could affect many people, though not necessarily a specific customer.p: mapsGoogle Maps pluginpackageflutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions