Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Conversation

@jason-simmons
Copy link
Member

@flutter-dashboard
Copy link

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 Hixie on the #hackers channel in Chat (don't just cc him here, he won't see it! He's on 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.

@gaaclarke
Copy link
Member

I was able to solve this by having the fence hold onto the Context in #41748

That makes sure that the device lives long enough to kill the tracked objects.

@jason-simmons
Copy link
Member Author

In this case the issue is the lifetime of the command pool, not the device - see flutter/flutter#125519 (comment)

The command pool is destroyed by the ClearAllPools call made by the ContextVK destructor, which runs before the context's FenceWaiterVK is destructed. If the command pool has already been deleted, then it is no longer safe to free buffers associated with that pool.

@gaaclarke
Copy link
Member

In this case the issue is the lifetime of the command pool, not the device - see flutter/flutter#125519 (comment)

The command pool is destroyed by the ClearAllPools call made by the ContextVK destructor, which runs before the context's FenceWaiterVK is destructed. If the command pool has already been deleted, then it is no longer safe to free buffers associated with that pool.

Right, I get that. The command pools before my change are actually cleaned up when the thread is destroyed since a thread_local variable has a strong reference. That PR I linked actually removes the strong link when the context is destroyed. Since the fence holds onto a strong reference to the tracked objects and the context the pool is guaranteed to be alive when the fence finishes.

@jason-simmons
Copy link
Member Author

ClearAllPools calls Reset on every pool associated with the ContextVK. Reset deletes the graphics_pool_, which is the actual underlying Vulkan command pool object.

Once the graphics_pool_ is gone, all of its command buffers are freed and are now unusable. The CommandPoolVK should not make further Vulkan API calls using those buffers.

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.

Talked with jason offline this is a good change. I've seen these command buffers crash when their deallocator is run late. release is a misnomer and isn't releasing the ownership of the c++ wrapper. This all looks good, thanks jason.

@flar flar added the autosubmit Merge PR when tree becomes green via auto submit App label May 5, 2023
@auto-submit auto-submit bot merged commit 758cbad into flutter:main May 5, 2023
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request May 5, 2023
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request May 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App needs tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Impeller] vulkan unit tests will randomly crash in ~TrackedObjectsVK()

3 participants