mapbox-maps-flutter icon indicating copy to clipboard operation
mapbox-maps-flutter copied to clipboard

No implementation found for method subscribeToEvents

Open favazHF opened this issue 1 year ago • 11 comments

Error:

Crash MethodChannel._invokeMethod package:flutter/src/services/platform_channel.dart:332 MissingPluginException(No implementation found for method subscribeToEvents on channel com.mapbox.maps.flutter.map_events)

Devices: Android and iOS

Mapbox version: mapbox_maps_flutter: ^2.1.0

I have been getting these reports to our error tracker, what can it be or how can it be solved?

favazHF avatar Aug 19 '24 15:08 favazHF

i have same problem!

Wiwo99 avatar Aug 30 '24 08:08 Wiwo99

I was able to find an invocation in map_events.dart:L58 And it is supposed to handle it in EventHandler.kt:L60 So, for some reason that condition is false 🤔

PuntitOwO avatar Sep 10 '24 19:09 PuntitOwO

The issue occurs with the latest version of the package (mapbox_maps_flutter: ^2.2.1).

Attempted Workarounds:

The error is thrown inside the Flutter code of the package, not the Android native code. I initially tried commenting out the result.notImplemented() line in the EventHandler class of the Android source code, but this did not resolve the issue. Here is the relevant code snippet:
EventHandler.kt Line 72.

I then tried temporarily resolving the issue by commenting out the line that throws a MissingPluginException() in the Flutter source code, but this did not work either. Here is the relevant code snippet:
map_events.dart Line 72.

I also added a try-catch block around this line, but it didn't work:
map_events.dart Line 57.

Suspected Cause:

I suspect the issue might be related to lifecycle handling when resuming the app, possibly inside the following file:
MapboxMapController.kt.

However, the same issue also occurs on iOS, suggesting it might not be limited to Android's lifecycle management.

Would appreciate any guidance on a more permanent fix or if there’s an update planned to address this.

vitorDevop avatar Sep 21 '24 08:09 vitorDevop

Same exception here (Android and library at 2.3.0-rc.1).. Anything on this? Which version is not affected?

gbertoncelli avatar Sep 27 '24 15:09 gbertoncelli

I've tested the issue with the latest Flutter versions (3.24.0 and 3.24.3), and the problem persists. Below are the versions of the mapbox_maps_flutter package I tested:

  • 2.2.0
  • 2.2.1
  • 2.1.0
  • 2.0.0

It's worth noting that version 0.5.1 of the package worked correctly without this issue when using Flutter 3.7.11. This suggests that the problem may be related to changes introduced in newer versions of the package or Flutter SDK.

Could you please look into this, or provide any guidance on potential workarounds?

vitorDevop avatar Sep 27 '24 16:09 vitorDevop

The package version 1.1.0 worked, but I had to modify the MapboxMapController.kt file to resolve lifecycle errors,

vitorDevop avatar Sep 28 '24 15:09 vitorDevop

Hello, same problem here.

mhammerc avatar Sep 30 '24 14:09 mhammerc

We are also experiencing this issue in our sentry logs from multiple devices, multiple OS

lukaskurz avatar Oct 07 '24 14:10 lukaskurz

Hi all, thank you for reporting this and sorry for the inconvenience, has anybody been able to reproduce it? A piece of sample code would be much appreciated 🙏

evil159 avatar Oct 09 '24 14:10 evil159

I looked into this and so far my theory is that platform view might take a while get up and running, and during this time the channels are not hooked up, so if we will try to send event subscription update request then - we get an exception that nobody has answered the call.

I made a draft PR for this https://github.com/mapbox/mapbox-maps-flutter/pull/724 if somebody wants to try it out.

evil159 avatar Oct 09 '24 15:10 evil159

I have made some tests and the porblem looks that it is resolved.

ciakov avatar Oct 10 '24 09:10 ciakov

@evil159 Do you think this solution will be released soon? the metrics of the error handlers are affected by this crash.

favazHF avatar Oct 16 '24 17:10 favazHF

@favazHF @ciakov Thank you for confirming the fix. It is scheduled for release in version 2.4.0, with the beta expected to be available later this week.

evil159 avatar Oct 17 '24 06:10 evil159

We have tried this fix in production with real users and the issue is gone. Thank you @evil159!

mauro-forest avatar Oct 24 '24 20:10 mauro-forest