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
[WebGPU] Extra deref of SwapChainImpl::m_backing #8941
[WebGPU] Extra deref of SwapChainImpl::m_backing #8941
Conversation
EWS run on previous version of this PR (hash 9236988) |
wgpuSwapChainRelease(m_backing); | ||
destroy(); | ||
} | ||
|
||
void SwapChainImpl::destroy() | ||
{ | ||
wgpuSwapChainRelease(m_backing); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's wrong to delete all calls to wgpuSwapChainRelease()
. I think the fact that there's only a single object under the hood shouldn't be visible from outside WebGPU.framework.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea, I'll increment the ref count instead on m_backing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requesting changes due to missing wgpuSwapChainRelease()
9236988
to
de93d28
Compare
EWS run on previous version of this PR (hash de93d28) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this bumps the ref by 2 instead of by 1
@@ -36,6 +36,7 @@ | |||
Ref<PresentationContext> Device::createSwapChain(PresentationContext& presentationContext, const WGPUSwapChainDescriptor& descriptor) | |||
{ | |||
presentationContext.configure(*this, descriptor); | |||
presentationContext.ref(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary? The input to this function is a PresentationContext& and the output is a Ref. So the next line return statement will invoke the constructor of Ref that will increment the ref count. So I think this change will actually bump the ref count by 2, not 1.
Also, suspicious that every ref needs to be matched with a deref but this one doesn't seem to be.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good observation, I will take a closer look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I think I found the root cause now. The destructor and destroy were both calling release. wgpuSurfaceRelease
doesn't actually release the backing, it just decrements the ref count. So after calling this I now set the backing to null so it can't be released again.
de93d28
to
c6f2805
Compare
EWS run on current version of this PR (hash c6f2805) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://bugs.webkit.org/show_bug.cgi?id=250963 <rdar://104522929> Reviewed by Myles C. Maxfield. WebGPUSurfaceImpl and WebGPUSwapChainImpl called release in both destroy and their destructor, resulting in a double release. Fix this issue by setting the backing to null when the object is released. * Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUSurfaceImpl.cpp: (PAL::WebGPU::SurfaceImpl::destroy): * Source/WebCore/PAL/pal/graphics/WebGPU/Impl/WebGPUSwapChainImpl.cpp: (PAL::WebGPU::SwapChainImpl::~SwapChainImpl): (PAL::WebGPU::SwapChainImpl::destroy): Canonical link: https://commits.webkit.org/259318@main
c6f2805
to
83826f3
Compare
Committed 259318@main (83826f3): https://commits.webkit.org/259318@main Reviewed commits have been landed. Closing PR #8941 and removing active labels. |
83826f3
c6f2805