mapbox / mapbox-maps-flutter

Interactive, thoroughly customizable maps for Flutter powered by Mapbox Maps SDK
https://www.mapbox.com/mobile-maps-sdk
Other
284 stars 117 forks source link

No implementation found for method subscribeToEvents #657

Open favazHF opened 2 months ago

favazHF commented 2 months ago

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?

Wiwo99 commented 2 months ago

i have same problem!

PuntitOwO commented 1 month ago

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 🤔

vitorDevop commented 1 month ago

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.

HighSoftWare96 commented 1 month ago

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

vitorDevop commented 1 month ago

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:

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 commented 1 month ago

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

mhammerc commented 1 month ago

Hello, same problem here.

lukaskurz commented 3 weeks ago

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

evil159 commented 3 weeks ago

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 commented 3 weeks ago

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.

ciakov commented 3 weeks ago

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

favazHF commented 2 weeks ago

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

evil159 commented 2 weeks ago

@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.

mauro-forest commented 1 week ago

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