RESOLVED FIXED 231482
[WebXR] Replace the session reference in WebXRSpace subclasses with weak pointers
https://bugs.webkit.org/show_bug.cgi?id=231482
Summary [WebXR] Replace the session reference in WebXRSpace subclasses with weak poin...
Dean Jackson
Reported 2021-10-09 15:15:24 PDT
[WebXR] Replace the session reference in WebXRSpace subclasses with weak pointers
Attachments
Patch (18.19 KB, patch)
2021-10-09 15:22 PDT, Dean Jackson
sam: review+
EWS test (22.33 KB, patch)
2021-10-10 11:33 PDT, Dean Jackson
no flags
Dean Jackson
Comment 1 2021-10-09 15:22:06 PDT
Radar WebKit Bug Importer
Comment 2 2021-10-09 15:37:43 PDT
Sam Weinig
Comment 3 2021-10-09 17:39:18 PDT
Comment on attachment 440718 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=440718&action=review > Source/WebCore/ChangeLog:12 > + WebXRSpace had a pure virtual session() accessor that returned > + a reference to a WebXRSession. This made subclasses hold strong > + references to the WebXRSession, and would become problematic > + for a WebXRSpace subclass that was (indirectly) owned by the > + WebXRSession (found in the Hand Input module). Pretty sure this was already causing leaks elsewhere for other XRSpaces, like the targetRaySpace and gripSpace in WebXRInputSource. > Source/WebCore/Modules/webxr/WebXRReferenceSpace.cpp:72 > + if (!m_session) > + return identity; This feels a bit weird to me. It at least needs a comment explaining itself, but I would assume this would propagate an Exception to the caller. > Source/WebCore/Modules/webxr/WebXRReferenceSpace.cpp:120 > + if (!m_session) > + return { }; Same as above. > Source/WebCore/Modules/webxr/WebXRSpace.cpp:61 > + WebXRSession* xrSession = session(); > + if (!xrSession) > + return false; Seems like this should be an exception rather than just returning false.
Dean Jackson
Comment 4 2021-10-10 11:33:50 PDT
Created attachment 440732 [details] EWS test
Dean Jackson
Comment 5 2021-10-10 11:35:13 PDT
Comment on attachment 440718 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=440718&action=review >> Source/WebCore/Modules/webxr/WebXRReferenceSpace.cpp:72 >> + return identity; > > This feels a bit weird to me. It at least needs a comment explaining itself, but I would assume this would propagate an Exception to the caller. Good point. I changed ::nativeOrigin to return an optional<TransformationMatrix>, updated all the subclasses, and return an Exception at the calling site if the session has disappeared. >> Source/WebCore/Modules/webxr/WebXRReferenceSpace.cpp:120 >> + return { }; > > Same as above. Ditto. >> Source/WebCore/Modules/webxr/WebXRSpace.cpp:61 >> + return false; > > Seems like this should be an exception rather than just returning false. Done. Similar solution - this returns an optional that ends up returning an exception in the caller.
Dean Jackson
Comment 6 2021-10-10 16:05:27 PDT
Note You need to log in before you can comment on or make changes to this bug.