Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop proxy binary messenger #715

Merged
merged 23 commits into from
Oct 18, 2024
Merged

Conversation

maios
Copy link
Contributor

@maios maios commented Oct 2, 2024

What does this pull request do?

Drop ProxyBinaryMessenger, instead, setup channel with a messageChannelSuffix which is now supported by Pigeon

What is the motivation and context behind this change?

Pull request checklist:

  • Add a changelog entry.
  • Write tests for all new functionality. If tests were not written, please explain why.
  • Add documentation comments for any added or updated public APIs.

- Adopt Pigeon message channel suffix instead of own custom proxy binary messenger
per teardown annotations controller with suffix
@maios maios force-pushed the MAPSFLT-213_drop-proxy-binary-messenger branch from f2ff4b7 to 593a58a Compare October 10, 2024 09:52
@maios maios changed the title Mapsflt 213 drop proxy binary messenger Drop proxy binary messenger Oct 10, 2024
@maios maios marked this pull request as ready for review October 10, 2024 10:28
@maios maios requested review from a team as code owners October 10, 2024 10:28
@maios maios requested a review from evil159 October 10, 2024 10:28
Copy link
Contributor

@evil159 evil159 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There some aspects to improve, mainly when it comes to multi-instance scenarios, but looking good overall.

lib/src/snapshotter/snapshotter.dart Outdated Show resolved Hide resolved
lib/src/map_widget.dart Outdated Show resolved Hide resolved
lib/src/map_events.dart Outdated Show resolved Hide resolved
lib/src/annotation/polyline_annotation_manager.dart Outdated Show resolved Hide resolved
lib/src/annotation/annotation_manager.dart Outdated Show resolved Hide resolved
lib/src/offline/tile_store.dart Outdated Show resolved Hide resolved
lib/src/mapbox_maps_platform.dart Show resolved Hide resolved
style = StyleManager(binaryMessenger: messenger);
_mapEvents = _MapEvents(binaryMessenger: messenger);
_snapshotterMessenger =
_SnapshotterMessenger(messageChannelSuffix: _suffix.toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed a pattern where binary messenger is specified explicitly, for consistency it should be specified here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it is necessary, as stated by the doc, so we can leave it as optional null

The [binaryMessenger] named argument is available for dependency injection. If it is left null, the default BinaryMessenger will be used which routes to the host platform.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not having it works for me as well, as long as it is consistent through the code base.
Currently, we still have binaryMessenger parameter specified in some places.

_MapEvents({BinaryMessenger? binaryMessenger}) {
_channel = MethodChannel('com.mapbox.maps.flutter.map_events',
const StandardMethodCodec(), binaryMessenger);
_MapEvents({BinaryMessenger? binaryMessenger, String channelSuffix = ''}) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally binary messenger should be a required parameter as well, since in all other places binary messenger is specified explicitly, having it as a requirement will help with consistency.

Comment on lines -73 to +58
arguments: args,
channelSuffix: args["channelSuffix"] as? Int ?? 0,
registrar: registrar,
pluginVersion: pluginVersion,
eventTypes: eventTypes
pluginVersion: args["mapboxPluginVersion"] as? String ?? "",
eventTypes: args["eventTypes"] as? [Int] ?? []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What will happen if these fallback values (0, "", []) are used?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's the same as before 😅 this one is only clean up the code a bit

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good 😄

@maios maios requested a review from a team as a code owner October 17, 2024 13:31
@maios maios requested a review from evil159 October 17, 2024 13:31
pjleonard37
pjleonard37 previously approved these changes Oct 17, 2024
Copy link
Contributor

@pjleonard37 pjleonard37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good from my side. I think ready to go once we get @evil159 's approval

Copy link
Contributor

@evil159 evil159 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@maios thank you for addressing the feedback. I think we are almost there, I have left a couple of nits(in my opinion the binary messenger parameter should be removed), and I noticed there is one method channel in _MapboxMapsPlatform lacking the channel suffix.
Otherwise, it's looking very good!

P.S. This is an internal change, but its impact is broad. Should we note it in the changelog?

style = StyleManager(binaryMessenger: messenger);
_mapEvents = _MapEvents(binaryMessenger: messenger);
_snapshotterMessenger =
_SnapshotterMessenger(messageChannelSuffix: _suffix.toString());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not having it works for me as well, as long as it is consistent through the code base.
Currently, we still have binaryMessenger parameter specified in some places.

lib/src/annotation/annotation_manager.dart Outdated Show resolved Hide resolved
lib/src/mapbox_maps_platform.dart Outdated Show resolved Hide resolved
evil159
evil159 previously approved these changes Oct 18, 2024
Copy link
Contributor

@evil159 evil159 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nicely done!

@pjleonard37
Copy link
Contributor

@maios -- I think the build-android job is failing because of this unresolved reference to $messageChannel.

https://github.com/mapbox/mapbox-maps-flutter/pull/715/files#diff-f72e4d76e69116de99f71b5e16fe8b73874d764869c822e44a81453325f7234dR100

Should this be $channelSuffix?

@maios maios merged commit de83e5b into main Oct 18, 2024
6 checks passed
@maios maios deleted the MAPSFLT-213_drop-proxy-binary-messenger branch October 18, 2024 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants