Commit a5dd314
authored
_**WIP**: We do not plan to land this PR until the next stable release (>= April 3rd 2024)_.
Work towards flutter/flutter#145930.
## Details
Migrates uses of `createSurfaceTexture` to `createSurfaceProducer`, which is intended to have no change in behavior, but _does_ change the backend rendering path, so it will require more testing (and we're also open to minor API renames or changes before it becomes stable).
## Background
Android plugins previously requested a `SurfaceTexture` from the Android embedder, and used that to produce a `Surface` to render external textures on (i.e. `video_player`). This worked because 100% of Flutter applications on Android used OpenGLES (via our Skia backend), and `SurfaceTexture` is actually an (opaque) OpenGLES-texture.
Starting soon (roughly ~Q3, this is not a guarantee and just an estimate), Flutter on Android will start to use our new Impeller graphics backend, which on newer devices (`>= API_VERSION_28`), will default to the Vulkan, _not_ OpenGLES. In other words, `SurfaceTexture` will cease to work (it is possible, but non-trivial, to map an OpenGLES texture over to Vulkan).
After consultation with the Android team, they helped us understand that vending `SurfaceTexture` (the _consumer-side_ API) was never the right abstraction, and we should have been vending the _producer-side_ API, or `Surface` directly. The new `SurfaceProducer` API is exactly that - it generates a `Surface`, and similar to our platform view strategy, picks the "right" _consumer-side_ implementation details _for_ the user/plugin packages.
The new `SurfaceProducer` API has 2 possible rendering types (as an implementation detail):
- `SurfaceTexture`, for older OpenGLES devices, which works exactly as it does today.
- `ImageReader`, for newer OpenGLES _or_ Vulkan devices.
These are some subtle nuances in how these two APIs work differently (one example: flutter/flutter#144407), but our theory at this point is we don't expect these changes to be observed by any users, and we have other ideas if necessary.
> [!NOTE]
> These invariants are [tested on CI in `flutter/engine`](https://github.com/flutter/engine/tree/main/testing/scenario_app/android#ci-configuration).
Points of contact:
- @matanlurey or @jonahwilliams (Flutter Engine)
- @johnmccutchan or @reidbaker (Flutter on Android)
1 parent 28e8afd commit a5dd314
File tree
6 files changed
+136
-38
lines changed- packages/video_player/video_player_android
- android/src
- main/java/io/flutter/plugins/videoplayer
- test/java/io/flutter/plugins/videoplayer
- example/android/app/src/test/java/io/flutter/plugins/videoplayerexample
6 files changed
+136
-38
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
| |||
Lines changed: 49 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
48 | 47 | | |
49 | 48 | | |
50 | 49 | | |
51 | | - | |
52 | | - | |
53 | | - | |
| 50 | + | |
54 | 51 | | |
55 | 52 | | |
56 | 53 | | |
57 | 54 | | |
58 | 55 | | |
59 | 56 | | |
60 | 57 | | |
| 58 | + | |
| 59 | + | |
61 | 60 | | |
62 | 61 | | |
| 62 | + | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
66 | 70 | | |
67 | 71 | | |
68 | 72 | | |
69 | 73 | | |
70 | | - | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
75 | 79 | | |
76 | | - | |
| 80 | + | |
77 | 81 | | |
78 | 82 | | |
79 | 83 | | |
| |||
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
86 | | - | |
| 90 | + | |
87 | 91 | | |
88 | 92 | | |
89 | 93 | | |
| |||
96 | 100 | | |
97 | 101 | | |
98 | 102 | | |
99 | | - | |
| 103 | + | |
100 | 104 | | |
101 | 105 | | |
102 | 106 | | |
103 | 107 | | |
104 | | - | |
| 108 | + | |
105 | 109 | | |
106 | 110 | | |
107 | 111 | | |
| |||
169 | 173 | | |
170 | 174 | | |
171 | 175 | | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
172 | 210 | | |
173 | 211 | | |
174 | 212 | | |
| |||
186 | 224 | | |
187 | 225 | | |
188 | 226 | | |
189 | | - | |
190 | | - | |
| 227 | + | |
191 | 228 | | |
192 | 229 | | |
193 | 230 | | |
| |||
334 | 371 | | |
335 | 372 | | |
336 | 373 | | |
337 | | - | |
| 374 | + | |
338 | 375 | | |
339 | | - | |
340 | | - | |
341 | | - | |
342 | 376 | | |
343 | 377 | | |
344 | 378 | | |
| |||
Lines changed: 69 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
11 | 15 | | |
12 | 16 | | |
13 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
14 | 21 | | |
15 | 22 | | |
16 | 23 | | |
| |||
29 | 36 | | |
30 | 37 | | |
31 | 38 | | |
32 | | - | |
| 39 | + | |
| 40 | + | |
33 | 41 | | |
34 | 42 | | |
35 | 43 | | |
36 | 44 | | |
| 45 | + | |
37 | 46 | | |
38 | 47 | | |
39 | 48 | | |
| |||
83 | 92 | | |
84 | 93 | | |
85 | 94 | | |
86 | | - | |
| 95 | + | |
87 | 96 | | |
88 | 97 | | |
89 | 98 | | |
| |||
93 | 102 | | |
94 | 103 | | |
95 | 104 | | |
96 | | - | |
| 105 | + | |
97 | 106 | | |
98 | 107 | | |
99 | 108 | | |
| |||
107 | 116 | | |
108 | 117 | | |
109 | 118 | | |
110 | | - | |
111 | | - | |
| 119 | + | |
112 | 120 | | |
113 | 121 | | |
114 | 122 | | |
| |||
144 | 152 | | |
145 | 153 | | |
146 | 154 | | |
147 | | - | |
148 | 155 | | |
149 | 156 | | |
150 | 157 | | |
| |||
200 | 207 | | |
201 | 208 | | |
202 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
203 | 266 | | |
204 | 267 | | |
205 | 268 | | |
| |||
Lines changed: 11 additions & 15 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
38 | 37 | | |
39 | 38 | | |
40 | 39 | | |
41 | | - | |
42 | | - | |
| 40 | + | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
| |||
52 | 50 | | |
53 | 51 | | |
54 | 52 | | |
55 | | - | |
56 | | - | |
57 | | - | |
| 53 | + | |
58 | 54 | | |
59 | 55 | | |
60 | 56 | | |
| |||
66 | 62 | | |
67 | 63 | | |
68 | 64 | | |
69 | | - | |
| 65 | + | |
70 | 66 | | |
71 | 67 | | |
72 | 68 | | |
| |||
85 | 81 | | |
86 | 82 | | |
87 | 83 | | |
88 | | - | |
| 84 | + | |
89 | 85 | | |
90 | 86 | | |
91 | 87 | | |
| |||
111 | 107 | | |
112 | 108 | | |
113 | 109 | | |
114 | | - | |
| 110 | + | |
115 | 111 | | |
116 | 112 | | |
117 | 113 | | |
| |||
135 | 131 | | |
136 | 132 | | |
137 | 133 | | |
138 | | - | |
| 134 | + | |
139 | 135 | | |
140 | 136 | | |
141 | 137 | | |
| |||
164 | 160 | | |
165 | 161 | | |
166 | 162 | | |
167 | | - | |
| 163 | + | |
168 | 164 | | |
169 | 165 | | |
170 | 166 | | |
| |||
193 | 189 | | |
194 | 190 | | |
195 | 191 | | |
196 | | - | |
| 192 | + | |
197 | 193 | | |
198 | 194 | | |
199 | 195 | | |
| |||
222 | 218 | | |
223 | 219 | | |
224 | 220 | | |
225 | | - | |
| 221 | + | |
226 | 222 | | |
227 | 223 | | |
228 | 224 | | |
| |||
251 | 247 | | |
252 | 248 | | |
253 | 249 | | |
254 | | - | |
| 250 | + | |
255 | 251 | | |
256 | 252 | | |
257 | 253 | | |
| |||
296 | 292 | | |
297 | 293 | | |
298 | 294 | | |
299 | | - | |
| 295 | + | |
300 | 296 | | |
301 | 297 | | |
302 | 298 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
0 commit comments