-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Platform channel for predictive back in route transitions on android #49093
Conversation
1353dcd
to
e79dace
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.
This LGTM overall just left an idea for a test and some nits!
shell/platform/android/io/flutter/embedding/engine/systemchannels/NavigationChannel.java
Outdated
Show resolved
Hide resolved
shell/platform/android/io/flutter/embedding/android/FlutterActivity.java
Outdated
Show resolved
Hide resolved
shell/platform/android/io/flutter/embedding/android/FlutterActivity.java
Outdated
Show resolved
Hide resolved
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.
@maRci002 You are a hero for implementing this, thank you for the PR.
Have you tried tying into these methods on the framework side and seeing what happens? I'd like to verify that it is going to meet our needs on the framework before merging this PR. I added some requirements to the description in flutter/flutter#131961 that I'd like to verify are possible.
You mentioned in flutter/flutter#131961 (comment) that you might want to work on the framework side. Feel free to open a framework PR (even a draft) if so. We don't have to hit all of those requirements in the first PR, I just want to make sure we've got the API right so that they're possible.
Thanks, @justinmc. I've just created the PR for the framework part flutter/flutter#141373 |
acc36fd
to
d9033d8
Compare
In my opinion, this PR is ready for further review. However, I've encountered some issues with testing, particularly related to the |
I owe a major review on this, sorry for the delay. I've been struggling to get my engine development set up on a new machine... |
de5ba9b
to
92730fe
Compare
92730fe
to
99e31b4
Compare
@maRci002 Looks like tests are passing! Is this ready for re-review? |
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 for such a long delay in reviewing this. I was able to get it running locally and it worked great for me! I think overall this approach looks good.
My main concern is any possible breakages due to no longer calling onBackPressed. See my comment on that below.
I'll also leave a review on the framework PR in a bit.
? new OnBackInvokedCallback() { | ||
// TODO(garyq): Remove SuppressWarnings annotation. This was added to workaround | ||
// a google3 bug where the linter is not properly running against API 33, causing | ||
// a failure here. See b/243609613 and https://github.com/flutter/flutter/issues/111295 |
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.
I've edited the PR description to say "Fixes flutter/flutter#111295". It looks like that Google bug is closed now, so I think it should be fine to remove the annotation like you did.
shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java
Outdated
Show resolved
Hide resolved
@TargetApi(33) | ||
@RequiresApi(33) | ||
private OnBackInvokedCallback createOnBackInvokedCallback() { | ||
if (Build.VERSION.SDK_INT >= 34) { |
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.
So for API >= 34, popping will be done by the framework via commitBackGesture. For API <= 33, the framework will handle it by listening to popRoute called by onBackPressed as usual.
Could there be any situations where users that are expecting onBackPressed won't get it and won't be listening for commitBackGesture? Like what if someone has a custom Android route transition and they don't know about these new changes?
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.
Ok at the route transition level it won't matter because either way it will just result in a pop. But I wonder if this could mess with users at any other level...
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.
But I wonder if this could mess with users at any other level...
If someone directly sets their own method for SystemChannels.navigation.setMethodCallHandler
, it might cause a problem. However, using the recommended WidgetsBindingObserver
to register their own handlers shouldn't be a problem, since the handleCommitBackGesture
method might delegate work to the handlePopRoute
method if it's not handled by registered observers.
shell/platform/android/io/flutter/embedding/android/FlutterActivityAndFragmentDelegate.java
Outdated
Show resolved
Hide resolved
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.
Looks great! Just left an optional nit on documentation
* Invoke this from {@link OnBackAnimationCallback#onBackStarted(BackEvent)}. | ||
* | ||
* <p>This method should be called when the back gesture is initiated, as part of the | ||
* implementation of {@link OnBackAnimationCallback}. It's responsible for handling the initial |
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.
Nit: can this doc is some way clarify that what it's responsible for is defined in the framework?
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.
Same nit for the other methods you added here
Golden file changes have been found for this pull request. Click here to view and triage (e.g. because this is an intentional change). If you are still iterating on this change and are not ready to resolve the images on the Flutter Gold dashboard, consider marking this PR as a draft pull request above. You will still be able to view image results on the dashboard, commenting will be silenced, and the check will not try to resolve itself until marked ready for review. |
shell/platform/android/io/flutter/embedding/engine/systemchannels/BackGestureChannel.java
Outdated
Show resolved
Hide resolved
Thanks for the quick turnaround on that! |
5934345
to
0caacd8
Compare
…145877) flutter/engine@c602abd...922c7b1 2024-03-28 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from Lk8KBU-c97ROj-YHm... to uzI3wnbEGlZ_dtO0Z... (flutter/engine#51737) 2024-03-28 skia-flutter-autoroll@skia.org Roll Skia from b6160ffc0b96 to 66241be7c81c (16 revisions) (flutter/engine#51733) 2024-03-28 bdero@google.com [Impeller] Reland: Use the scissor to limit all draws by clip coverage. (flutter/engine#51731) 2024-03-27 30870216+gaaclarke@users.noreply.github.com [Impeller] adds a `plus` advanced blend for f16 pixel formats (flutter/engine#51589) 2024-03-27 maRci002@users.noreply.github.com Platform channel for predictive back in route transitions on android (flutter/engine#49093) 2024-03-27 jonahwilliams@google.com [Impeller] render empty filled paths without crashing. (flutter/engine#51713) 2024-03-27 jonahwilliams@google.com [Impeller] use optimal depth attachment, remove useless barrier. (flutter/engine#51723) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from Lk8KBU-c97RO to uzI3wnbEGlZ_ If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC jacksongardner@google.com,rmistry@google.com,zra@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
…isions) (#145877)" (#145901) Reverts: #145877 Initiated by: zanderso Reason for reverting: #145899 Original PR Author: engine-flutter-autoroll Reviewed By: {fluttergithubbot} This change reverts the following previous change: flutter/engine@c602abd...922c7b1 2024-03-28 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from Lk8KBU-c97ROj-YHm... to uzI3wnbEGlZ_dtO0Z... (flutter/engine#51737) 2024-03-28 skia-flutter-autoroll@skia.org Roll Skia from b6160ffc0b96 to 66241be7c81c (16 revisions) (flutter/engine#51733) 2024-03-28 bdero@google.com [Impeller] Reland: Use the scissor to limit all draws by clip coverage. (flutter/engine#51731) 2024-03-27 30870216+gaaclarke@users.noreply.github.com [Impeller] adds a `plus` advanced blend for f16 pixel formats (flutter/engine#51589) 2024-03-27 maRci002@users.noreply.github.com Platform channel for predictive back in route transitions on android (flutter/engine#49093) 2024-03-27 jonahwilliams@google.com [Impeller] render empty filled paths without crashing. (flutter/engine#51713) 2024-03-27 jonahwilliams@google.com [Impeller] use optimal depth attachment, remove useless barrier. (flutter/engine#51723) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from Lk8KBU-c97RO to uzI3wnbEGlZ_ If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC jacksongardner@google.com,rmistry@google.com,zra@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
…sions) (#145903) Manual roll requested by zra@google.com flutter/engine@c602abd...9df2d3a 2024-03-28 98614782+auto-submit[bot]@users.noreply.github.com Reverts "[Impeller] adds a `plus` advanced blend for f16 pixel formats (#51589)" (flutter/engine#51741) 2024-03-28 jonahwilliams@google.com [Impeller] correct multisample resolve/store configuration for Vulkan. (flutter/engine#51740) 2024-03-28 matanlurey@users.noreply.github.com Remove Impeller/OpenGLES from CI branch for Android e2e tests. (flutter/engine#51734) 2024-03-28 skia-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from Lk8KBU-c97ROj-YHm... to uzI3wnbEGlZ_dtO0Z... (flutter/engine#51737) 2024-03-28 skia-flutter-autoroll@skia.org Roll Skia from b6160ffc0b96 to 66241be7c81c (16 revisions) (flutter/engine#51733) 2024-03-28 bdero@google.com [Impeller] Reland: Use the scissor to limit all draws by clip coverage. (flutter/engine#51731) 2024-03-27 30870216+gaaclarke@users.noreply.github.com [Impeller] adds a `plus` advanced blend for f16 pixel formats (flutter/engine#51589) 2024-03-27 maRci002@users.noreply.github.com Platform channel for predictive back in route transitions on android (flutter/engine#49093) 2024-03-27 jonahwilliams@google.com [Impeller] render empty filled paths without crashing. (flutter/engine#51713) 2024-03-27 jonahwilliams@google.com [Impeller] use optimal depth attachment, remove useless barrier. (flutter/engine#51723) Also rolling transitive DEPS: fuchsia/sdk/core/linux-amd64 from Lk8KBU-c97RO to uzI3wnbEGlZ_ If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC jacksongardner@google.com,rmistry@google.com,zra@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
Any idea how these changes can somehow cause Apologies if this is unwanted here. I simply traced my exception back to this change and I'm seriously out of my depth here. |
This pull request introduces platform channel support for predictive back route transitions on Android, as part of the ongoing efforts in flutter/flutter#131961.
OnBackInvokedCallback
to handle back navigation events (Platform channel for predictive back #39208).OnBackAnimationCallback
, taking advantage of the enhanced back navigation capabilities introduced in this version.In both scenarios, the callbacks are appropriately forwarded to the Flutter framework.
This PR focuses on the engine part, setting the stage for integrating these enhancements into the broader Flutter ecosystem.
References
Part of flutter/flutter#131961
Framework PR: flutter/flutter#141373
Fixes flutter/flutter#111295
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.