Skip to content

Drop proxy binary messenger#715

Merged
maios merged 23 commits intomainfrom
MAPSFLT-213_drop-proxy-binary-messenger
Oct 18, 2024
Merged

Drop proxy binary messenger#715
maios merged 23 commits intomainfrom
MAPSFLT-213_drop-proxy-binary-messenger

Conversation

@maios
Copy link
Copy Markdown
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.

maios added 7 commits October 2, 2024 16:29
- 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
Copy Markdown
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.

Comment thread lib/src/snapshotter/snapshotter.dart Outdated
Comment thread lib/src/map_widget.dart Outdated
Comment thread lib/src/map_events.dart Outdated
Comment thread lib/src/annotation/polyline_annotation_manager.dart Outdated
Comment thread lib/src/annotation/annotation_manager.dart Outdated
Comment thread lib/src/offline/tile_store.dart
Comment thread android/src/main/kotlin/com/mapbox/maps/mapbox_maps/EventHandler.kt Outdated
Comment thread lib/src/mapbox_maps_platform.dart
style = StyleManager(binaryMessenger: messenger);
_mapEvents = _MapEvents(binaryMessenger: messenger);
_snapshotterMessenger =
_SnapshotterMessenger(messageChannelSuffix: _suffix.toString());
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread lib/src/map_events.dart Outdated
_MapEvents({BinaryMessenger? binaryMessenger}) {
_channel = MethodChannel('com.mapbox.maps.flutter.map_events',
const StandardMethodCodec(), binaryMessenger);
_MapEvents({BinaryMessenger? binaryMessenger, String channelSuffix = ''}) {
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

Comment thread lib/src/annotation/annotation_manager.dart Outdated
Comment thread lib/src/mapbox_maps_platform.dart Outdated
evil159
evil159 previously approved these changes Oct 18, 2024
Copy link
Copy Markdown
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
Copy Markdown
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
@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