Title: [277251] trunk/Source/WebCore
Revision
277251
Author
[email protected]
Date
2021-05-09 12:04:22 -0700 (Sun, 09 May 2021)

Log Message

[WebXR] Remove reference cycle in WebXRSession
https://bugs.webkit.org/show_bug.cgi?id=225025
<rdar://problem/77111217>

Reviewed by Sam Weinig.

Patch by Sam Weinig, who took my bad patch and made it better.

WebXRSession was attempting to create an WebXRInputSourceArray in
its constructor, which itself was trying to hold a strong reference
back to WebXRSession - causing a crash.

* Modules/webxr/WebXRBoundedReferenceSpace.h: Fix small typo.

* Modules/webxr/WebXRFrame.cpp: Use reference in constructor, since we
know the session exists.
(WebCore::WebXRFrame::create):
(WebCore::WebXRFrame::WebXRFrame):
* Modules/webxr/WebXRFrame.h:

* Modules/webxr/WebXRInputSource.cpp: Use a WeakPtr as a reference back
to the WebXRSession.
(WebCore::WebXRInputSource::create):
(WebCore::WebXRInputSource::WebXRInputSource):
(WebCore::WebXRInputSource::session): Add this getter.
(WebCore::WebXRInputSource::update): Check for null.
(WebCore::WebXRInputSource::pollEvents):
(WebCore::WebXRInputSource::createEvent): Deleted - moved to lambda.
* Modules/webxr/WebXRInputSource.h:
* Modules/webxr/WebXRInputSource.idl:

* Modules/webxr/WebXRInputSourceArray.cpp: Add GenerateIsReachable.
(WebCore::WebXRInputSourceArray::create):
(WebCore::WebXRInputSourceArray::WebXRInputSourceArray):
(WebCore::WebXRInputSourceArray::ref):
(WebCore::WebXRInputSourceArray::deref):
(WebCore::WebXRInputSourceArray::update):
(WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources):
* Modules/webxr/WebXRInputSourceArray.h:
* Modules/webxr/WebXRInputSourceArray.idl:

* Modules/webxr/WebXRInputSpace.cpp: Use reference in constructor.
(WebCore::WebXRInputSpace::create):
(WebCore::WebXRInputSpace::WebXRInputSpace):
* Modules/webxr/WebXRInputSpace.h:

* Modules/webxr/WebXRSession.cpp: Use a UniqueRef for input source array.
(WebCore::WebXRSession::onFrame):
* Modules/webxr/WebXRSession.h:

* bindings/scripts/CodeGeneratorJS.pm: Add ImplWebXRSessionRoot to GenerateIsReachable.
(GenerateImplementation):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (277250 => 277251)


--- trunk/Source/WebCore/ChangeLog	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/ChangeLog	2021-05-09 19:04:22 UTC (rev 277251)
@@ -1,3 +1,58 @@
+2021-05-09  Dean Jackson  <[email protected]>
+
+        [WebXR] Remove reference cycle in WebXRSession
+        https://bugs.webkit.org/show_bug.cgi?id=225025
+        <rdar://problem/77111217>
+
+        Reviewed by Sam Weinig.
+
+        Patch by Sam Weinig, who took my bad patch and made it better.
+
+        WebXRSession was attempting to create an WebXRInputSourceArray in
+        its constructor, which itself was trying to hold a strong reference
+        back to WebXRSession - causing a crash.
+
+        * Modules/webxr/WebXRBoundedReferenceSpace.h: Fix small typo.
+
+        * Modules/webxr/WebXRFrame.cpp: Use reference in constructor, since we
+        know the session exists.
+        (WebCore::WebXRFrame::create):
+        (WebCore::WebXRFrame::WebXRFrame):
+        * Modules/webxr/WebXRFrame.h:
+
+        * Modules/webxr/WebXRInputSource.cpp: Use a WeakPtr as a reference back
+        to the WebXRSession.
+        (WebCore::WebXRInputSource::create):
+        (WebCore::WebXRInputSource::WebXRInputSource):
+        (WebCore::WebXRInputSource::session): Add this getter.
+        (WebCore::WebXRInputSource::update): Check for null.
+        (WebCore::WebXRInputSource::pollEvents):
+        (WebCore::WebXRInputSource::createEvent): Deleted - moved to lambda.
+        * Modules/webxr/WebXRInputSource.h:
+        * Modules/webxr/WebXRInputSource.idl:
+
+        * Modules/webxr/WebXRInputSourceArray.cpp: Add GenerateIsReachable.
+        (WebCore::WebXRInputSourceArray::create):
+        (WebCore::WebXRInputSourceArray::WebXRInputSourceArray):
+        (WebCore::WebXRInputSourceArray::ref):
+        (WebCore::WebXRInputSourceArray::deref):
+        (WebCore::WebXRInputSourceArray::update):
+        (WebCore::WebXRInputSourceArray::handleAddedOrUpdatedInputSources):
+        * Modules/webxr/WebXRInputSourceArray.h:
+        * Modules/webxr/WebXRInputSourceArray.idl:
+
+        * Modules/webxr/WebXRInputSpace.cpp: Use reference in constructor.
+        (WebCore::WebXRInputSpace::create):
+        (WebCore::WebXRInputSpace::WebXRInputSpace):
+        * Modules/webxr/WebXRInputSpace.h:
+
+        * Modules/webxr/WebXRSession.cpp: Use a UniqueRef for input source array.
+        (WebCore::WebXRSession::onFrame):
+        * Modules/webxr/WebXRSession.h:
+
+        * bindings/scripts/CodeGeneratorJS.pm: Add ImplWebXRSessionRoot to GenerateIsReachable.
+        (GenerateImplementation):
+
 2021-05-09  Darin Adler  <[email protected]>
 
         Remove uses of the String::toInt family of functions from the WebCore/platform directory

Modified: trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.h (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.h	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRBoundedReferenceSpace.h	2021-05-09 19:04:22 UTC (rev 277251)
@@ -36,7 +36,7 @@
 
 class DOMPointReadOnly;
 
-class WebXRBoundedReferenceSpace final: public WebXRReferenceSpace {
+class WebXRBoundedReferenceSpace final : public WebXRReferenceSpace {
     WTF_MAKE_ISO_ALLOCATED(WebXRBoundedReferenceSpace);
 public:
     static Ref<WebXRBoundedReferenceSpace> create(Document&, Ref<WebXRSession>&&, XRReferenceSpaceType);

Modified: trunk/Source/WebCore/Modules/webxr/WebXRFrame.cpp (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRFrame.cpp	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRFrame.cpp	2021-05-09 19:04:22 UTC (rev 277251)
@@ -38,14 +38,14 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(WebXRFrame);
 
-Ref<WebXRFrame> WebXRFrame::create(Ref<WebXRSession>&& session, IsAnimationFrame isAnimationFrame)
+Ref<WebXRFrame> WebXRFrame::create(WebXRSession& session, IsAnimationFrame isAnimationFrame)
 {
-    return adoptRef(*new WebXRFrame(WTFMove(session), isAnimationFrame));
+    return adoptRef(*new WebXRFrame(session, isAnimationFrame));
 }
 
-WebXRFrame::WebXRFrame(Ref<WebXRSession>&& session, IsAnimationFrame isAnimationFrame)
+WebXRFrame::WebXRFrame(WebXRSession& session, IsAnimationFrame isAnimationFrame)
     : m_isAnimationFrame(isAnimationFrame == IsAnimationFrame::Yes)
-    , m_session(WTFMove(session))
+    , m_session(session)
 {
 }
 

Modified: trunk/Source/WebCore/Modules/webxr/WebXRFrame.h (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRFrame.h	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRFrame.h	2021-05-09 19:04:22 UTC (rev 277251)
@@ -48,7 +48,7 @@
     WTF_MAKE_ISO_ALLOCATED(WebXRFrame);
 public:
     enum class IsAnimationFrame : bool { No, Yes };
-    static Ref<WebXRFrame> create(Ref<WebXRSession>&&, IsAnimationFrame);
+    static Ref<WebXRFrame> create(WebXRSession&, IsAnimationFrame);
     ~WebXRFrame();
 
     const WebXRSession& session() const { return m_session.get(); }
@@ -66,7 +66,7 @@
     static TransformationMatrix matrixFromPose(const PlatformXR::Device::FrameData::Pose&);
 
 private:
-    WebXRFrame(Ref<WebXRSession>&&, IsAnimationFrame);
+    WebXRFrame(WebXRSession&, IsAnimationFrame);
 
     bool isOutsideNativeBoundsOfBoundedReferenceSpace(const WebXRSpace&, const WebXRSpace&) const;
     bool isLocalReferenceSpace(const WebXRSpace&) const;

Modified: trunk/Source/WebCore/Modules/webxr/WebXRInputSource.cpp (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRInputSource.cpp	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRInputSource.cpp	2021-05-09 19:04:22 UTC (rev 277251)
@@ -42,14 +42,14 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(WebXRInputSource);
 
-Ref<WebXRInputSource> WebXRInputSource::create(Document& document, Ref<WebXRSession>&& session, double timestamp, const PlatformXR::Device::FrameData::InputSource& source)
+Ref<WebXRInputSource> WebXRInputSource::create(Document& document, WebXRSession& session, double timestamp, const PlatformXR::Device::FrameData::InputSource& source)
 {
-    return adoptRef(*new WebXRInputSource(document, WTFMove(session), timestamp, source));
+    return adoptRef(*new WebXRInputSource(document, session, timestamp, source));
 }
 
-WebXRInputSource::WebXRInputSource(Document& document, Ref<WebXRSession>&& session, double timestamp, const PlatformXR::Device::FrameData::InputSource& source)
-    : m_session(WTFMove(session))
-    , m_targetRaySpace(WebXRInputSpace::create(document, m_session.copyRef(), source.pointerOrigin))
+WebXRInputSource::WebXRInputSource(Document& document, WebXRSession& session, double timestamp, const PlatformXR::Device::FrameData::InputSource& source)
+    : m_session(makeWeakPtr(session))
+    , m_targetRaySpace(WebXRInputSpace::create(document, session, source.pointerOrigin))
     , m_connectTime(timestamp)
 #if ENABLE(GAMEPAD)
     , m_gamepad(Gamepad::create(WebXRGamepad(timestamp, timestamp, source)))
@@ -60,8 +60,17 @@
 
 WebXRInputSource::~WebXRInputSource() = default;
 
+WebXRSession* WebXRInputSource::session()
+{
+    return m_session.get();
+}
+
 void WebXRInputSource::update(double timestamp, const PlatformXR::Device::FrameData::InputSource& source)
 {
+    auto session = makeRefPtr(m_session.get());
+    if (!session)
+        return;
+
 #if !ENABLE(GAMEPAD)
     UNUSED_PARAM(timestamp);
 #endif
@@ -70,8 +79,8 @@
     if (auto gripOrigin = source.gripOrigin) {
         if (m_gripSpace)
             m_gripSpace->setPose(*gripOrigin);
-        else if (auto* document = downcast<Document>(m_session->scriptExecutionContext()))
-            m_gripSpace = WebXRInputSpace::create(*document, m_session.copyRef(), *gripOrigin);
+        else if (auto* document = downcast<Document>(session->scriptExecutionContext()))
+            m_gripSpace = WebXRInputSpace::create(*document, *session, *gripOrigin);
     } else
         m_gripSpace = nullptr;
 #if ENABLE(GAMEPAD)
@@ -97,6 +106,18 @@
 
 void WebXRInputSource::pollEvents(Vector<Ref<XRInputSourceEvent>>& events)
 {
+    auto session = makeRefPtr(m_session.get());
+    if (!session)
+        return;
+
+    auto createEvent = [this, session](const AtomString& name) -> Ref<XRInputSourceEvent> {
+        XRInputSourceEvent::Init init;
+        init.frame = WebXRFrame::create(*session, WebXRFrame::IsAnimationFrame::No);
+        init.inputSource = makeRefPtr(*this);
+
+        return XRInputSourceEvent::create(name, init);
+    };
+
     if (!m_connected) {
         // A user agent MUST dispatch a selectend event on an XRSession when one of its XRInputSources ends 
         // when an XRInputSource that has begun a primary select action is disconnected.
@@ -143,15 +164,6 @@
     }
 }
 
-Ref<XRInputSourceEvent> WebXRInputSource::createEvent(const AtomString& name)
-{
-    XRInputSourceEvent::Init init;
-    init.frame = WebXRFrame::create(m_session.copyRef(), WebXRFrame::IsAnimationFrame::No);
-    init.inputSource = makeRefPtr(*this);
-
-    return XRInputSourceEvent::create(name, init);
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(WEBXR)

Modified: trunk/Source/WebCore/Modules/webxr/WebXRInputSource.h (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRInputSource.h	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRInputSource.h	2021-05-09 19:04:22 UTC (rev 277251)
@@ -53,7 +53,7 @@
     using InputSource = PlatformXR::Device::FrameData::InputSource;
     using InputSourceButton = PlatformXR::Device::FrameData::InputSourceButton;
 
-    static Ref<WebXRInputSource> create(Document&, Ref<WebXRSession>&&, double timestamp, const InputSource&);
+    static Ref<WebXRInputSource> create(Document&, WebXRSession&, double timestamp, const InputSource&);
     ~WebXRInputSource();
 
     PlatformXR::InputSourceHandle handle() const { return m_source.handle; }
@@ -72,12 +72,13 @@
     
     void pollEvents(Vector<Ref<XRInputSourceEvent>>&);
 
+    // For GC reachablitiy.
+    WebXRSession* session();
+
 private:
-    WebXRInputSource(Document&, Ref<WebXRSession>&&, double timestamp, const InputSource&);
+    WebXRInputSource(Document&, WebXRSession&, double timestamp, const InputSource&);
 
-    Ref<XRInputSourceEvent> createEvent(const AtomString&);
-
-    Ref<WebXRSession> m_session;
+    WeakPtr<WebXRSession> m_session;
     InputSource m_source;
     Ref<WebXRInputSpace> m_targetRaySpace;
     RefPtr<WebXRInputSpace> m_gripSpace;

Modified: trunk/Source/WebCore/Modules/webxr/WebXRInputSource.idl (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRInputSource.idl	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRInputSource.idl	2021-05-09 19:04:22 UTC (rev 277251)
@@ -24,6 +24,7 @@
  */
 
 [
+    GenerateIsReachable=ImplWebXRSessionRoot,
     EnabledBySetting=WebXR,
     Conditional=WEBXR,
     SecureContext,

Modified: trunk/Source/WebCore/Modules/webxr/WebXRInputSourceArray.cpp (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRInputSourceArray.cpp	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRInputSourceArray.cpp	2021-05-09 19:04:22 UTC (rev 277251)
@@ -38,18 +38,28 @@
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(WebXRInputSourceArray);
 
-Ref<WebXRInputSourceArray> WebXRInputSourceArray::create(Ref<WebXRSession>&& session)
+UniqueRef<WebXRInputSourceArray> WebXRInputSourceArray::create(WebXRSession& session)
 {
-    return adoptRef(*new WebXRInputSourceArray(WTFMove(session)));
+    return makeUniqueRef<WebXRInputSourceArray>(session);
 }
 
-WebXRInputSourceArray::WebXRInputSourceArray(Ref<WebXRSession>&& session)
-    : m_session(WTFMove(session))
+WebXRInputSourceArray::WebXRInputSourceArray(WebXRSession& session)
+    : m_session(session)
 {
 }
 
 WebXRInputSourceArray::~WebXRInputSourceArray() = default;
 
+void WebXRInputSourceArray::ref()
+{
+    m_session.ref();
+}
+
+void WebXRInputSourceArray::deref()
+{
+    m_session.deref();
+}
+
 unsigned WebXRInputSourceArray::length() const
 {
     return m_inputSources.size();
@@ -78,12 +88,12 @@
     if (!added.isEmpty() || !removed.isEmpty()) {
         // A user agent MUST dispatch an inputsourceschange event on an XRSession when the session’s list of active XR input sources has changed.
         XRInputSourcesChangeEvent::Init init;
-        init.session = m_session.copyRef();
+        init.session = makeRef(m_session);
         init.added = WTFMove(added);
         init.removed = WTFMove(removed);
         
         auto event = XRInputSourcesChangeEvent::create(eventNames().inputsourceschangeEvent, init);
-        m_session->queueTaskToDispatchEvent(m_session.get(), TaskSource::WebXR, WTFMove(event));
+        ActiveDOMObject::queueTaskToDispatchEvent(m_session, TaskSource::WebXR, WTFMove(event));
     }
 
     if (!inputEvents.isEmpty()) {
@@ -95,9 +105,9 @@
         // 5. Set frame’s active boolean to false.
 
         for (auto& event : inputEvents) {
-            m_session->queueTaskKeepingObjectAlive(m_session.get(), TaskSource::WebXR, [&session = m_session.get(), event = WTFMove(event)]() {
+            ActiveDOMObject::queueTaskKeepingObjectAlive(m_session, TaskSource::WebXR, [session = makeRefPtr(m_session), event = WTFMove(event)]() {
                 event->setFrameActive(true);
-                session.dispatchEvent(event.copyRef());
+                session->dispatchEvent(event.copyRef());
                 event->setFrameActive(false);
             });
         }
@@ -127,7 +137,7 @@
 // https://immersive-web.github.io/webxr/#list-of-active-xr-input-sources
 void WebXRInputSourceArray::handleAddedOrUpdatedInputSources(double timestamp, const InputSourceList& inputSources, Vector<RefPtr<WebXRInputSource>>& added, Vector<RefPtr<WebXRInputSource>>& removed, Vector<Ref<XRInputSourceEvent>>& inputEvents)
 {
-    auto* document = downcast<Document>(m_session->scriptExecutionContext());
+    auto* document = downcast<Document>(m_session.scriptExecutionContext());
     if (!document)
         return;
 
@@ -141,7 +151,7 @@
             //   3.1 Let inputSource be a new XRInputSource in the relevant realm of this XRSession.
             //   3.2 Add inputSource to added.
 
-            auto input = WebXRInputSource::create(*document, m_session.copyRef(), timestamp, inputSource);
+            auto input = WebXRInputSource::create(*document, m_session, timestamp, inputSource);
             added.append(input.copyRef());
             input->pollEvents(inputEvents);
             m_inputSources.append(WTFMove(input));
@@ -165,7 +175,7 @@
             input->pollEvents(inputEvents);
             m_inputSources.remove(index);
 
-            auto newInputSource = WebXRInputSource::create(*document, m_session.copyRef(), timestamp, inputSource);
+            auto newInputSource = WebXRInputSource::create(*document, m_session, timestamp, inputSource);
             added.append(newInputSource.copyRef());
             newInputSource->pollEvents(inputEvents);
             m_inputSources.append(WTFMove(newInputSource));

Modified: trunk/Source/WebCore/Modules/webxr/WebXRInputSourceArray.h (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRInputSourceArray.h	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRInputSourceArray.h	2021-05-09 19:04:22 UTC (rev 277251)
@@ -28,9 +28,11 @@
 #if ENABLE(WEBXR)
 
 #include "PlatformXR.h"
+#include "ScriptWrappable.h"
 #include <wtf/IsoMalloc.h>
 #include <wtf/Ref.h>
 #include <wtf/RefCounted.h>
+#include <wtf/UniqueRef.h>
 
 namespace WebCore {
 
@@ -39,13 +41,17 @@
 class XRInputSourceEvent;
 class WebXRSession;
 
-class WebXRInputSourceArray : public RefCounted<WebXRInputSourceArray> {
+class WebXRInputSourceArray final : public ScriptWrappable {
     WTF_MAKE_ISO_ALLOCATED(WebXRInputSourceArray);
+    friend UniqueRef<WebXRInputSourceArray> WTF::makeUniqueRefWithoutFastMallocCheck<WebXRInputSourceArray, WebXRSession&>(WebXRSession&);
 public:
     using InputSourceList = Vector<PlatformXR::Device::FrameData::InputSource>;
-    static Ref<WebXRInputSourceArray> create(Ref<WebXRSession>&&);
+    static UniqueRef<WebXRInputSourceArray> create(WebXRSession&);
     ~WebXRInputSourceArray();
 
+    void ref();
+    void deref();
+
     unsigned length() const;
     WebXRInputSource* item(unsigned) const;
 
@@ -52,13 +58,16 @@
     void clear();
     void update(double timestamp, const InputSourceList&);
 
+    // For GC reachablitiy.
+    WebXRSession* session() const { return &m_session; }
+
 private:
-    WebXRInputSourceArray(Ref<WebXRSession>&&);
+    WebXRInputSourceArray(WebXRSession&);
 
     void handleRemovedInputSources(const InputSourceList&, Vector<RefPtr<WebXRInputSource>>&, Vector<Ref<XRInputSourceEvent>>&);
     void handleAddedOrUpdatedInputSources(double timestamp, const InputSourceList&, Vector<RefPtr<WebXRInputSource>>&, Vector<RefPtr<WebXRInputSource>>&, Vector<Ref<XRInputSourceEvent>>&);
 
-    Ref<WebXRSession> m_session;
+    WebXRSession& m_session;
     Vector<Ref<WebXRInputSource>> m_inputSources;
 };
 

Modified: trunk/Source/WebCore/Modules/webxr/WebXRInputSourceArray.idl (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRInputSourceArray.idl	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRInputSourceArray.idl	2021-05-09 19:04:22 UTC (rev 277251)
@@ -24,6 +24,7 @@
  */
 
 [
+    GenerateIsReachable=ImplWebXRSessionRoot,
     EnabledBySetting=WebXR,
     Conditional=WEBXR,
     SecureContext,

Modified: trunk/Source/WebCore/Modules/webxr/WebXRInputSpace.cpp (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRInputSpace.cpp	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRInputSpace.cpp	2021-05-09 19:04:22 UTC (rev 277251)
@@ -39,14 +39,14 @@
 
 // WebXRInputSpace
 
-Ref<WebXRInputSpace> WebXRInputSpace::create(Document& document, Ref<WebXRSession>&& session, const PlatformXR::Device::FrameData::InputSourcePose& pose)
+Ref<WebXRInputSpace> WebXRInputSpace::create(Document& document, WebXRSession& session, const PlatformXR::Device::FrameData::InputSourcePose& pose)
 {
-    return adoptRef(*new WebXRInputSpace(document, WTFMove(session), pose));
+    return adoptRef(*new WebXRInputSpace(document, session, pose));
 }
 
-WebXRInputSpace::WebXRInputSpace(Document& document, Ref<WebXRSession>&& session, const PlatformXR::Device::FrameData::InputSourcePose& pose)
+WebXRInputSpace::WebXRInputSpace(Document& document, WebXRSession& session, const PlatformXR::Device::FrameData::InputSourcePose& pose)
     : WebXRSpace(document, WebXRRigidTransform::create())
-    , m_session(WTFMove(session))
+    , m_session(session)
     , m_pose(pose)
 {
 }

Modified: trunk/Source/WebCore/Modules/webxr/WebXRInputSpace.h (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRInputSpace.h	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRInputSpace.h	2021-05-09 19:04:22 UTC (rev 277251)
@@ -38,7 +38,7 @@
 class WebXRInputSpace : public RefCounted<WebXRInputSpace>, public WebXRSpace {
     WTF_MAKE_ISO_ALLOCATED(WebXRInputSpace);
 public:
-    static Ref<WebXRInputSpace> create(Document&, Ref<WebXRSession>&&, const PlatformXR::Device::FrameData::InputSourcePose&);
+    static Ref<WebXRInputSpace> create(Document&, WebXRSession&, const PlatformXR::Device::FrameData::InputSourcePose&);
     virtual ~WebXRInputSpace();
 
     using RefCounted<WebXRInputSpace>::ref;
@@ -48,7 +48,7 @@
     void setPose(const PlatformXR::Device::FrameData::InputSourcePose& pose) { m_pose = pose; }
 
 private:
-    WebXRInputSpace(Document&, Ref<WebXRSession>&&, const PlatformXR::Device::FrameData::InputSourcePose&);
+    WebXRInputSpace(Document&, WebXRSession&, const PlatformXR::Device::FrameData::InputSourcePose&);
     WebXRSession& session() const final { return m_session.get(); }
     TransformationMatrix nativeOrigin() const final;
 

Modified: trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp	2021-05-09 19:04:22 UTC (rev 277251)
@@ -526,7 +526,7 @@
         //  1.Let now be the current high resolution time.
         auto now = (MonotonicTime::now() - m_timeOrigin).milliseconds();
 
-        auto frame = WebXRFrame::create(makeRef(*this), WebXRFrame::IsAnimationFrame::Yes);
+        auto frame = WebXRFrame::create(*this, WebXRFrame::IsAnimationFrame::Yes);
         //  2.Let frame be session’s animation frame.
         //  3.Set frame’s time to frameTime.
         frame->setTime(static_cast<DOMHighResTimeStamp>(frameData.predictedDisplayTime));

Modified: trunk/Source/WebCore/Modules/webxr/WebXRSession.h (277250 => 277251)


--- trunk/Source/WebCore/Modules/webxr/WebXRSession.h	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/Modules/webxr/WebXRSession.h	2021-05-09 19:04:22 UTC (rev 277251)
@@ -129,7 +129,7 @@
     XREnvironmentBlendMode m_environmentBlendMode;
     XRInteractionMode m_interactionMode;
     XRVisibilityState m_visibilityState;
-    Ref<WebXRInputSourceArray> m_inputSources;
+    UniqueRef<WebXRInputSourceArray> m_inputSources;
     bool m_ended { false };
     Optional<EndPromise> m_endPromise;
 

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm (277250 => 277251)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2021-05-09 18:57:20 UTC (rev 277250)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm	2021-05-09 19:04:22 UTC (rev 277251)
@@ -5087,6 +5087,12 @@
                 $rootString .= "        return false;\n";
                 $rootString .= "    if (UNLIKELY(reason))\n";
                 $rootString .= "        *reason = \"Reachable from ScriptExecutionContext\";\n";
+            } elsif (GetGenerateIsReachable($interface) eq "ImplWebXRSessionRoot") {
+                $rootString  = "    WebXRSession* root = WTF::getPtr(js${interfaceName}->wrapped().session());\n";
+                $rootString .= "    if (!root)\n";
+                $rootString .= "        return false;\n";
+                $rootString .= "    if (UNLIKELY(reason))\n";
+                $rootString .= "        *reason = \"Reachable from WebXRSession\";\n";
             } else {
                 $rootString  = "    void* root = WebCore::root(&js${interfaceName}->wrapped());\n";
                 $rootString .= "    if (UNLIKELY(reason))\n";
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to