Fix input mirroring in platform views when system language is RTL, and support is set in manifest.#183472
Conversation
| final ViewGroup.LayoutParams viewWrapperLayoutParams = viewWrapper.getLayoutParams(); | ||
| viewWrapperLayoutParams.width = physicalWidth; | ||
| viewWrapperLayoutParams.height = physicalHeight; | ||
| if (viewWrapperLayoutParams instanceof FrameLayout.LayoutParams) { |
There was a problem hiding this comment.
This is kind of weird: the call to FrameLayout.getLayoutParams above returns a ViewGroup.LayoutParams, not a FrameLayout.LayoutParams. Then we immediately call our own setLayoutParams implementation:
https://github.com/flutter/flutter/blob/master/engine/src/flutter/shell/platform/android/io/flutter/plugin/platform/PlatformViewWrapper.java#L87
which takes a FrameLayout.LayoutParams, so we are always doing this cast which I am checking for. I could alternatively put this in the setLayoutParams method, but I'd prefer to keep the layout parameter configuration here in one place. But I acknowledge it looks weird... in my defense it's weird that android gives back a ViewGroup.LayoutParams in the first place...
| await flutterDriver.close(); | ||
| }); | ||
|
|
||
| test( |
There was a problem hiding this comment.
Neither taps delivered by flutterDriver or the nativeDriver extension repro the issue. Instead, this test requests the location of the blue box via flutter driver, and also requests pixel information, to calculate the location of the box and deliver a tab via adb to those physical coordinates.
There was a problem hiding this comment.
Code Review
This pull request fixes an issue with input mirroring for platform views in RTL layouts by explicitly setting the gravity of FrameLayout.LayoutParams to Gravity.LEFT | Gravity.TOP. This prevents the default Gravity.START from being misinterpreted in RTL contexts. The changes are applied consistently across FlutterMutatorView, PlatformViewsController, and PlatformViewsController2. A new integration test is also added to verify the fix. The fix appears correct and well-tested. However, I found a compilation error in the new test application code that needs to be addressed.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request addresses an input mirroring issue on platform views in RTL layouts. The changes involve explicitly setting the gravity to Gravity.LEFT | Gravity.TOP for FrameLayout.LayoutParams in FlutterMutatorView, PlatformViewsController, and PlatformViewsController2. This ensures platform views are positioned correctly regardless of layout direction. Additionally, an integration test has been added to verify the fix, which required enabling RTL support in the test application's manifest.
There was a problem hiding this comment.
Code Review
This pull request effectively addresses an input mirroring issue on platform views in RTL layouts by explicitly setting the layout gravity to Gravity.LEFT | Gravity.TOP. The change is well-supported by a new integration test that accurately reproduces and verifies the fix. My only suggestion is to consider deduplicating the new gravity value to improve code maintainability.
…is RTL, and support is set in manifest. (flutter/flutter#183472)
…is RTL, and support is set in manifest. (flutter/flutter#183472)
…is RTL, and support is set in manifest. (flutter/flutter#183472)
…is RTL, and support is set in manifest. (flutter/flutter#183472)
flutter/flutter@3f400d7...9e36adb 2026-03-12 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from QD887D4OanteB7UKM... to jJbpv4J_tjW-wuKDq... (flutter/flutter#183584) 2026-03-12 matt.kosarek@canonical.com Adding the SatelliteWindowController interface to `_window.dart` (flutter/flutter#182903) 2026-03-12 engine-flutter-autoroll@skia.org Roll Skia from 0cab3e4ee34b to 46f41493ebf4 (17 revisions) (flutter/flutter#183553) 2026-03-12 engine-flutter-autoroll@skia.org Roll Dart SDK from 8531f7c2bdae to 59be21f25f2d (4 revisions) (flutter/flutter#183547) 2026-03-12 koji.wakamiya@gmail.com [ios][engine] Fix keyboard flicker when switching text fields (flutter/flutter#182661) 2026-03-11 34871572+gmackall@users.noreply.github.com Rename hcpp opt in flag to `enable-hcpp` (flutter/flutter#183151) 2026-03-11 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#183541) 2026-03-11 97480502+b-luk@users.noreply.github.com Re-enable gpu_test.dart for opengles, but disable specific tests in the file (flutter/flutter#183531) 2026-03-11 jacksongardner@google.com Use CLA-approved email and username for github workflow commits. (flutter/flutter#183540) 2026-03-11 okorohelijah@google.com [integration_test]UIScene Migration (flutter/flutter#182631) 2026-03-11 git@reb0.org ci: Run orchestrator for windows_arm_host_engine on Linux (flutter/flutter#181075) 2026-03-11 mdebbar@google.com [web] Prevent Firefox auto-updates (flutter/flutter#183330) 2026-03-11 koji.wakamiya@gmail.com Add scrollCacheExtent to PageView (flutter/flutter#180411) 2026-03-11 danny@tuppeny.com Remove redundant VS Code code/tests (flutter/flutter#183506) 2026-03-11 danny@tuppeny.com Roll pub packages (flutter/flutter#183527) 2026-03-11 34871572+gmackall@users.noreply.github.com Reapply "Make HCPP upgrading work for vd/tlhc (#181024)" (#183310) (flutter/flutter#183360) 2026-03-11 victorsanniay@gmail.com Add awaits to dev/ callsites (flutter/flutter#183479) 2026-03-11 stuartmorgan@google.com Standardize review timeline guidance (flutter/flutter#183465) 2026-03-11 chingjun@google.com Rename ExecutionModelToString to ExecutionModelToStringName. (flutter/flutter#183461) 2026-03-11 34871572+gmackall@users.noreply.github.com Fix input mirroring in platform views when system language is RTL, and support is set in manifest. (flutter/flutter#183472) 2026-03-11 engine-flutter-autoroll@skia.org Roll Packages from ee460d6 to ecace66 (10 revisions) (flutter/flutter#183517) 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 Please CC stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
…r#11233) flutter/flutter@3f400d7...9e36adb 2026-03-12 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from QD887D4OanteB7UKM... to jJbpv4J_tjW-wuKDq... (flutter/flutter#183584) 2026-03-12 matt.kosarek@canonical.com Adding the SatelliteWindowController interface to `_window.dart` (flutter/flutter#182903) 2026-03-12 engine-flutter-autoroll@skia.org Roll Skia from 0cab3e4ee34b to 46f41493ebf4 (17 revisions) (flutter/flutter#183553) 2026-03-12 engine-flutter-autoroll@skia.org Roll Dart SDK from 8531f7c2bdae to 59be21f25f2d (4 revisions) (flutter/flutter#183547) 2026-03-12 koji.wakamiya@gmail.com [ios][engine] Fix keyboard flicker when switching text fields (flutter/flutter#182661) 2026-03-11 34871572+gmackall@users.noreply.github.com Rename hcpp opt in flag to `enable-hcpp` (flutter/flutter#183151) 2026-03-11 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#183541) 2026-03-11 97480502+b-luk@users.noreply.github.com Re-enable gpu_test.dart for opengles, but disable specific tests in the file (flutter/flutter#183531) 2026-03-11 jacksongardner@google.com Use CLA-approved email and username for github workflow commits. (flutter/flutter#183540) 2026-03-11 okorohelijah@google.com [integration_test]UIScene Migration (flutter/flutter#182631) 2026-03-11 git@reb0.org ci: Run orchestrator for windows_arm_host_engine on Linux (flutter/flutter#181075) 2026-03-11 mdebbar@google.com [web] Prevent Firefox auto-updates (flutter/flutter#183330) 2026-03-11 koji.wakamiya@gmail.com Add scrollCacheExtent to PageView (flutter/flutter#180411) 2026-03-11 danny@tuppeny.com Remove redundant VS Code code/tests (flutter/flutter#183506) 2026-03-11 danny@tuppeny.com Roll pub packages (flutter/flutter#183527) 2026-03-11 34871572+gmackall@users.noreply.github.com Reapply "Make HCPP upgrading work for vd/tlhc (#181024)" (#183310) (flutter/flutter#183360) 2026-03-11 victorsanniay@gmail.com Add awaits to dev/ callsites (flutter/flutter#183479) 2026-03-11 stuartmorgan@google.com Standardize review timeline guidance (flutter/flutter#183465) 2026-03-11 chingjun@google.com Rename ExecutionModelToString to ExecutionModelToStringName. (flutter/flutter#183461) 2026-03-11 34871572+gmackall@users.noreply.github.com Fix input mirroring in platform views when system language is RTL, and support is set in manifest. (flutter/flutter#183472) 2026-03-11 engine-flutter-autoroll@skia.org Roll Packages from ee460d6 to ecace66 (10 revisions) (flutter/flutter#183517) 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 Please CC stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
…d support is set in manifest. (flutter#183472) Fixes flutter#182823 We use a [`FrameLayout`](https://developer.android.com/reference/android/widget/FrameLayout) to [wrap platform views](https://github.com/flutter/flutter/blob/master/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorView.java#L30). We construct new `FrameLayout.LayoutParams` and set them on the frame layout ([here](https://github.com/flutter/flutter/blob/758463261fabe1b37f2a4752bfc44a57e10c79b7/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorView.java#L107), and a couple of other places). Because we don't specify a gravity, it defaults to [UNSPECIFIED_GRAVITY](https://developer.android.com/reference/android/widget/FrameLayout.LayoutParams#gravity), which is `Gravity.TOP | Gravity.START`. When a developer indicates that their app supports RTL (right-to-left) layouts (e.g. arabic), and the system language is set to one with an RTL layout, START becomes left https://developer.android.com/reference/android/view/Gravity#getAbsoluteGravity(int,%20int), and the view ends up thinking it is positioned relative to the right of the screen, even though we are controlling the drawing and putting it on the left. Because we are handling the drawing, and all that matters is that flutter knows where the view is, we can just statically set the horizontal gravity to be left. Then flutter knows where to find the view and deliver the tap to it, whether we are in an RTL or LTR layout. --------- Co-authored-by: Gray Mackall <mackall@google.com>
…d support is set in manifest. (flutter#183472) Fixes flutter#182823 We use a [`FrameLayout`](https://developer.android.com/reference/android/widget/FrameLayout) to [wrap platform views](https://github.com/flutter/flutter/blob/master/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorView.java#L30). We construct new `FrameLayout.LayoutParams` and set them on the frame layout ([here](https://github.com/flutter/flutter/blob/758463261fabe1b37f2a4752bfc44a57e10c79b7/engine/src/flutter/shell/platform/android/io/flutter/embedding/engine/mutatorsstack/FlutterMutatorView.java#L107), and a couple of other places). Because we don't specify a gravity, it defaults to [UNSPECIFIED_GRAVITY](https://developer.android.com/reference/android/widget/FrameLayout.LayoutParams#gravity), which is `Gravity.TOP | Gravity.START`. When a developer indicates that their app supports RTL (right-to-left) layouts (e.g. arabic), and the system language is set to one with an RTL layout, START becomes left https://developer.android.com/reference/android/view/Gravity#getAbsoluteGravity(int,%20int), and the view ends up thinking it is positioned relative to the right of the screen, even though we are controlling the drawing and putting it on the left. Because we are handling the drawing, and all that matters is that flutter knows where the view is, we can just statically set the horizontal gravity to be left. Then flutter knows where to find the view and deliver the tap to it, whether we are in an RTL or LTR layout. --------- Co-authored-by: Gray Mackall <mackall@google.com>
…r#11233) flutter/flutter@3f400d7...9e36adb 2026-03-12 engine-flutter-autoroll@skia.org Roll Fuchsia Linux SDK from QD887D4OanteB7UKM... to jJbpv4J_tjW-wuKDq... (flutter/flutter#183584) 2026-03-12 matt.kosarek@canonical.com Adding the SatelliteWindowController interface to `_window.dart` (flutter/flutter#182903) 2026-03-12 engine-flutter-autoroll@skia.org Roll Skia from 0cab3e4ee34b to 46f41493ebf4 (17 revisions) (flutter/flutter#183553) 2026-03-12 engine-flutter-autoroll@skia.org Roll Dart SDK from 8531f7c2bdae to 59be21f25f2d (4 revisions) (flutter/flutter#183547) 2026-03-12 koji.wakamiya@gmail.com [ios][engine] Fix keyboard flicker when switching text fields (flutter/flutter#182661) 2026-03-11 34871572+gmackall@users.noreply.github.com Rename hcpp opt in flag to `enable-hcpp` (flutter/flutter#183151) 2026-03-11 137456488+flutter-pub-roller-bot@users.noreply.github.com Roll pub packages (flutter/flutter#183541) 2026-03-11 97480502+b-luk@users.noreply.github.com Re-enable gpu_test.dart for opengles, but disable specific tests in the file (flutter/flutter#183531) 2026-03-11 jacksongardner@google.com Use CLA-approved email and username for github workflow commits. (flutter/flutter#183540) 2026-03-11 okorohelijah@google.com [integration_test]UIScene Migration (flutter/flutter#182631) 2026-03-11 git@reb0.org ci: Run orchestrator for windows_arm_host_engine on Linux (flutter/flutter#181075) 2026-03-11 mdebbar@google.com [web] Prevent Firefox auto-updates (flutter/flutter#183330) 2026-03-11 koji.wakamiya@gmail.com Add scrollCacheExtent to PageView (flutter/flutter#180411) 2026-03-11 danny@tuppeny.com Remove redundant VS Code code/tests (flutter/flutter#183506) 2026-03-11 danny@tuppeny.com Roll pub packages (flutter/flutter#183527) 2026-03-11 34871572+gmackall@users.noreply.github.com Reapply "Make HCPP upgrading work for vd/tlhc (#181024)" (#183310) (flutter/flutter#183360) 2026-03-11 victorsanniay@gmail.com Add awaits to dev/ callsites (flutter/flutter#183479) 2026-03-11 stuartmorgan@google.com Standardize review timeline guidance (flutter/flutter#183465) 2026-03-11 chingjun@google.com Rename ExecutionModelToString to ExecutionModelToStringName. (flutter/flutter#183461) 2026-03-11 34871572+gmackall@users.noreply.github.com Fix input mirroring in platform views when system language is RTL, and support is set in manifest. (flutter/flutter#183472) 2026-03-11 engine-flutter-autoroll@skia.org Roll Packages from ee460d6 to ecace66 (10 revisions) (flutter/flutter#183517) 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 Please CC stuartmorgan@google.com on the revert to ensure that a human is aware of the problem. To file a bug in Packages: 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
Fixes #182823
We use a
FrameLayoutto wrap platform views. We construct newFrameLayout.LayoutParamsand set them on the frame layout (here, and a couple of other places). Because we don't specify a gravity, it defaults to UNSPECIFIED_GRAVITY, which isGravity.TOP | Gravity.START. When a developer indicates that their app supports RTL (right-to-left) layouts (e.g. arabic), and the system language is set to one with an RTL layout, START becomes right https://developer.android.com/reference/android/view/Gravity#getAbsoluteGravity(int,%20int), and the view ends up thinking it is positioned relative to the right of the screen, even though we are controlling the drawing and putting it on the left.Because we are handling the drawing, and all that matters is that flutter knows where the view is, we can just statically set the horizontal gravity to be left. Then flutter knows where to find the view and deliver the tap to it, whether we are in an RTL or LTR layout.