-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Reduce unsafeness in WebGPU module #47342
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
Reduce unsafeness in WebGPU module #47342
Conversation
EWS run on previous version of this PR (hash aca9e84) |
Safer C++ Build #41981 (aca9e84)
|
@@ -90,7 +90,7 @@ class GPUBuffer : public RefCountedAndCanMakeWeakPtr<GPUBuffer> { | |||
const GPUBufferUsageFlags m_usage { 0 }; | |||
GPUBufferMapState m_mapState { GPUBufferMapState::Unmapped }; | |||
std::optional<MapAsyncPromise> m_pendingMapPromise; | |||
WeakPtr<GPUDevice, WeakPtrImplWithEventTargetData> m_device; | |||
const WeakPtr<GPUDevice, WeakPtrImplWithEventTargetData> m_device; |
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.
This does not protect anything since the type is WeakPtr and WeakPtr does not keep the object alive. This should not help for the purpose of static analysis and if it does, I believe it would likely be a bug in the static analyzer.
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 know, but I saw people adding these in other PRs so I figured I'd do it as drive-by as well.
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.
But what's the purpose?
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 guess I misunderstood. I'll revert that change and those like it.
aca9e84
to
38ac9df
Compare
EWS run on previous version of this PR (hash 38ac9df) |
RefPtr currentTexture = m_currentTexture; | ||
if ((!currentTexture || currentTexture->isDestroyed()) && m_device.get()) { | ||
if (auto backingCurrentTexture = m_backing->getCurrentTexture(index)) { | ||
currentTexture = GPUTexture::create(*backingCurrentTexture, m_textureDescriptor, *m_device.get()).ptr(); | ||
m_currentTexture = currentTexture.copyRef(); | ||
} |
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.
We could just inline isDestroyed()
and avoid doing all of this
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.
Thanks for pointing that out, I'll make that change!
38ac9df
to
e1f5964
Compare
EWS run on previous version of this PR (hash e1f5964) |
e1f5964
to
a854904
Compare
EWS run on current version of this PR (hash a854904) |
Safe-Merge-Queue: Build #61938. |
https://bugs.webkit.org/show_bug.cgi?id=295160 Reviewed by Mike Wyrzykowski. Apply https://github.com/WebKit/WebKit/wiki/Safer-CPP-Guidelines Canonical link: https://commits.webkit.org/296859@main
a854904
to
24972cf
Compare
Committed 296859@main (24972cf): https://commits.webkit.org/296859@main Reviewed commits have been landed. Closing PR #47342 and removing active labels. |
24972cf
a854904