Commit 058851b
authored
_**WIP**: We do not plan to land this PR until the next stable release (>= April 3rd 2024)_.
Work towards 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#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 e35f291 commit 058851b
File tree
6 files changed
+47
-79
lines changed- packages/camera/camera_android
- android/src
- main/java/io/flutter/plugins/camera
- test/java/io/flutter/plugins/camera
6 files changed
+47
-79
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
1 | 5 | | |
2 | 6 | | |
3 | 7 | | |
| |||
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
39 | | - | |
| 43 | + | |
40 | 44 | | |
41 | 45 | | |
42 | 46 | | |
| |||
Lines changed: 16 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| |||
63 | 62 | | |
64 | 63 | | |
65 | 64 | | |
66 | | - | |
| 65 | + | |
67 | 66 | | |
68 | 67 | | |
69 | 68 | | |
| |||
113 | 112 | | |
114 | 113 | | |
115 | 114 | | |
116 | | - | |
| 115 | + | |
117 | 116 | | |
118 | 117 | | |
119 | 118 | | |
| |||
214 | 213 | | |
215 | 214 | | |
216 | 215 | | |
217 | | - | |
| 216 | + | |
218 | 217 | | |
219 | 218 | | |
220 | 219 | | |
221 | 220 | | |
222 | | - | |
223 | 221 | | |
224 | 222 | | |
225 | 223 | | |
226 | 224 | | |
227 | | - | |
| 225 | + | |
228 | 226 | | |
229 | 227 | | |
230 | 228 | | |
| |||
243 | 241 | | |
244 | 242 | | |
245 | 243 | | |
246 | | - | |
247 | 244 | | |
248 | 245 | | |
249 | 246 | | |
| |||
256 | 253 | | |
257 | 254 | | |
258 | 255 | | |
259 | | - | |
260 | 256 | | |
261 | 257 | | |
262 | 258 | | |
| |||
307 | 303 | | |
308 | 304 | | |
309 | 305 | | |
310 | | - | |
311 | | - | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
312 | 309 | | |
313 | 310 | | |
314 | 311 | | |
| |||
386 | 383 | | |
387 | 384 | | |
388 | 385 | | |
389 | | - | |
| 386 | + | |
| 387 | + | |
390 | 388 | | |
391 | 389 | | |
392 | 390 | | |
| |||
470 | 468 | | |
471 | 469 | | |
472 | 470 | | |
473 | | - | |
474 | | - | |
| 471 | + | |
475 | 472 | | |
476 | 473 | | |
477 | | - | |
| 474 | + | |
478 | 475 | | |
479 | 476 | | |
480 | 477 | | |
| |||
1160 | 1157 | | |
1161 | 1158 | | |
1162 | 1159 | | |
1163 | | - | |
| 1160 | + | |
| 1161 | + | |
1164 | 1162 | | |
1165 | 1163 | | |
1166 | 1164 | | |
| |||
1193 | 1191 | | |
1194 | 1192 | | |
1195 | 1193 | | |
1196 | | - | |
1197 | 1194 | | |
1198 | 1195 | | |
1199 | 1196 | | |
| |||
1361 | 1358 | | |
1362 | 1359 | | |
1363 | 1360 | | |
1364 | | - | |
1365 | 1361 | | |
1366 | 1362 | | |
1367 | 1363 | | |
1368 | 1364 | | |
1369 | 1365 | | |
1370 | | - | |
| 1366 | + | |
| 1367 | + | |
1371 | 1368 | | |
1372 | 1369 | | |
1373 | 1370 | | |
| |||
1400 | 1397 | | |
1401 | 1398 | | |
1402 | 1399 | | |
1403 | | - | |
| 1400 | + | |
1404 | 1401 | | |
1405 | 1402 | | |
1406 | 1403 | | |
| |||
Lines changed: 4 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
396 | | - | |
397 | | - | |
| 396 | + | |
398 | 397 | | |
399 | | - | |
400 | | - | |
| 398 | + | |
401 | 399 | | |
402 | 400 | | |
403 | 401 | | |
404 | 402 | | |
405 | 403 | | |
406 | 404 | | |
407 | 405 | | |
408 | | - | |
| 406 | + | |
409 | 407 | | |
410 | 408 | | |
411 | 409 | | |
412 | 410 | | |
413 | 411 | | |
414 | 412 | | |
415 | 413 | | |
416 | | - | |
| 414 | + | |
417 | 415 | | |
418 | 416 | | |
419 | 417 | | |
| |||
0 commit comments