engine icon indicating copy to clipboard operation
engine copied to clipboard

Platform channel for predictive back in route transitions on android

Open maRci002 opened this issue 1 year ago • 9 comments

This pull request introduces platform channel support for predictive back route transitions on Android, as part of the ongoing efforts in flutter/flutter#131961.

  • For Android SDK 33: Utilizes OnBackInvokedCallback to handle back navigation events (#39208).
  • For Android SDK 34 and above: Employs 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 https://github.com/flutter/flutter/issues/111295

Pre-launch Checklist

  • [x] I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • [x] I read the Tree Hygiene wiki page, which explains my responsibilities.
  • [x] I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • [x] I listed at least one issue that this PR fixes in the description above.
  • [x] I added new tests to check the change I am making or feature I am adding, or the PR is test-exempt. See testing the engine for instructions on writing and running engine tests.
  • [x] I updated/added relevant documentation (doc comments with ///).
  • [x] I signed the CLA.
  • [x] All existing and new tests are passing.

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

maRci002 avatar Dec 15 '23 17:12 maRci002

Thanks, @justinmc. I've just created the PR for the framework part flutter/flutter#141373

maRci002 avatar Jan 11 '24 14:01 maRci002

What is the status of this PR, is it waiting on review comments or framework changes? Friendly ping @justinmc / @maRci002

jonahwilliams avatar Jan 25 '24 21:01 jonahwilliams

In my opinion, this PR is ready for further review. However, I've encountered some issues with testing, particularly related to the @Config annotation. I'm currently awaiting some inputs from @camsim99 to resolve these concerns. Once these are addressed, I believe the PR will be in good shape for final review.

maRci002 avatar Jan 25 '24 22:01 maRci002

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...

justinmc avatar Jan 25 '24 23:01 justinmc

@maRci002 Looks like tests are passing! Is this ready for re-review?

camsim99 avatar Feb 05 '24 16:02 camsim99

@maRci002 Looks like tests are passing! Is this ready for re-review?

@camsim99, thanks, but the API might change over time. I will definitely let you know when it's ready for review from an Android perspective.

maRci002 avatar Feb 06 '24 14:02 maRci002

@maRci002 Can you fix the build conflict? I think it's just that PR https://github.com/flutter/engine/pull/51171 requires the use of API_LEVELS.API_33 instead of 33 etc. now.

justinmc avatar Mar 11 '24 17:03 justinmc

I think once you've fixed the merge conflict we should move forward with merging this PR, and then focus on getting the framework PR merged.

Framework and Engine should be merged together; otherwise, on Android 14, the back button will break down since the commitBackGesture event will be sent instead of popRoute.

@camsim99, thank you for waiting. The PR is ready for review from an Android perspective. However, please do not apply autosubmit label if possible until the framework is finished. I will let you know when it's ready :)

maRci002 avatar Mar 12 '24 17:03 maRci002

Ah good catch. Sounds good.

justinmc avatar Mar 12 '24 22:03 justinmc

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.

Changes reported for pull request #49093 at sha 7bcd50fd284b58b47fcc842f20a085ed1c77f002

flutter-dashboard[bot] avatar Mar 19 '24 23:03 flutter-dashboard[bot]

Thanks for the quick turnaround on that!

justinmc avatar Mar 20 '24 22:03 justinmc

Any idea how these changes can somehow causeOnBackInvokedCallback to be invoked on a different platformview, causing an exception on Android < 13? https://github.com/flutter/flutter/issues/151733

Apologies if this is unwanted here. I simply traced my exception back to this change and I'm seriously out of my depth here.

timbotimbo avatar Jul 14 '24 17:07 timbotimbo