Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Impeller] Test FenceWaiterVK and fix termination bugs #45870

Merged
merged 25 commits into from
Sep 15, 2023

Conversation

matanlurey
Copy link
Contributor

@matanlurey matanlurey commented Sep 15, 2023

Fixes flutter/flutter#134751, and @jonahwilliams suspects it could be related to a number of other flaky/texture leak scenarios (flutter/flutter#133506 (comment)) that only happen sometimes (i.e. on CI but not real devices), i.e. stuff like:

--- Vulkan Debug Report  ----------------------------------------
|                Severity: Error
|                    Type: { Validation }
|                 ID Name: VUID-vkDestroyBuffer-buffer-00922
|               ID Number: -464217071
|       Queue Breadcrumbs: [NONE]
|  CMD Buffer Breadcrumbs: [NONE]
|         Related Objects: Device [94498356231456] [ImpellerDevice]
|                 Trigger: Validation Error: [ VUID-vkDestroyBuffer-buffer-00922 ] Object 0: handle = 0x55f21cf47d20, name = ImpellerDevice, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xe4549c11 | Cannot call vkDestroyBuffer on VkBuffer 0xbb00000000bb[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to buffer, either directly or via a VkBufferView, must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyBuffer-buffer-00922)
-----------------------------------------------------------------

This PR will look a bit like a mess until the last 2 PRs merge in, but locally it appears to fix fence races/segfaults that I was seeing on CI, including on Linux with validations enabled. We can test it further tomorrow. EDIT: Updated.

@matanlurey matanlurey changed the title [📚 STACKED] Test FenceWaiterVK and fix termination bugs [Impeller] Test FenceWaiterVK and fix termination bugs Sep 15, 2023
@matanlurey matanlurey marked this pull request as ready for review September 15, 2023 17:42
Copy link
Member

@gaaclarke gaaclarke left a comment

Choose a reason for hiding this comment

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

This code is tricky, it looks good to me and the additional tests are an welcome addition. You should get 2 approvals just because it's tricky threading changes.

One minor nit across the board is that auto should only be used if if makes the code easier to read, not out of convenience as per the style guide. We violate this a lot.

impeller/renderer/backend/vulkan/fence_waiter_vk.cc Outdated Show resolved Hide resolved
impeller/renderer/backend/vulkan/fence_waiter_vk.cc Outdated Show resolved Hide resolved
impeller/renderer/backend/vulkan/test/mock_vulkan.cc Outdated Show resolved Hide resolved
Copy link
Member

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

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

LGTM

@matanlurey
Copy link
Contributor Author

@chinmaygarde I have 2 LGTMs, but would prefer you as a third if you're around.

Copy link
Member

@chinmaygarde chinmaygarde left a comment

Choose a reason for hiding this comment

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

Not having static thread analysis annotated synchronization utils for condition variables really hurts the reviewability of this PR. We should patch that in //impeller/base/thread.h. Rather not have to reason about things the compiler can :/

Other than that, just nits.

@@ -377,10 +377,6 @@ void ContextVK::Setup(Settings settings) {
///
auto fence_waiter =
std::shared_ptr<FenceWaiterVK>(new FenceWaiterVK(device_holder));
if (!fence_waiter->IsValid()) {
Copy link
Member

Choose a reason for hiding this comment

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

An invalid fence waiter will no longer invalidate the context now. In the future, if fence waiters cannot be created reliably, the call sites of the users will have to be patched.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is no such thing as an invalid fence waiter, that is, there is no state that ever marks the fence waiter as invalid. I found it misleading that we check a boolean that is effectively constant true - let's it add it back if/when there is such a case?

impeller/renderer/backend/vulkan/fence_waiter_vk.cc Outdated Show resolved Hide resolved
@matanlurey matanlurey added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 15, 2023
@auto-submit auto-submit bot merged commit 06567e1 into flutter:main Sep 15, 2023
27 checks passed
@matanlurey matanlurey deleted the impeller-vk-fence-contract branch September 16, 2023 15:36
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 16, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Sep 16, 2023
…ions) (#134876)

Manual roll requested by [email protected]

flutter/engine@326faf1...30b7e9d

2023-09-15 [email protected] Roll Skia from 7f88bda24f7f to 0057898979a1 (1 revision) (flutter/engine#45904)
2023-09-15 [email protected] [Impeller] Test `FenceWaiterVK` and fix termination bugs (flutter/engine#45870)
2023-09-15 [email protected] Roll Dart SDK from a5ee0055cf20 to e9452310189b (1 revision) (flutter/engine#45902)
2023-09-15 [email protected] Roll Skia from 4f26f22daa4b to 7f88bda24f7f (5 revisions) (flutter/engine#45901)
2023-09-15 [email protected] [Impeller] dont cache failed render target allocations. (flutter/engine#45895)

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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Mairramer pushed a commit to Mairramer/flutter that referenced this pull request Oct 10, 2023
…ions) (flutter#134876)

Manual roll requested by [email protected]

flutter/engine@326faf1...30b7e9d

2023-09-15 [email protected] Roll Skia from 7f88bda24f7f to 0057898979a1 (1 revision) (flutter/engine#45904)
2023-09-15 [email protected] [Impeller] Test `FenceWaiterVK` and fix termination bugs (flutter/engine#45870)
2023-09-15 [email protected] Roll Dart SDK from a5ee0055cf20 to e9452310189b (1 revision) (flutter/engine#45902)
2023-09-15 [email protected] Roll Skia from 4f26f22daa4b to 7f88bda24f7f (5 revisions) (flutter/engine#45901)
2023-09-15 [email protected] [Impeller] dont cache failed render target allocations. (flutter/engine#45895)

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://bugs.chromium.org/p/skia/issues/entry?template=Autoroller+Bug

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
harryterkelsen pushed a commit that referenced this pull request Oct 23, 2023
Fixes flutter/flutter#134751, and @jonahwilliams suspects it could be related to a number of other flaky/texture leak scenarios (flutter/flutter#133506 (comment)) that only happen sometimes (i.e. on CI but not real devices), i.e. stuff like:

```txt
--- Vulkan Debug Report  ----------------------------------------
|                Severity: Error
|                    Type: { Validation }
|                 ID Name: VUID-vkDestroyBuffer-buffer-00922
|               ID Number: -464217071
|       Queue Breadcrumbs: [NONE]
|  CMD Buffer Breadcrumbs: [NONE]
|         Related Objects: Device [94498356231456] [ImpellerDevice]
|                 Trigger: Validation Error: [ VUID-vkDestroyBuffer-buffer-00922 ] Object 0: handle = 0x55f21cf47d20, name = ImpellerDevice, type = VK_OBJECT_TYPE_DEVICE; | MessageID = 0xe4549c11 | Cannot call vkDestroyBuffer on VkBuffer 0xbb00000000bb[] that is currently in use by a command buffer. The Vulkan spec states: All submitted commands that refer to buffer, either directly or via a VkBufferView, must have completed execution (https://www.khronos.org/registry/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-vkDestroyBuffer-buffer-00922)
-----------------------------------------------------------------
```

---

~~This PR will look a bit like a mess until the last 2 PRs merge in, but locally it appears to fix fence races/segfaults that I was seeing on CI, including on Linux with validations enabled. We can test it further tomorrow.~~ EDIT: Updated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App e: impeller
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Fence waiter can terminate without waiting on fences
5 participants