Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@JonathanPeterCole
Copy link
Contributor

Currently during the keyboard animation, the navigation bar insets are subtracted from the keyboard insets. This is correct when the app isn't laid out behind the navigation bar, but results in incorrect viewInsets when the app's running in edge-to-edge or fullscreen.

This change checks if the app is being laid out behind the navigation bar and adjusts the bottom insets accordingly during the keyboard animation.

Fixes flutter/flutter#89914

Tested on Android 13 (Pixel 7) using the code sample here: flutter/flutter#109623

Before

Before.mp4

After

After.mp4

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 [Flutter Style Guide] and the [C++, Objective-C, Java style guides].
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See [testing the engine] for instructions on writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the [CLA].
  • All existing and new tests are passing.

@JonathanPeterCole JonathanPeterCole changed the title Fix incorrect viewInsets during keyboard animation with EdgeToEdge [Android] Fix incorrect viewInsets during keyboard animation with EdgeToEdge Feb 4, 2023
@chinmaygarde
Copy link
Member

@reidbaker Please route the appropriate reviewer.

@reidbaker
Copy link
Contributor

@gmackall can you give this a first pass it looks related to an issue you are working on. I will give it a second pass when it is ready.

@camsim99 camsim99 requested a review from gmackall February 16, 2023 19:46
@chinmaygarde
Copy link
Member

From Triage: Ping @gmackall.

@reidbaker
Copy link
Contributor

@gmackall can you provide some next steps for this pr.

@gmackall
Copy link
Member

gmackall commented Mar 2, 2023

Sure! The issue of excluding all systembars vs only navbars is the only comment I’m looking to resolve, once we can resolve that I can give an approval and @reidbaker will do a final review. Let me know when you’ve had a chance to make/test the change!

Thanks for the contribution and especially for including video of the issue/resolution, it makes reviewing much easier 🙂

@JonathanPeterCole
Copy link
Contributor Author

Should be resolved now, I've switched to navigationBar insets and tested on-device to make sure it's still working as expected 👍

Copy link
Member

@gmackall gmackall left a comment

Choose a reason for hiding this comment

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

Thanks for making that change and testing it out! This looks good to me, passing to @reidbaker for final review.

Additional context for reading the PR:
The flags set by the different UI modes are defined here - https://github.com/flutter/engine/blob/main/shell/platform/android/io/flutter/plugin/platform/PlatformPlugin.java#L302

@camsim99 camsim99 requested a review from reidbaker March 9, 2023 19:27
@gmackall
Copy link
Member

Hey, just following up to see if you are still planning to address Reids comments.

@JonathanPeterCole
Copy link
Contributor Author

Sorry I've been meaning to get back to this for a while, I'll try to address the comments in the next few days.

@chinmaygarde
Copy link
Member

Any updates? If this is still WIP, please convert it to a draft so triagers don't bother you every week :)

@delfme
Copy link

delfme commented Apr 2, 2023

FYI, #40867 is on its way. After both PRs will land, flutter bottom inset animation on keyboard opening will work as expected on both platforms.

@JonathanPeterCole
Copy link
Contributor Author

I'm currently exploring possible solutions that don't depend on deprecated APIs per @reidbaker's comment, I'll set this as a draft for now whilst I continue to investigate.

@JonathanPeterCole JonathanPeterCole marked this pull request as draft April 2, 2023 18:23
@delfme
Copy link

delfme commented Apr 2, 2023

@reidbaker if the non-deprecated path is already mastered by you, would it be possible for you to try to make time and help integrating it? That would speed thing up

@reidbaker
Copy link
Contributor

I think that is a question for @gmackall.

@delfme
Copy link

delfme commented Apr 4, 2023

Thx @reidbaker if you notice this might take more time than expected, can it be considered to merge PR just to mitigate clients pain and at same time move the pending part to remove deprecated code to a new PR?

Asking it because issue is severe and also Lucky said me that #40867 is almost ready, he is just testing it a bit.

@delfme
Copy link

delfme commented Apr 18, 2023

@JonathanPeterCole yes that is the issue that would still require a fix. A similar work has been done for ios with #40867

If possible, the idea is to have this merged with a note about the deprecated api, so that we can keep debugging on master. Issue is painful and since landing an ultimate fix might take some time, apps would meantime benefit from a not-perfect-yet-decent keyboard animation. The fix for ios took 1yr, we are confident that the android side would be easier but we are not sure.

@reidbaker
Copy link
Contributor

Ok @delfme that sounds like a reasonable plan to me. When you are ready for re review can you move this out of draft and ping @gmackall and myself again?

@delfme
Copy link

delfme commented Apr 18, 2023

@reidbaker I suggested to merge this PR so that we can keep debugging issue on master. Another PR will address deprecated api and the other issue mentioned above when it is ready

@delfme
Copy link

delfme commented Apr 18, 2023

Ok @delfme that sounds like a reasonable plan to me. When you are ready for re review can you move this out of draft and ping @gmackall and myself again?

@reidbaker I’ve misunderstood this. It is perfect 👍 If you also want to file an issue, we will refer to it for next PR.

@JonathanPeterCole can you please move this out of draft so it can be merged?

@delfme
Copy link

delfme commented Apr 18, 2023

CC: @CoolDude53

@JonathanPeterCole JonathanPeterCole marked this pull request as ready for review April 20, 2023 21:22
@JonathanPeterCole
Copy link
Contributor Author

@reidbaker @gmackall Sorry for the delays on this one, it should now be ready for a re-review

@camsim99 camsim99 requested review from gmackall and reidbaker April 27, 2023 18:35
@reidbaker
Copy link
Contributor

First pass on the re review looks good. @gmackall can you checkout this code and run it on a real device before approving.
I have some unreleased devices I need to test with before approving.

@gmackall
Copy link
Member

gmackall commented May 4, 2023

First pass on the re review looks good. @gmackall can you checkout this code and run it on a real device before approving. I have some unreleased devices I need to test with before approving.

Will try testing on a device this afternoon and update with results

@gmackall
Copy link
Member

gmackall commented May 5, 2023

Tested on a samsung galaxy s21 on both master and with this patch, and was able to both recreate the issue on master and confirm that this patch fixes it.

The changes to tests since my last approval also look good, so re-adding my approval.

// out behind the navigation bar aren't present.
int excludedInsets = 0;
int systemUiFlags = view.getWindowSystemUiVisibility();
if ((systemUiFlags & View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION) == 0
Copy link
Contributor

Choose a reason for hiding this comment

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

Without committing you to building it do you think we need to do a similar evaluation for status bar and the top insets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that'll be necessary as the status bar visibility and top insets didn't affect the keyboard animation in my testing.

Copy link
Contributor

Choose a reason for hiding this comment

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

But it would impact any animation coming from the top like keyboards impact animations coming from the bottom. Right? If for example the status bar was present our code would behave differently than if status bar was overlayed. I am thinking of flutter/flutter#118761

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah interesting, I'm not sure on this one but WindowInsetsController.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE is one of the new APIs introduced in API 30, so I wonder if it's a conflict with the deprecated system UI flags currently in use, rather than an issue with keyboard animation.

Copy link
Contributor

Choose a reason for hiding this comment

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

@gmackall this is something to keep in mind.

@reidbaker reidbaker added the autosubmit Merge PR when tree becomes green via auto submit App label May 8, 2023
@auto-submit auto-submit bot merged commit c94be7a into flutter:main May 8, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 9, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 9, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 9, 2023
…126309)

flutter/engine@8d3a816...824cd09

2023-05-09 [email protected] Increase timeout of orchestrator. (flutter/engine#41839)
2023-05-09 [email protected] [fuchsia] Stop calling FIDL from Dart in Flutter integration tests (flutter/engine#41669)
2023-05-09 [email protected] [tests] Remove unused fuchsia.sys protocol reference (flutter/engine#41826)
2023-05-09 [email protected] Roll Skia from 7736fbaf84f0 to 485cd3d0f9ca (6 revisions) (flutter/engine#41840)
2023-05-09 [email protected] [Impeller] introduces DeviceHolder to avoid accessing a dead Device (flutter/engine#41748)
2023-05-08 [email protected] Get rid of "outrageous" default text styles for HTML renderer. (flutter/engine#41822)
2023-05-08 [email protected] Adjust DL filter bounds tests to not rely on exact Skia results (flutter/engine#41792)
2023-05-08 [email protected] Roll Dart SDK from a8b6687327d6 to 498cfa57165b (1 revision) (flutter/engine#41823)
2023-05-08 [email protected] [Android] Fix incorrect viewInsets during keyboard animation with EdgeToEdge (flutter/engine#39391)
2023-05-08 [email protected] Roll Skia from 951eb9653163 to 7736fbaf84f0 (1 revision) (flutter/engine#41821)

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 [email protected],[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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SystemUiMode.edgeToEdge bottom viewInset jumps when keyboard is opening

5 participants