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

Fix unnecessary toList/fromList calls during encode/decode process #6426

Merged
merged 20 commits into from May 6, 2024

Conversation

tarrinneal
Copy link
Contributor

@tarrinneal tarrinneal commented Mar 28, 2024

Fix unnecessary toList/fromList calls during encode/decode process.

also makes some kotlin code more idiomatic.

removes the ability to have collisions with the name list.

fixes flutter/flutter#119351

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/packages repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@tarrinneal tarrinneal changed the title cc Fix redundant encode/decode Apr 1, 2024
@tarrinneal tarrinneal marked this pull request as ready for review April 2, 2024 00:04
@tarrinneal tarrinneal requested review from stuartmorgan and removed request for hellohuanlin April 2, 2024 00:04
@stuartmorgan
Copy link
Contributor

removes double encode/decode on custom classes.

Per offline discussion I think we should adjust the PR description here, as well as the changelog. It's not that things were double-encoding custom classes, it's that we were making the encoding logic needlessly complex by calling ToList/FromList directly instead of letting the encoder do the encoding internally.

(This PR will actually make the byte encoding slightly less efficient; before a custom class was encoded as <list type marker><list size><list elements> and now it will be <custom class type marker><list type marker><list size><list elements>. Maybe that's why it was originally written the other way, but I don't think that's a worthwhile optimization for the conceptual complexity it adds.)

@@ -186,15 +186,15 @@ ArrayList<Object> toList() {
return toListResult;
}

static @NonNull MessageData fromList(@NonNull ArrayList<Object> list) {
static @NonNull MessageData fromList(@NonNull ArrayList<Object> __pigeon_list) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't need to be in this PR, but we should consider just inlining all of the value expressions into the setter calls so we don't need variables, and thus don't have a collision concern.

@@ -3,6 +3,7 @@
// found in the LICENSE file.
// Autogenerated from Pigeon, do not edit directly.
// See also: https://pub.dev/packages/pigeon
@file:Suppress("UNCHECKED_CAST", "LocalVariableName", "ArrayInDataClass")
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the change? Don't we want to make the suppressions for this as targeted as possible?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

most of them are full file regardless, it gives "redundant suppression" errors.

packages/pigeon/CHANGELOG.md Outdated Show resolved Hide resolved
packages/pigeon/lib/objc_generator.dart Outdated Show resolved Hide resolved
packages/pigeon/lib/swift_generator.dart Outdated Show resolved Hide resolved
packages/pigeon/lib/swift_generator.dart Outdated Show resolved Hide resolved
packages/pigeon/lib/swift_generator.dart Outdated Show resolved Hide resolved
packages/pigeon/pigeons/core_tests.dart Show resolved Hide resolved
@stuartmorgan
Copy link
Contributor

stuartmorgan commented Apr 26, 2024

Now I remember why this error looked familiar: it's a bug in VS 2019, which was fixed in VS 2022.

We actually shouldn't still be using VS 2019 in CI, but it's going to be tricky to update that right now so I'll dig up the workaround. IIRC it will just require turning on exceptions for the test app.

@tarrinneal
Copy link
Contributor Author

Now I remember why this error looked familiar: it's a bug in VS 2019, which was fixed in VS 2022.

We actually shouldn't still be using VS 2019 in CI, but it's going to be tricky to update that right now so I'll dig up the workaround. IIRC it will just require turning on exceptions for the test app.

Seems like it may be something else still...

@stuartmorgan
Copy link
Contributor

Now I remember why this error looked familiar: it's a bug in VS 2019, which was fixed in VS 2022.
We actually shouldn't still be using VS 2019 in CI, but it's going to be tricky to update that right now so I'll dig up the workaround. IIRC it will just require turning on exceptions for the test app.

Seems like it may be something else still...

Or it is that same problem, but I put the workaround on the example app binary when the failure is coming from a unit test file that's not compiled in that binary, and I need to change the build settings of the thing that was actually failing to compile 🤦🏻

@tarrinneal tarrinneal changed the title Fix redundant encode/decode Fix unnecessary toList/fromList calls during encode/decode process Apr 30, 2024
Copy link
Contributor

@stuartmorgan stuartmorgan left a comment

Choose a reason for hiding this comment

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

LGTM! Just a few minor comments about possible simplifications.

packages/pigeon/lib/dart_generator.dart Outdated Show resolved Hide resolved
packages/pigeon/lib/kotlin_generator.dart Outdated Show resolved Hide resolved
packages/pigeon/lib/swift_generator.dart Outdated Show resolved Hide resolved
@tarrinneal tarrinneal added the autosubmit Merge PR when tree becomes green via auto submit App label May 6, 2024
@auto-submit auto-submit bot merged commit 9a94bfd into flutter:main May 6, 2024
78 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 6, 2024
vashworth pushed a commit to vashworth/packages that referenced this pull request May 6, 2024
…lutter#6426)

Fix unnecessary toList/fromList calls during encode/decode process.

also makes some kotlin code more idiomatic.

removes the ability to have collisions with the name `list`.

fixes flutter/flutter#119351
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 6, 2024
flutter/packages@f4719ca...2dfe645

2024-05-06 PROGrand@users.noreply.github.com [camera] MediaSettings parameter for createCameraWithSettings (flutter/packages#3586)
2024-05-06 tarrinneal@gmail.com Fix unnecessary toList/fromList calls during encode/decode process (flutter/packages#6426)
2024-05-03 engine-flutter-autoroll@skia.org Roll Flutter from bf7191f to f1037a0 (21 revisions) (flutter/packages#6641)

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 flutter-ecosystem@google.com,rmistry@google.com 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants