Skip to content

[Impeller] Do not log VK_ERROR_SURFACE_LOST_KHR errors returned by vkAcquireNextImageKHR#183338

Merged
auto-submit[bot] merged 2 commits into
flutter:masterfrom
jason-simmons:pr_183288_b
Mar 10, 2026
Merged

[Impeller] Do not log VK_ERROR_SURFACE_LOST_KHR errors returned by vkAcquireNextImageKHR#183338
auto-submit[bot] merged 2 commits into
flutter:masterfrom
jason-simmons:pr_183288_b

Conversation

@jason-simmons

Copy link
Copy Markdown
Member

Android may use this error code to indicate situations that are recoverable (such as a temporary failure to dequeue a buffer). This PR removes this error from the validation log to reduce noise in the logs.

See #183288

…AcquireNextImageKHR

Android may use this error code to indicate situations that are recoverable
(such as a temporary failure to dequeue a buffer).  This PR removes this error
from the validation log to reduce noise in the logs.

See flutter#183288
@jason-simmons
jason-simmons requested a review from gaaclarke March 7, 2026 00:21
@flutter-dashboard

Copy link
Copy Markdown

It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging.

If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix?

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group.

@github-actions github-actions Bot added engine flutter/engine related. See also e: labels. e: impeller Impeller rendering backend issues and features requests labels Mar 7, 2026
@jason-simmons

Copy link
Copy Markdown
Member Author

Testing: this change is visible in the log output of SwapchainTest.NoFenceWaitAfterAcquireNextImageFailure

@gaaclarke gaaclarke left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the AcquireNextDrawable function to handle the VK_ERROR_SURFACE_LOST_KHR error. This error is now treated as a recoverable condition that doesn't require swapchain recreation, which prevents logging an error. This change is intended to reduce log noise on Android, where this error can be a temporary and recoverable issue.

@jason-simmons jason-simmons added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 10, 2026
@auto-submit
auto-submit Bot added this pull request to the merge queue Mar 10, 2026
Merged via the queue into flutter:master with commit dad1d08 Mar 10, 2026
185 checks passed
@flutter-dashboard flutter-dashboard Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Mar 10, 2026
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 10, 2026
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Mar 10, 2026
Roll Flutter from 2ec61af30672 to 195ae7b3a122 (36 revisions)

flutter/flutter@2ec61af...195ae7b

2026-03-10 [email protected] [web] Updates to the README (flutter/flutter#176292)
2026-03-10 [email protected] [Impeller] Do not log VK_ERROR_SURFACE_LOST_KHR errors returned by vkAcquireNextImageKHR (flutter/flutter#183338)
2026-03-10 [email protected] DlDeferredImageGPUImpeller::ImageWrapper texture thread safety improvements (flutter/flutter#183429)
2026-03-10 [email protected] refactor: remove material imports from system_context_menu_test, table_test (flutter/flutter#183368)
2026-03-10 [email protected] refactor: remove material from baseline_test, slivers_test (flutter/flutter#183367)
2026-03-10 [email protected] Migrated circle sdf to euclidean 2d derivative (flutter/flutter#183184)
2026-03-10 [email protected] Roll Packages from c717018 to ee460d6 (2 revisions) (flutter/flutter#183451)
2026-03-10 [email protected] Roll Skia from 68f24903b592 to 4b35832cc7ea (1 revision) (flutter/flutter#183449)
2026-03-10 [email protected] Roll Skia from 8eda160375ea to 68f24903b592 (1 revision) (flutter/flutter#183444)
2026-03-10 [email protected] Roll Skia from e7b957806202 to 8eda160375ea (2 revisions) (flutter/flutter#183440)
2026-03-10 [email protected] Roll Fuchsia Linux SDK from ox-II3wPpa818y78_... to 8C_qfgWgoNhkV0_Mn... (flutter/flutter#183437)
2026-03-10 [email protected] Roll Skia from 887df915a95e to e7b957806202 (1 revision) (flutter/flutter#183434)
2026-03-10 [email protected] Remove material from scrollable_test.dart (flutter/flutter#181429)
2026-03-09 [email protected] Update 'a: text input' globs (flutter/flutter#183405)
2026-03-09 [email protected] Roll Skia from 3aa442e0624a to 887df915a95e (7 revisions) (flutter/flutter#183423)
2026-03-09 [email protected] Adds geometry dirty nodes (flutter/flutter#180375)
2026-03-09 [email protected] Roll Dart SDK from 5b1aa4f8db14 to ebef6c849489 (1 revision) (flutter/flutter#183417)
2026-03-09 [email protected] Add Alexander Dmitriev to AUTHORS (flutter/flutter#183357)
2026-03-09 [email protected] Update org triage (flutter/flutter#183254)
2026-03-09 [email protected] [Android] Avoid plugin auto-registration during FlutterFragmentActivity recreate timing window (flutter/flutter#182963)
2026-03-09 [email protected] Standardize skia includes. (flutter/flutter#183404)
2026-03-09 [email protected] Add a note to `arcTo` docs about the 2PI drawing angle issue (flutter/flutter#183293)
2026-03-09 [email protected] Roll pub packages (flutter/flutter#183411)
2026-03-09 [email protected] [ Tool ] Fix --print-dtd not working for web targets (flutter/flutter#183171)
2026-03-09 [email protected] Add await or ignore lint to flutter_driver unawaited callsites (flutter/flutter#183334)
2026-03-09 [email protected] Cleanup MockVulkan when the vulkan instance is destroyed (flutter/flutter#183324)
2026-03-09 [email protected] Updates tests commit (flutter/flutter#183301)
2026-03-09 [email protected] Implements `ClipRSuperellipse` on backdrop filter on platform view (flutter/flutter#182643)
2026-03-09 [email protected] Roll Skia from ea4fd0e1472a to 3aa442e0624a (1 revision) (flutter/flutter#183397)
2026-03-09 [email protected] Roll Dart SDK from 050b2f646425 to 5b1aa4f8db14 (1 revision) (flutter/flutter#183393)
2026-03-09 [email protected] Roll Packages from fe3de64 to c717018 (10 revisions) (flutter/flutter#183396)
2026-03-09 [email protected] Roll Skia from a83dca75c531 to ea4fd0e1472a (1 revision) (flutter/flutter#183389)
2026-03-09 [email protected] Roll Skia from 254e44141861 to a83dca75c531 (7 revisions) (flutter/flutter#183388)
2026-03-09 [email protected] Roll Fuchsia Linux SDK from giLoee6arX5CRHuRh... to ox-II3wPpa818y78_... (flutter/flutter#183386)
2026-03-09 [email protected] Roll Dart SDK from 1604910613c7 to 050b2f646425 (1 revision) (flutter/flutter#183383)
2026-03-08 [email protected] Roll Skia from af994ae4d990 to 254e44141861 (2 revisions) (flutter/flutter#183377)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
...
xxxOVALxxx pushed a commit to xxxOVALxxx/flutter that referenced this pull request Mar 10, 2026
…AcquireNextImageKHR (flutter#183338)

Android may use this error code to indicate situations that are
recoverable (such as a temporary failure to dequeue a buffer). This PR
removes this error from the validation log to reduce noise in the logs.

See flutter#183288
okorohelijah pushed a commit to okorohelijah/packages that referenced this pull request Mar 26, 2026
…r#11222)

Roll Flutter from 2ec61af30672 to 195ae7b3a122 (36 revisions)

flutter/flutter@2ec61af...195ae7b

2026-03-10 [email protected] [web] Updates to the README (flutter/flutter#176292)
2026-03-10 [email protected] [Impeller] Do not log VK_ERROR_SURFACE_LOST_KHR errors returned by vkAcquireNextImageKHR (flutter/flutter#183338)
2026-03-10 [email protected] DlDeferredImageGPUImpeller::ImageWrapper texture thread safety improvements (flutter/flutter#183429)
2026-03-10 [email protected] refactor: remove material imports from system_context_menu_test, table_test (flutter/flutter#183368)
2026-03-10 [email protected] refactor: remove material from baseline_test, slivers_test (flutter/flutter#183367)
2026-03-10 [email protected] Migrated circle sdf to euclidean 2d derivative (flutter/flutter#183184)
2026-03-10 [email protected] Roll Packages from c717018 to ee460d6 (2 revisions) (flutter/flutter#183451)
2026-03-10 [email protected] Roll Skia from 68f24903b592 to 4b35832cc7ea (1 revision) (flutter/flutter#183449)
2026-03-10 [email protected] Roll Skia from 8eda160375ea to 68f24903b592 (1 revision) (flutter/flutter#183444)
2026-03-10 [email protected] Roll Skia from e7b957806202 to 8eda160375ea (2 revisions) (flutter/flutter#183440)
2026-03-10 [email protected] Roll Fuchsia Linux SDK from ox-II3wPpa818y78_... to 8C_qfgWgoNhkV0_Mn... (flutter/flutter#183437)
2026-03-10 [email protected] Roll Skia from 887df915a95e to e7b957806202 (1 revision) (flutter/flutter#183434)
2026-03-10 [email protected] Remove material from scrollable_test.dart (flutter/flutter#181429)
2026-03-09 [email protected] Update 'a: text input' globs (flutter/flutter#183405)
2026-03-09 [email protected] Roll Skia from 3aa442e0624a to 887df915a95e (7 revisions) (flutter/flutter#183423)
2026-03-09 [email protected] Adds geometry dirty nodes (flutter/flutter#180375)
2026-03-09 [email protected] Roll Dart SDK from 5b1aa4f8db14 to ebef6c849489 (1 revision) (flutter/flutter#183417)
2026-03-09 [email protected] Add Alexander Dmitriev to AUTHORS (flutter/flutter#183357)
2026-03-09 [email protected] Update org triage (flutter/flutter#183254)
2026-03-09 [email protected] [Android] Avoid plugin auto-registration during FlutterFragmentActivity recreate timing window (flutter/flutter#182963)
2026-03-09 [email protected] Standardize skia includes. (flutter/flutter#183404)
2026-03-09 [email protected] Add a note to `arcTo` docs about the 2PI drawing angle issue (flutter/flutter#183293)
2026-03-09 [email protected] Roll pub packages (flutter/flutter#183411)
2026-03-09 [email protected] [ Tool ] Fix --print-dtd not working for web targets (flutter/flutter#183171)
2026-03-09 [email protected] Add await or ignore lint to flutter_driver unawaited callsites (flutter/flutter#183334)
2026-03-09 [email protected] Cleanup MockVulkan when the vulkan instance is destroyed (flutter/flutter#183324)
2026-03-09 [email protected] Updates tests commit (flutter/flutter#183301)
2026-03-09 [email protected] Implements `ClipRSuperellipse` on backdrop filter on platform view (flutter/flutter#182643)
2026-03-09 [email protected] Roll Skia from ea4fd0e1472a to 3aa442e0624a (1 revision) (flutter/flutter#183397)
2026-03-09 [email protected] Roll Dart SDK from 050b2f646425 to 5b1aa4f8db14 (1 revision) (flutter/flutter#183393)
2026-03-09 [email protected] Roll Packages from fe3de64 to c717018 (10 revisions) (flutter/flutter#183396)
2026-03-09 [email protected] Roll Skia from a83dca75c531 to ea4fd0e1472a (1 revision) (flutter/flutter#183389)
2026-03-09 [email protected] Roll Skia from 254e44141861 to a83dca75c531 (7 revisions) (flutter/flutter#183388)
2026-03-09 [email protected] Roll Fuchsia Linux SDK from giLoee6arX5CRHuRh... to ox-II3wPpa818y78_... (flutter/flutter#183386)
2026-03-09 [email protected] Roll Dart SDK from 1604910613c7 to 050b2f646425 (1 revision) (flutter/flutter#183383)
2026-03-08 [email protected] Roll Skia from af994ae4d990 to 254e44141861 (2 revisions) (flutter/flutter#183377)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
...
mboetger pushed a commit to mboetger/flutter that referenced this pull request Mar 26, 2026
…AcquireNextImageKHR (flutter#183338)

Android may use this error code to indicate situations that are
recoverable (such as a temporary failure to dequeue a buffer). This PR
removes this error from the validation log to reduce noise in the logs.

See flutter#183288
ahmedsameha1 pushed a commit to ahmedsameha1/flutter that referenced this pull request Apr 14, 2026
…AcquireNextImageKHR (flutter#183338)

Android may use this error code to indicate situations that are
recoverable (such as a temporary failure to dequeue a buffer). This PR
removes this error from the validation log to reduce noise in the logs.

See flutter#183288
creatorpiyush pushed a commit to creatorpiyush/packages that referenced this pull request Jun 10, 2026
…r#11222)

Roll Flutter from 2ec61af30672 to 195ae7b3a122 (36 revisions)

flutter/flutter@2ec61af...195ae7b

2026-03-10 [email protected] [web] Updates to the README (flutter/flutter#176292)
2026-03-10 [email protected] [Impeller] Do not log VK_ERROR_SURFACE_LOST_KHR errors returned by vkAcquireNextImageKHR (flutter/flutter#183338)
2026-03-10 [email protected] DlDeferredImageGPUImpeller::ImageWrapper texture thread safety improvements (flutter/flutter#183429)
2026-03-10 [email protected] refactor: remove material imports from system_context_menu_test, table_test (flutter/flutter#183368)
2026-03-10 [email protected] refactor: remove material from baseline_test, slivers_test (flutter/flutter#183367)
2026-03-10 [email protected] Migrated circle sdf to euclidean 2d derivative (flutter/flutter#183184)
2026-03-10 [email protected] Roll Packages from c717018 to ee460d6 (2 revisions) (flutter/flutter#183451)
2026-03-10 [email protected] Roll Skia from 68f24903b592 to 4b35832cc7ea (1 revision) (flutter/flutter#183449)
2026-03-10 [email protected] Roll Skia from 8eda160375ea to 68f24903b592 (1 revision) (flutter/flutter#183444)
2026-03-10 [email protected] Roll Skia from e7b957806202 to 8eda160375ea (2 revisions) (flutter/flutter#183440)
2026-03-10 [email protected] Roll Fuchsia Linux SDK from ox-II3wPpa818y78_... to 8C_qfgWgoNhkV0_Mn... (flutter/flutter#183437)
2026-03-10 [email protected] Roll Skia from 887df915a95e to e7b957806202 (1 revision) (flutter/flutter#183434)
2026-03-10 [email protected] Remove material from scrollable_test.dart (flutter/flutter#181429)
2026-03-09 [email protected] Update 'a: text input' globs (flutter/flutter#183405)
2026-03-09 [email protected] Roll Skia from 3aa442e0624a to 887df915a95e (7 revisions) (flutter/flutter#183423)
2026-03-09 [email protected] Adds geometry dirty nodes (flutter/flutter#180375)
2026-03-09 [email protected] Roll Dart SDK from 5b1aa4f8db14 to ebef6c849489 (1 revision) (flutter/flutter#183417)
2026-03-09 [email protected] Add Alexander Dmitriev to AUTHORS (flutter/flutter#183357)
2026-03-09 [email protected] Update org triage (flutter/flutter#183254)
2026-03-09 [email protected] [Android] Avoid plugin auto-registration during FlutterFragmentActivity recreate timing window (flutter/flutter#182963)
2026-03-09 [email protected] Standardize skia includes. (flutter/flutter#183404)
2026-03-09 [email protected] Add a note to `arcTo` docs about the 2PI drawing angle issue (flutter/flutter#183293)
2026-03-09 [email protected] Roll pub packages (flutter/flutter#183411)
2026-03-09 [email protected] [ Tool ] Fix --print-dtd not working for web targets (flutter/flutter#183171)
2026-03-09 [email protected] Add await or ignore lint to flutter_driver unawaited callsites (flutter/flutter#183334)
2026-03-09 [email protected] Cleanup MockVulkan when the vulkan instance is destroyed (flutter/flutter#183324)
2026-03-09 [email protected] Updates tests commit (flutter/flutter#183301)
2026-03-09 [email protected] Implements `ClipRSuperellipse` on backdrop filter on platform view (flutter/flutter#182643)
2026-03-09 [email protected] Roll Skia from ea4fd0e1472a to 3aa442e0624a (1 revision) (flutter/flutter#183397)
2026-03-09 [email protected] Roll Dart SDK from 050b2f646425 to 5b1aa4f8db14 (1 revision) (flutter/flutter#183393)
2026-03-09 [email protected] Roll Packages from fe3de64 to c717018 (10 revisions) (flutter/flutter#183396)
2026-03-09 [email protected] Roll Skia from a83dca75c531 to ea4fd0e1472a (1 revision) (flutter/flutter#183389)
2026-03-09 [email protected] Roll Skia from 254e44141861 to a83dca75c531 (7 revisions) (flutter/flutter#183388)
2026-03-09 [email protected] Roll Fuchsia Linux SDK from giLoee6arX5CRHuRh... to ox-II3wPpa818y78_... (flutter/flutter#183386)
2026-03-09 [email protected] Roll Dart SDK from 1604910613c7 to 050b2f646425 (1 revision) (flutter/flutter#183383)
2026-03-08 [email protected] Roll Skia from af994ae4d990 to 254e44141861 (2 revisions) (flutter/flutter#183377)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected] on the revert to ensure that a human
is aware of the problem.

To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
...
sero583 added a commit to sero583/flutter that referenced this pull request Jul 16, 2026
…urce exhaustion

Stability fixes for the Vulkan backend discovered through sustained
stress testing on AMD RDNA 2 hardware and Mesa dzn (Vulkan on D3D12 in
WSL2), first published as part of flutter#183382 and rebased onto the current
FenceWaiterVK submission architecture.

Device loss handling:
- ContextVK gains an atomic device_lost_ flag. CreateCommandBuffer()
  and CommandQueueVK::Submit() short-circuit once the device is lost,
  since any Vulkan call on a driver that entered a corrupted OOM state
  can access-fault inside the ICD.
- On vkQueueSubmit failure, tracked objects are abandoned without
  making Vulkan calls (AbandonForDriverCrash on command pools and
  descriptor pools), the device is marked lost, and per-heap memory
  budgets are logged for diagnosis.
- FenceWaiterVK releases rather than destroys the fence when the
  submit callback fails; some drivers partially track the fence even
  though the submission failed, and vkDestroyFence then crashes
  (VUID-vkDestroyFence-fence-01120 observed on AMD).

Submission backpressure:
- CommandQueueVK caps concurrent in-flight submissions (3) with a
  condition variable, releasing the slot from the fence completion
  callback. Prevents unbounded host memory growth when the CPU
  outpaces the GPU.
- ContextVK::FlushCommandBuffers() submits in chunks of 64 to keep
  per-submit driver allocations bounded on frames that accumulate very
  large command buffer counts.
- GPUSurfaceVulkanImpeller (embedder-managed image path) adds a
  two-entry frame fence ring mirroring the KHR swapchain's
  backpressure, with a bounded wait that skips the frame under extreme
  GPU pressure. Image views for embedder images are now cached instead
  of being allocated (and leaked) per frame, and in-flight frames are
  drained before views are destroyed on resize or teardown.

Command pool lifecycle:
- BackgroundCommandPoolVK releases its handles without Vulkan calls
  when the recycler is gone; the device may already be destroyed at
  that point. This is the same class of teardown race as the
  CommandPoolVK destructor fix that landed in flutter#186749.
- The recycled pool list is capped at 8 entries, evicting oldest
  first.
- unused_command_buffers_ is annotated IPLR_GUARDED_BY(pool_mutex_).

Descriptor pools:
- Reset via vkResetDescriptorPool on reclaim. Reclaimed pools
  previously stayed at capacity and produced
  VK_ERROR_OUT_OF_POOL_MEMORY on every reuse.
- Pool maxSets is now the sum of the per-type pool sizes.

Barrier and render pass correctness:
- Six barrier fixes in the blit pass: pre-copy barriers use transfer
  stage and access flags, post-copy barriers flush transfer writes,
  and mipmap generation barriers match the actual current layout.
  Fixes corrupted glyph atlases and SYNC-HAZARD-WRITE-AFTER-WRITE
  reported by the synchronization validation layer on AMD RDNA 2.
- RenderPassBuilderVK moves subpass dependencies to a counted builder,
  drops eByRegion from external (VK_SUBPASS_EXTERNAL) dependencies
  where it has no meaning per Vulkan spec section 7.1, and gains
  SetFramebufferFetchEnabled() so input attachment references and
  self-dependencies are omitted on drivers without framebuffer fetch
  support. The flag is wired through pipeline and render pass creation
  and the compat render pass used for PSO construction.

Driver workarounds:
- DriverInfoVK exposes GetDriverID() (Vulkan 1.2) and detects Mesa
  dzn.
- New skip_sub_region_buffer_to_image_copy workaround: Mesa dzn
  reports minImageTransferGranularity of (0,0,0) and corrupts textures
  on sub-region buffer-to-image copies; the blit pass stages such
  copies through a full-size temporary texture.

Memory management:
- The VMA buffer pool is capped at 256 blocks (about 1 GB); the pool
  otherwise grows without bound when high-water-mark demand spikes and
  fragmentation prevents block reuse.
- Image allocation failure paths no longer leak the VMA allocation
  when image view creation fails.
- On Windows, the working set is periodically trimmed when Resizable
  BAR mappings inflate RSS far beyond actual VMA usage (gated by
  cooldown, RSS threshold, and RSS-to-VMA ratio).

KHR swapchain robustness:
- The synchronizer fence is re-signaled with an empty submit on every
  early return after a failed or unusable acquireNextImageKHR
  (including the surface-lost path added in flutter#183338). The fence was
  reset by WaitForFence, and without a new signal the next wrap-around
  to the same synchronizer deadlocks in waitForFences with an infinite
  timeout.
- AcquireNextDrawable short-circuits when the device is marked lost.
- Zero-extent surfaces (minimized windows) skip the frame instead of
  attempting swapchain recreation, preserving recovery on restore.
- The render target cache is capped at 256 entries with
  used-this-frame-first eviction.

Embedder mode:
- CapabilitiesVK enumerates instance layers in embedder mode so that
  validation layers can be detected and enabled when requested.
sero583 added a commit to sero583/flutter that referenced this pull request Jul 16, 2026
…urce exhaustion

Stability fixes for the Vulkan backend discovered through sustained
stress testing on AMD RDNA 2 hardware and Mesa dzn (Vulkan on D3D12 in
WSL2), first published as part of flutter#183382 and rebased onto the current
FenceWaiterVK submission architecture.

Device loss handling:
- ContextVK gains an atomic device_lost_ flag. CreateCommandBuffer()
  and CommandQueueVK::Submit() short-circuit once the device is lost,
  since any Vulkan call on a driver that entered a corrupted OOM state
  can access-fault inside the ICD.
- On vkQueueSubmit failure, tracked objects are abandoned without
  making Vulkan calls (AbandonForDriverCrash on command pools and
  descriptor pools), the device is marked lost, and per-heap memory
  budgets are logged for diagnosis.
- FenceWaiterVK releases rather than destroys the fence when the
  submit callback fails; some drivers partially track the fence even
  though the submission failed, and vkDestroyFence then crashes
  (VUID-vkDestroyFence-fence-01120 observed on AMD).

Submission backpressure:
- CommandQueueVK caps concurrent in-flight submissions (3) with a
  condition variable, releasing the slot from the fence completion
  callback. Prevents unbounded host memory growth when the CPU
  outpaces the GPU.
- ContextVK::FlushCommandBuffers() submits in chunks of 64 to keep
  per-submit driver allocations bounded on frames that accumulate very
  large command buffer counts.
- GPUSurfaceVulkanImpeller (embedder-managed image path) adds a
  two-entry frame fence ring mirroring the KHR swapchain's
  backpressure, with a bounded wait that skips the frame under extreme
  GPU pressure. Image views for embedder images are now cached instead
  of being allocated (and leaked) per frame, and in-flight frames are
  drained before views are destroyed on resize or teardown.

Command pool lifecycle:
- BackgroundCommandPoolVK releases its handles without Vulkan calls
  when the recycler is gone; the device may already be destroyed at
  that point. This is the same class of teardown race as the
  CommandPoolVK destructor fix that landed in flutter#186749.
- The recycled pool list is capped at 8 entries, evicting oldest
  first.
- unused_command_buffers_ is annotated IPLR_GUARDED_BY(pool_mutex_).

Descriptor pools:
- Reset via vkResetDescriptorPool on reclaim. Reclaimed pools
  previously stayed at capacity and produced
  VK_ERROR_OUT_OF_POOL_MEMORY on every reuse.

Barrier and render pass correctness:
- Six barrier fixes in the blit pass: pre-copy barriers use transfer
  stage and access flags, post-copy barriers flush transfer writes,
  and mipmap generation barriers match the actual current layout.
  Fixes corrupted glyph atlases and SYNC-HAZARD-WRITE-AFTER-WRITE
  reported by the synchronization validation layer on AMD RDNA 2.
- RenderPassBuilderVK moves subpass dependencies to a counted builder,
  drops eByRegion from external (VK_SUBPASS_EXTERNAL) dependencies
  where it has no meaning per Vulkan spec section 7.1, and gains
  SetFramebufferFetchEnabled() so input attachment references and
  self-dependencies are omitted on drivers without framebuffer fetch
  support. The flag is wired through pipeline and render pass creation
  and the compat render pass used for PSO construction.

Driver workarounds:
- DriverInfoVK exposes GetDriverID() (Vulkan 1.2) and detects Mesa
  dzn.
- New skip_sub_region_buffer_to_image_copy workaround: Mesa dzn
  reports minImageTransferGranularity of (0,0,0) and corrupts textures
  on sub-region buffer-to-image copies; the blit pass stages such
  copies through a full-size temporary texture.

Memory management:
- The VMA buffer pool is capped at 256 blocks (about 1 GB); the pool
  otherwise grows without bound when high-water-mark demand spikes and
  fragmentation prevents block reuse.
- Image allocation failure paths no longer leak the VMA allocation
  when image view creation fails.
- On Windows, the working set is periodically trimmed when Resizable
  BAR mappings inflate RSS far beyond actual VMA usage (gated by
  cooldown, RSS threshold, and RSS-to-VMA ratio).

KHR swapchain robustness:
- The synchronizer fence is re-signaled with an empty submit on every
  early return after a failed or unusable acquireNextImageKHR
  (including the surface-lost path added in flutter#183338). The fence was
  reset by WaitForFence, and without a new signal the next wrap-around
  to the same synchronizer deadlocks in waitForFences with an infinite
  timeout.
- AcquireNextDrawable short-circuits when the device is marked lost.
- Zero-extent surfaces (minimized windows) skip the frame instead of
  attempting swapchain recreation, preserving recovery on restore.

Embedder mode:
- CapabilitiesVK enumerates instance layers in embedder mode so that
  validation layers can be detected and enabled when requested.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

e: impeller Impeller rendering backend issues and features requests engine flutter/engine related. See also e: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants