Bug 223211

Summary: Protect this in all PlatformOpenXR queue->dispatch() calls
Product: WebKit Reporter: Imanol Fernandez <ifernandez>
Component: WebXRAssignee: Imanol Fernandez <ifernandez>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 208988    
Attachments:
Description Flags
Patch
none
Patch none

Description Imanol Fernandez 2021-03-15 13:25:36 PDT
As discussed in https://bugs.webkit.org/show_bug.cgi?id=222607, the WorkQueue may outlive OpenXRDevice so m_queue->dispatch([this] { /*do something with this*/}); is unsafe.
Comment 1 Imanol Fernandez 2021-03-15 13:37:49 PDT
Created attachment 423231 [details]
Patch
Comment 2 Chris Dumez 2021-03-15 13:42:23 PDT
Comment on attachment 423231 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=423231&action=review

> Source/WebCore/platform/xr/PlatformXR.h:65
> +class Device : public RefCounted<Device>, public CanMakeWeakPtr<Device> {

You want ThreadSafeRefCounted since you are passing this to another thread.

> Source/WebCore/platform/xr/openxr/PlatformXROpenXR.h:50
> +    virtual ~OpenXRDevice();

I don't think we need the `virtual`.
Comment 3 Imanol Fernandez 2021-03-15 13:55:00 PDT
Created attachment 423233 [details]
Patch

Thanks for the quick review! I added ThreadSafeRefCounted and removed the unneeded virtual destructor in the inherited class
Comment 4 Chris Dumez 2021-03-15 14:00:07 PDT
Comment on attachment 423233 [details]
Patch

r=me if the bots are happy.
Comment 5 EWS 2021-03-16 01:45:56 PDT
Committed r274470: <https://commits.webkit.org/r274470>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 423233 [details].
Comment 6 Radar WebKit Bug Importer 2021-03-16 01:46:15 PDT
<rdar://problem/75468705>