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

FlutterFragment predictive back #52302

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

justinmc
Copy link
Contributor

Following up on #39208 and #42789, which added predictive back support for FlutterActivity.

My test app for this is: https://github.com/justinmc/flutter-add-to-app

I tried this both with the Flutter app as the main activity, and with it as a secondary activity after an initial Android route. Predictive back worked in both cases.

Related: flutter/flutter#109558, and my comment flutter/flutter#109558 (comment).

b/242216228

// can be changed by calling setFrameworkHandlesBack. For example, the
// framework will call this automatically in a typical app when it has
// routes to pop.
onBackPressedCallback.setEnabled(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

You probably also need to update the implementation of popSystemNavigator() to restore the previous state of the callback-enablement, instead of unconditionally re-enabling it on line 1673.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@math1man Thanks for jumping back in here, I've been trying to catch back up on your comments from the last PR. Pushing a fix for that now.

Copy link
Contributor

Choose a reason for hiding this comment

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

No worries. Honestly, I think besides this comment everything looks good. Happy to look into anything specific you might be concerned about though.

@justinmc justinmc requested a review from reidbaker April 24, 2024 20:41
@justinmc
Copy link
Contributor Author

Could @math1man or @reidbaker point me in the right direction for how to test this? Sorry I'm pretty inexperienced here, I'm struggling to even get into a real workflow. It seems like I need to recompile every time I touch the engine code (but not the test code). I'm doing:

$ autoninja -C out/android_debug_unopt                                                                     
$ ./flutter/testing/run_tests.py --type java --java-filter io.flutter.embedding.android.FlutterFragmentTest

But for one, I don't know how to view the output of Log statements I put in the test or in the engine code. They never show up in the test output.

I added some code in FlutterFragmentTest to verify popSystemNavigator is enabling/disabling the callback, but it doesn't seem to fail if I revert the PR's changes, and I'm struggling to understand why not without the benefit of logs.

@reidbaker
Copy link
Contributor

Honestly @matanlurey is who I go to for engine help but tomorrow I can take a look.

@justinmc
Copy link
Contributor Author

@camsim99 helped me out on Discord, the answer is System.out.println. That should help me make some more progress on the tests tomorrow. Thanks!

@math1man
Copy link
Contributor

Sometimes android.util.Log is better, but in most cases either should work.

@justinmc
Copy link
Contributor Author

Ah thanks, I was using io.flutter.Log, which didn't seem to show up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants