Repository navigation
Commit da33f2f
authored
Made
Made `FlutterWindowControllerSizeTest.SizedToContentNotResizable` more
robust to timing failures where `onBeginFrame` is called before the
window is created.
This test used to flake because the `onBeginFrame` callback was being
called before the window was created so the frame was getting sent to
the wrong view. The testing logic is also made more robust by hooking
into the notification center events instead of assuming that only one
update will happen per run of the event loop. The actual fix is in the
dart testing code `flutter_desktop_test.dart`.
I've tested this locally where I could reproduce the flake 1/300 times,
now the tests runs 1000/1000.
fixes flutter#194780
gemini output:
<details>
> I've found the real cause, fixed it, and staged the fix. It's
different from my first diagnosis: the test wasn't missing a size
change, the first frame was going to the wrong view.
>
> **Cause:** the Dart fixture
[`testRenderSizedToContent`](file:///Users/aaclarke/dev/flutter/engine/src/flutter/shell/platform/darwin/macos/framework/Source/fixtures/flutter_desktop_test.dart#L124-L153)
draws into `PlatformDispatcher.instance.views.last` and assumes its
first frame lands in the test's window.
> - Sometimes a frame starts before the test's `CreateRegularWindow`
call has run. At that moment `views.last` is the implicit view (id 0),
which has no window in this test.
> - The 300×300 frame goes to view 0. Creating its render surface fails
(`Could not create the embedder backing store`), so it's dropped.
> - The frame counter has already moved past 0, so the new window only
ever gets the 200×200 frame. The test then waits for 300×300 until its
30 s timeout, which matches the CI log.
>
> The temporary logging confirmed this directly: the failing 300×300
frame was for view id 0, and the test created view 1 a few ms later.
>
> **Staged changes (2 files):**
> 1. **Fix**, in `flutter_desktop_test.dart`: `onBeginFrame` now skips
any frame where `views.last` is the implicit view, then renders into the
test's window. A later frame is triggered when the window's view is
added, so nothing hangs.
> 2. **Test hardening**, in
[FlutterWindowControllerTest.mm](file:///Users/aaclarke/dev/flutter/engine/src/flutter/shell/platform/darwin/macos/framework/Source/FlutterWindowControllerTest.mm#L781-L826):
the resize-notification version from before. On failure it now also
lists every size the window went through; that list is what pointed to
the real cause here.
>
> The temporary logging in `FlutterCompositor.mm`,
`FlutterViewEngineProvider.mm` and `FlutterWindowController.mm` is
reverted. The `git checkout` I used for that printed a hook notice
suggesting `gclient sync -D`; I didn't run it.
>
> **Verification:**
>
> | Run | Result |
> |---|---|
> | Test hardening only, before the fixture fix | 2 failures in 600
runs, both from the frame going to view 0 |
> | Both changes, `FlutterWindowControllerSizeTest.*` × 1000 |
**1000/1000 passed** |
> | All `FlutterWindowController*` tests | 16/16 passed |
>
> `clang-format`, `dart format` and `dart analyze --fatal-infos` are all
clean.
>
> `SizedToContentResizable` still sends its first frame to view 0
sometimes (14 of 1000 runs). It passes anyway because that fixture draws
300×300 on every frame, so a later frame fixes it. I can add the same
implicit-view skip there for consistency if you'd like.
>
</details>
## Pre-launch Checklist
- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
If you need help, consider asking for advice on the #hackers-new channel
on [Discord].
If this change needs to override an active code freeze, provide a
comment explaining why. The code freeze workflow can be overridden by
code reviewers. See pinned issues for any active code freezes with
guidance.
**Note**: The Flutter team is currently trialing the use of [Gemini Code
Assist for
GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code).
Comments from the `gemini-code-assist` bot should not be taken as
authoritative feedback from the Flutter team. If you find its comments
useful you can update your code accordingly, but if you are unsure or
disagree with the feedback, please feel free to wait for a Flutter team
member's review for guidance on which automated comments should be
addressed.
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[AI contribution guidelines]:
https://github.com/flutter/flutter/blob/main/CONTRIBUTING.ai.md
[Tree Hygiene]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
[test-exempt]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[flutter/website]: https://github.com/flutter/website
[breaking change policy]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes
[Discord]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md
[Data Driven Fixes]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.mdFlutterWindowControllerSizeTest.SizedToContentNotResizable more robust (flutter#195845)1 parent 1261478 commit da33f2f
2 files changed
Lines changed: 48 additions & 20 deletions
File tree
- engine/src/flutter/shell/platform/darwin/macos/framework/Source
- fixtures
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
| |||
776 | 779 | | |
777 | 780 | | |
778 | 781 | | |
779 | | - | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
780 | 799 | | |
781 | | - | |
782 | 800 | | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
791 | | - | |
| 801 | + | |
| 802 | + | |
792 | 803 | | |
793 | 804 | | |
794 | 805 | | |
795 | | - | |
796 | | - | |
797 | | - | |
798 | | - | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
799 | 818 | | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
804 | 824 | | |
805 | 825 | | |
806 | 826 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
126 | 126 | | |
127 | 127 | | |
128 | 128 | | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
129 | 137 | | |
130 | 138 | | |
131 | 139 | | |
| |||
134 | 142 | | |
135 | 143 | | |
136 | 144 | | |
137 | | - | |
| 145 | + | |
138 | 146 | | |
139 | 147 | | |
140 | 148 | | |
| |||
0 commit comments