-
Notifications
You must be signed in to change notification settings - Fork 6k
[Impeller] Fix a race between SwapchainImplVK::Present and WaitForFence #49777
[Impeller] Fix a race between SwapchainImplVK::Present and WaitForFence #49777
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). 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. |
The previous implementation used an fml::CountDownLatch to synchronize between FrameSynchronizer::WaitForFence and the task queued by SwapchainImplVK::Present. fml::CountDownLatch:Wait always waits, even if the count is already zero. So the raster thread would deadlock if the present task signals the latch before FrameSynchronizer::WaitForFence enters the wait. This PR instead uses a semaphore that is set each time SwapchainImplVK::Present is called. FrameSynchronizer::WaitForFence will check the semaphore to determine whether a present task is pending and if so wait for its completion.
2f80d6b
to
13e1e3f
Compare
test-exempt: not really testable |
(bonus points for figuring out a way to reliably trigger the deadlock though!) |
I had originally noticed this while running the Lottie animation example from flutter/flutter#139796 with Impeller/Vulkan. On a Pixel 6a the app typically hangs within a few minutes. With this PR I have not seen the hang. |
…141651) flutter/engine@d4b6b7e...021a5ff 2024-01-16 [email protected] [web] Leave blob URLs untouched in TT policy. (flutter/engine#49782) 2024-01-16 [email protected] [Impeller] Fix a race between SwapchainImplVK::Present and WaitForFence (flutter/engine#49777) 2024-01-16 [email protected] Reland "[Windows] Move to FlutterCompositor for rendering" (flutter/engine#49726) 2024-01-16 [email protected] [Impeller] Add an API for sampling strictly within the bounds of the source rect in DrawImageRect (flutter/engine#49696) 2024-01-16 [email protected] [Impeller] Encode directly to command buffer for Vulkan. (flutter/engine#49780) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…isions)" (#141659) Reverts #141651 Initiated by: jonahwilliams This change reverts the following previous change: Original Description: flutter/engine@d4b6b7e...021a5ff 2024-01-16 [email protected] [web] Leave blob URLs untouched in TT policy. (flutter/engine#49782) 2024-01-16 [email protected] [Impeller] Fix a race between SwapchainImplVK::Present and WaitForFence (flutter/engine#49777) 2024-01-16 [email protected] Reland "[Windows] Move to FlutterCompositor for rendering" (flutter/engine#49726) 2024-01-16 [email protected] [Impeller] Add an API for sampling strictly within the bounds of the source rect in DrawImageRect (flutter/engine#49696) 2024-01-16 [email protected] [Impeller] Encode directly to command buffer for Vulkan. (flutter/engine#49780) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…141664) flutter/engine@d4b6b7e...1382ff7 2024-01-16 [email protected] Remove iOS 12 availability checks (flutter/engine#49771) 2024-01-16 [email protected] [Impeller] generate mipmaps for imagefilters (flutter/engine#49794) 2024-01-16 [email protected] [web] Leave blob URLs untouched in TT policy. (flutter/engine#49782) 2024-01-16 [email protected] [Impeller] Fix a race between SwapchainImplVK::Present and WaitForFence (flutter/engine#49777) 2024-01-16 [email protected] Reland "[Windows] Move to FlutterCompositor for rendering" (flutter/engine#49726) 2024-01-16 [email protected] [Impeller] Add an API for sampling strictly within the bounds of the source rect in DrawImageRect (flutter/engine#49696) 2024-01-16 [email protected] [Impeller] Encode directly to command buffer for Vulkan. (flutter/engine#49780) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-engine-flutter-autoroll Please CC [email protected],[email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
The previous implementation used an fml::CountDownLatch to synchronize between FrameSynchronizer::WaitForFence and the task queued by SwapchainImplVK::Present.
fml::CountDownLatch:Wait always waits, even if the count is already zero. So the raster thread would deadlock if the present task signals the latch before FrameSynchronizer::WaitForFence enters the wait.
This PR instead uses a semaphore that is set each time SwapchainImplVK::Present is called. FrameSynchronizer::WaitForFence will check the semaphore to determine whether a present task is pending and if so wait for its completion.