Commit 64a83f4
[Impeller] Retry uncompressed when fixed-rate compression is exhausted (flutter#187586)
Fixes flutter#187564
## Issue
On the Pixel 10 (Tensor G5 / **Imagination PowerVR** GPU), Impeller's
Vulkan backend
crashes the raster thread under GPU pressure:
```
[ERROR:impeller/renderer/backend/vulkan/allocator_vk.cc] Unable to allocate Vulkan Image:
ErrorCompressionExhaustedEXT Type: Texture2D ... Usage: { ShaderRead, RenderTarget }
[ERROR:impeller/renderer/render_target.cc] Could not create color texture.
[ERROR:impeller/renderer/render_target.cc] Render target does not have color attachment at index 0.
F/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid NNNN (1.raster)
```
(In release builds the same failure surfaces as
`[FATAL:flutter/impeller/display_list/canvas.cc(1471)] Check failed:
back_texture. Context is valid:0`
SIGABRT, or a bare SIGSEGV @ 0x20 on the `*.raster` thread.)
### Root cause
Impeller requests **fixed-rate image compression**
(`VkImageCompressionControlEXT`) for
lossy render targets (`CreateOffscreenMSAA`'s color-resolve texture).
When the PowerVR
driver's fixed-rate-compression resources are exhausted,
`vmaCreateImage` returns
`VK_ERROR_COMPRESSION_EXHAUSTED_EXT`. `AllocatedTextureSourceVK` did not
handle this — it
logged and returned an invalid texture, which became a render target
with no color
attachment, and the raster thread then dereferenced the null texture.
This is a regression: it does **not** reproduce on Flutter 3.41.9, but
does on 3.44.x.
It is PowerVR-specific (the error is tied to the driver's compression
resource pool) and
GPU-state-dependent (it fires once cumulative GPU compression pressure
is high enough).
## Fix
`VK_ERROR_COMPRESSION_EXHAUSTED_EXT` is, per the Vulkan spec, only
returned for fixed-rate
compression requests — so retrying the same allocation **without**
compression is always a
valid recovery. On that error, `AllocatedTextureSourceVK` now unlinks
`VkImageCompressionControlEXT` from the create-info chain and retries
`vmaCreateImage` once
uncompressed (logging a one-time warning). The texture is identical,
just stored
uncompressed; the only cost is on the failure path (a small amount of
extra
memory/bandwidth for the affected texture, instead of a crash).
## Tests
- **Unit test** (`allocator_vk_unittests.cc` →
`RetriesUncompressedOnCompressionExhausted`):
extends the Vulkan mock to advertise fixed-rate compression and to fail
the first
compressed `vkCreateImage` with `VK_ERROR_COMPRESSION_EXHAUSTED_EXT`,
then asserts the
allocator returns a **valid** texture and called `vkCreateImage`
**twice** (compressed
attempt + uncompressed retry). Passes; the other allocator tests are
unaffected.
- **On-device A/B** (Pixel 10, locally-built `android_profile_arm64`,
same repro, same
GPU-pressured state):
| Engine | Result |
|---|---|
| Unpatched | `ErrorCompressionExhausted` → **SIGSEGV** on `1.raster`
(crash) |
| Patched | exhaustion → retry → **survives**; logs `Fixed-rate image
compression exhausted; falling back to uncompressed image allocation` |
## Repro
A pure-Flutter app that stacks enough full-screen `BackdropFilter` /
`saveLayer` offscreen
render targets to exhaust the PowerVR compression pool (see
`lib/main.dart` in the linked
repro). Crashes on the unpatched engine; runs on the patched one. Stable
on either with
`--no-enable-impeller`.
## Environment
- Flutter 3.44.x (regressed from 3.41.9)
- Device: Pixel 10, Android 17 (API 37)
- GPU: Imagination PowerVR (Tensor G5); renderer Impeller / Vulkan
## Pre-launch checklist
- [x] Added a unit test (or explained why not possible).
- [x] Listed any breaking changes (none).
- [x] Signed the [CLA](https://cla.developers.google.com/).
---------
Co-authored-by: John "codefu" McDole <codefu@google.com>1 parent 69c8c61 commit 64a83f4
4 files changed
Lines changed: 179 additions & 25 deletions
File tree
- engine/src/flutter/impeller/renderer/backend/vulkan
- test
Lines changed: 56 additions & 25 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
343 | 345 | | |
344 | 346 | | |
345 | 347 | | |
346 | | - | |
347 | | - | |
348 | | - | |
349 | 348 | | |
350 | 349 | | |
351 | 350 | | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
374 | 405 | | |
375 | 406 | | |
376 | 407 | | |
| |||
Lines changed: 37 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
5 | 7 | | |
6 | 8 | | |
7 | 9 | | |
| |||
93 | 95 | | |
94 | 96 | | |
95 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
96 | 133 | | |
97 | 134 | | |
98 | 135 | | |
| |||
Lines changed: 74 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
122 | 122 | | |
123 | 123 | | |
124 | 124 | | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
125 | 128 | | |
126 | 129 | | |
127 | 130 | | |
| |||
242 | 245 | | |
243 | 246 | | |
244 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
245 | 294 | | |
246 | 295 | | |
247 | 296 | | |
| |||
368 | 417 | | |
369 | 418 | | |
370 | 419 | | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
371 | 435 | | |
372 | 436 | | |
373 | 437 | | |
| |||
907 | 971 | | |
908 | 972 | | |
909 | 973 | | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
910 | 982 | | |
911 | 983 | | |
912 | 984 | | |
| |||
1097 | 1169 | | |
1098 | 1170 | | |
1099 | 1171 | | |
| 1172 | + | |
| 1173 | + | |
1100 | 1174 | | |
1101 | 1175 | | |
1102 | 1176 | | |
| |||
Lines changed: 12 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
137 | 148 | | |
138 | 149 | | |
139 | 150 | | |
| |||
151 | 162 | | |
152 | 163 | | |
153 | 164 | | |
| 165 | + | |
154 | 166 | | |
155 | 167 | | |
156 | 168 | | |
| |||
0 commit comments