-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
[pigeon] Channel name in flutter error. #5273
[pigeon] Channel name in flutter error. #5273
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I didn't think about this before: hard-coding all of these strings in the generated code will unnecessarily bloat the size of the binary, because each unique string will end up as data in the compiled output. For all languages, we should be using string interpolation so that we aren't creating N new strings constants.
And while compilers would probably handle de-duping for us if we inline them separately, it would be better not to rely on that and avoid duplicating even separate constants, so ideally we should have the generation output something like (example in Dart, but similar for the other languages):
const String channelName = "big string constant here, once";
final BasicMessageChannel<Object?> channel = BasicMessageChannel<Object?>(
channelName,
codec,
binaryMessenger: _binaryMessenger);
...
throw PlatformException(
code: 'channel-error',
message:
'Unable to establish connection on channel: "$channelName".',
);
Makes sense, I made sure to do that in the generators themselves, but I didn't even think about it for the generateds. This is also a general issue with the duplication of code in the generated files. Something that I'm hoping to tackle some day... |
245f947
to
59e32ad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with minor changes (some optional). If you want me to re-review the C++ helper change let me know.
packages/pigeon/example/app/android/app/src/main/java/io/flutter/plugins/Messages.java
Outdated
Show resolved
Hide resolved
packages/pigeon/example/app/android/app/src/main/java/io/flutter/plugins/Messages.java
Show resolved
Hide resolved
@@ -25,6 +25,13 @@ using flutter::EncodableList; | |||
using flutter::EncodableMap; | |||
using flutter::EncodableValue; | |||
|
|||
FlutterError CreateConnectionError(const std::string channel_name) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should either be static
or in a namespace { ... }
(i.e., an anonymous namespace).
75da08e
to
38a21e2
Compare
38a21e2
to
ec72ad4
Compare
flutter/packages@a682189...17bd92e 2023-11-11 [email protected] Only run tests on macOS 12 (flutter/packages#5369) 2023-11-10 [email protected] [pigeon] Channel name in flutter error. (flutter/packages#5273) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Adds the channel name in the connection error message on all platforms host and flutter api methods. Also fixes a bug with error handling for swift flutter api void methods. Also adds method to all generators to help clean up duplicated code. fixes flutter/flutter#136277
Adds the channel name in the connection error message on all platforms host and flutter api methods. Also fixes a bug with error handling for swift flutter api void methods. Also adds method to all generators to help clean up duplicated code. fixes flutter/flutter#136277
Adds the channel name in the connection error message on all platforms host and flutter api methods.
Also fixes a bug with error handling for swift flutter api void methods.
Also adds method to all generators to help clean up duplicated code.
fixes flutter/flutter#136277
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.