[pigeon] Channel name in flutter error.#5273
Conversation
stuartmorgan-g
left a comment
There was a problem hiding this comment.
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
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
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto 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.