Commit 3237222
authored
[macOS] Implement merged UI and platform thread (#162883)
Original issue: flutter/flutter#150525
This PR lets the macOS embedder run both with and without UI and
platform thread merged.
Thread merging is controlled through `FLTEnableMergedPlatformUIThread`
`info.plist` option similar to iOS embedder, though the default value is
currently `false`.
Changes in the resize / vsync synchronization:
- Added `FlutterRunLoop` class to schedule Flutter tasks on main thread
in a way where it is possible to only process these (Flutter posted)
tasks while waiting for correct frame size during resizing. This
significantly simplifies the resize synchronization and makes the same
code work both with separate UI thread and with UI and platform thread
merged.
- `FlutterThreadSynchronizer` has been renamed to
`FlutterResizeSynchronizer` vastly simplified, mutex and conditions are
removed and the blocking is now done by only processing Flutter messages
while waiting for resizing. It is now per view (instead of storing a
viewId->Size map internally) and owned by the view itself, instead of
engine.
- This approach to resize synchronization will work for Windows and
Linux as well. This will allow us to conceptually consolidate the way we
do threading and resize synchronization on all three desktop embedders.
## 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], 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 documentation (doc comments with `///`).
- [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].
<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview
[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
[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.md1 parent f01d068 commit 3237222
27 files changed
Lines changed: 718 additions & 1094 deletions
File tree
- engine/src/flutter
- ci/licenses_golden
- shell/platform/darwin/macos
- framework/Source
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52934 | 52934 | | |
52935 | 52935 | | |
52936 | 52936 | | |
| 52937 | + | |
| 52938 | + | |
| 52939 | + | |
52937 | 52940 | | |
52938 | 52941 | | |
52939 | 52942 | | |
| |||
52947 | 52950 | | |
52948 | 52951 | | |
52949 | 52952 | | |
52950 | | - | |
52951 | | - | |
52952 | | - | |
52953 | 52953 | | |
52954 | 52954 | | |
52955 | 52955 | | |
| |||
55943 | 55943 | | |
55944 | 55944 | | |
55945 | 55945 | | |
| 55946 | + | |
| 55947 | + | |
| 55948 | + | |
| 55949 | + | |
| 55950 | + | |
55946 | 55951 | | |
55947 | 55952 | | |
55948 | 55953 | | |
| |||
55956 | 55961 | | |
55957 | 55962 | | |
55958 | 55963 | | |
55959 | | - | |
55960 | | - | |
55961 | | - | |
55962 | 55964 | | |
55963 | 55965 | | |
55964 | 55966 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| |||
104 | 108 | | |
105 | 109 | | |
106 | 110 | | |
107 | | - | |
108 | | - | |
109 | 111 | | |
110 | 112 | | |
111 | 113 | | |
| |||
194 | 196 | | |
195 | 197 | | |
196 | 198 | | |
| 199 | + | |
197 | 200 | | |
198 | 201 | | |
199 | 202 | | |
200 | | - | |
201 | 203 | | |
202 | 204 | | |
203 | 205 | | |
| |||
Lines changed: 8 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
12 | 13 | | |
13 | 14 | | |
14 | 15 | | |
| 16 | + | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
20 | | - | |
21 | 23 | | |
22 | 24 | | |
23 | | - | |
24 | | - | |
| 25 | + | |
| 26 | + | |
25 | 27 | | |
26 | 28 | | |
27 | | - | |
| 29 | + | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
| 34 | + | |
33 | 35 | | |
34 | 36 | | |
35 | | - | |
| 37 | + | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
| |||
0 commit comments