Diff
Modified: trunk/Source/WebCore/ChangeLog (289222 => 289223)
--- trunk/Source/WebCore/ChangeLog 2022-02-07 16:21:48 UTC (rev 289222)
+++ trunk/Source/WebCore/ChangeLog 2022-02-07 17:01:12 UTC (rev 289223)
@@ -1,3 +1,14 @@
+2022-02-07 Ada Chan <[email protected]>
+
+ [WebXR] Handle updating session visibility state from PlatformXRCoordinator
+ https://bugs.webkit.org/show_bug.cgi?id=236150
+
+ Reviewed by Dean Jackson.
+
+ Add EnumTraits for PlatformXR::VisibilityState
+
+ * platform/xr/PlatformXR.h:
+
2022-02-07 Antti Koivisto <[email protected]>
[CSS Container Queries] Add ContainerQueryEvaluator
Modified: trunk/Source/WebCore/platform/xr/PlatformXR.h (289222 => 289223)
--- trunk/Source/WebCore/platform/xr/PlatformXR.h 2022-02-07 16:21:48 UTC (rev 289222)
+++ trunk/Source/WebCore/platform/xr/PlatformXR.h 2022-02-07 17:01:12 UTC (rev 289223)
@@ -676,6 +676,15 @@
>;
};
+template<> struct EnumTraits<PlatformXR::VisibilityState> {
+ using values = EnumValues<
+ PlatformXR::VisibilityState,
+ PlatformXR::VisibilityState::Visible,
+ PlatformXR::VisibilityState::VisibleBlurred,
+ PlatformXR::VisibilityState::Hidden
+ >;
+};
+
template<> struct EnumTraits<PlatformXR::XRHandedness> {
using values = EnumValues<
PlatformXR::XRHandedness,
Modified: trunk/Source/WebKit/ChangeLog (289222 => 289223)
--- trunk/Source/WebKit/ChangeLog 2022-02-07 16:21:48 UTC (rev 289222)
+++ trunk/Source/WebKit/ChangeLog 2022-02-07 17:01:12 UTC (rev 289223)
@@ -1,3 +1,36 @@
+2022-02-07 Ada Chan <[email protected]>
+
+ [WebXR] Handle updating session visibility state from PlatformXRCoordinator
+ https://bugs.webkit.org/show_bug.cgi?id=236150
+
+ Reviewed by Dean Jackson.
+
+ Add plumbing to allow PlatformXRCoordinator to communicate session visibility
+ state changes to XRDeviceProxy.
+
+ * Scripts/webkit/messages.py:
+ (types_that_cannot_be_forward_declared):
+ (headers_for_type):
+ * Shared/XR/XRDeviceProxy.cpp:
+ (WebKit::XRDeviceProxy::updateSessionVisibilityState):
+ Notify the PlatformXR::TrackingAndRenderingClient about the visibility state change.
+ * Shared/XR/XRDeviceProxy.h:
+ * UIProcess/XR/PlatformXRCoordinator.h:
+ Introduce a new protocol for PlatformXRCoordinator to communicate back
+ to PlatformXRSystem. This protocol so far has methods for notifying the
+ end of a session and visibility state changes in the session.
+ * UIProcess/XR/PlatformXRSystem.cpp:
+ (WebKit::PlatformXRSystem::initializeTrackingAndRendering):
+ startSession() now takes in the PlatformXRSystem instance as it now implements
+ SessionEventClient.
+ (WebKit::PlatformXRSystem::sessionDidEnd):
+ (WebKit::PlatformXRSystem::sessionDidUpdateVisibilityState):
+ * UIProcess/XR/PlatformXRSystem.h:
+ * WebProcess/XR/PlatformXRSystemProxy.cpp:
+ (WebKit::PlatformXRSystemProxy::sessionDidUpdateVisibilityState):
+ * WebProcess/XR/PlatformXRSystemProxy.h:
+ * WebProcess/XR/PlatformXRSystemProxy.messages.in:
+
2022-02-07 Wenson Hsieh <[email protected]>
Add a helper method on VideoFullscreenManagerProxy to request video frame data
Modified: trunk/Source/WebKit/Scripts/webkit/messages.py (289222 => 289223)
--- trunk/Source/WebKit/Scripts/webkit/messages.py 2022-02-07 16:21:48 UTC (rev 289222)
+++ trunk/Source/WebKit/Scripts/webkit/messages.py 2022-02-07 17:01:12 UTC (rev 289223)
@@ -265,6 +265,7 @@
'MediaTime',
'PlatformXR::ReferenceSpaceType',
'PlatformXR::SessionMode',
+ 'PlatformXR::VisibilityState',
'String',
'WebCore::BroadcastChannelIdentifier',
'WebCore::DestinationColorSpace',
@@ -744,6 +745,7 @@
'PlatformXR::Device::FrameData': ['<WebCore/PlatformXR.h>'],
'PlatformXR::ReferenceSpaceType': ['<WebCore/PlatformXR.h>'],
'PlatformXR::SessionMode': ['<WebCore/PlatformXR.h>'],
+ 'PlatformXR::VisibilityState': ['<WebCore/PlatformXR.h>'],
'Seconds': ['<wtf/Seconds.h>'],
'String': ['<wtf/text/WTFString.h>'],
'URL': ['<wtf/URLHash.h>'],
Modified: trunk/Source/WebKit/Shared/XR/XRDeviceProxy.cpp (289222 => 289223)
--- trunk/Source/WebKit/Shared/XR/XRDeviceProxy.cpp 2022-02-07 16:21:48 UTC (rev 289222)
+++ trunk/Source/WebKit/Shared/XR/XRDeviceProxy.cpp 2022-02-07 17:01:12 UTC (rev 289223)
@@ -57,6 +57,12 @@
trackingAndRenderingClient()->sessionDidEnd();
}
+void XRDeviceProxy::updateSessionVisibilityState(PlatformXR::VisibilityState visibilityState)
+{
+ if (trackingAndRenderingClient())
+ trackingAndRenderingClient()->updateSessionVisibilityState(visibilityState);
+}
+
void XRDeviceProxy::initializeTrackingAndRendering(PlatformXR::SessionMode sessionMode)
{
if (sessionMode != PlatformXR::SessionMode::ImmersiveVr)
Modified: trunk/Source/WebKit/Shared/XR/XRDeviceProxy.h (289222 => 289223)
--- trunk/Source/WebKit/Shared/XR/XRDeviceProxy.h 2022-02-07 16:21:48 UTC (rev 289222)
+++ trunk/Source/WebKit/Shared/XR/XRDeviceProxy.h 2022-02-07 17:01:12 UTC (rev 289223)
@@ -45,6 +45,7 @@
XRDeviceIdentifier identifier() const { return m_identifier; }
void sessionDidEnd();
+ void updateSessionVisibilityState(PlatformXR::VisibilityState);
private:
XRDeviceProxy(XRDeviceInfo&&, PlatformXRSystemProxy&);
Modified: trunk/Source/WebKit/UIProcess/XR/PlatformXRCoordinator.h (289222 => 289223)
--- trunk/Source/WebKit/UIProcess/XR/PlatformXRCoordinator.h 2022-02-07 16:21:48 UTC (rev 289222)
+++ trunk/Source/WebKit/UIProcess/XR/PlatformXRCoordinator.h 2022-02-07 17:01:12 UTC (rev 289223)
@@ -52,10 +52,17 @@
using FeatureListCallback = CompletionHandler<void(std::optional<PlatformXR::Device::FeatureList>&&)>;
virtual void requestPermissionOnSessionFeatures(WebPageProxy&, const WebCore::SecurityOriginData&, PlatformXR::SessionMode, const PlatformXR::Device::FeatureList& granted, const PlatformXR::Device::FeatureList& /* consentRequired */, const PlatformXR::Device::FeatureList& /* consentOptional */, FeatureListCallback&& completionHandler) { completionHandler(granted); }
-
+
+ class SessionEventClient : public CanMakeWeakPtr<SessionEventClient> {
+ public:
+ virtual ~SessionEventClient() = default;
+
+ virtual void sessionDidEnd(XRDeviceIdentifier) = 0;
+ virtual void sessionDidUpdateVisibilityState(XRDeviceIdentifier, PlatformXR::VisibilityState) = 0;
+ };
+
// Session creation/termination.
- using _OnSessionEndCallback_ = Function<void(XRDeviceIdentifier)>;
- virtual void startSession(WebPageProxy&, OnSessionEndCallback&&) = 0;
+ virtual void startSession(WebPageProxy&, WeakPtr<SessionEventClient>&&) = 0;
virtual void endSessionIfExists(WebPageProxy&) = 0;
// Session display loop.
Modified: trunk/Source/WebKit/UIProcess/XR/PlatformXRSystem.cpp (289222 => 289223)
--- trunk/Source/WebKit/UIProcess/XR/PlatformXRSystem.cpp 2022-02-07 16:21:48 UTC (rev 289222)
+++ trunk/Source/WebKit/UIProcess/XR/PlatformXRSystem.cpp 2022-02-07 17:01:12 UTC (rev 289223)
@@ -28,7 +28,6 @@
#if ENABLE(WEBXR)
-#include "PlatformXRCoordinator.h"
#include "PlatformXRSystemMessages.h"
#include "PlatformXRSystemProxyMessages.h"
#include "WebPageProxy.h"
@@ -91,14 +90,10 @@
if (!xrCoordinator)
return;
- auto immersiveSessionActivity = m_page.process().throttler().foregroundActivity("XR immersive session"_s);
+ m_immersiveSessionActivity = m_page.process().throttler().foregroundActivity("XR immersive session"_s).moveToUniquePtr();
- xrCoordinator->startSession(m_page, [weakThis = WeakPtr { *this }, immersiveSessionActivity = WTFMove(immersiveSessionActivity)](XRDeviceIdentifier deviceIdentifier) mutable {
- RunLoop::main().dispatch([weakThis, deviceIdentifier, immersiveSessionActivity = WTFMove(immersiveSessionActivity)]() mutable {
- if (weakThis)
- weakThis->m_page.send(Messages::PlatformXRSystemProxy::SessionDidEnd(deviceIdentifier));
- });
- });
+ WeakPtr weakThis { *this };
+ xrCoordinator->startSession(m_page, weakThis);
}
void PlatformXRSystem::shutDownTrackingAndRendering()
@@ -119,8 +114,31 @@
xrCoordinator->submitFrame(m_page);
}
+void PlatformXRSystem::sessionDidEnd(XRDeviceIdentifier deviceIdentifier)
+{
+ ensureOnMainRunLoop([weakThis = WeakPtr { *this }, deviceIdentifier]() mutable {
+ auto strongThis = weakThis.get();
+ if (!strongThis)
+ return;
+
+ strongThis->m_page.send(Messages::PlatformXRSystemProxy::SessionDidEnd(deviceIdentifier));
+ strongThis->m_immersiveSessionActivity = nullptr;
+ });
}
+void PlatformXRSystem::sessionDidUpdateVisibilityState(XRDeviceIdentifier deviceIdentifier, PlatformXR::VisibilityState visibilityState)
+{
+ ensureOnMainRunLoop([weakThis = WeakPtr { *this }, deviceIdentifier, visibilityState]() mutable {
+ auto strongThis = weakThis.get();
+ if (!strongThis)
+ return;
+
+ strongThis->m_page.send(Messages::PlatformXRSystemProxy::SessionDidUpdateVisibilityState(deviceIdentifier, visibilityState));
+ });
+}
+
+}
+
#if !USE(APPLE_INTERNAL_SDK)
namespace WebKit {
Modified: trunk/Source/WebKit/UIProcess/XR/PlatformXRSystem.h (289222 => 289223)
--- trunk/Source/WebKit/UIProcess/XR/PlatformXRSystem.h 2022-02-07 16:21:48 UTC (rev 289222)
+++ trunk/Source/WebKit/UIProcess/XR/PlatformXRSystem.h 2022-02-07 17:01:12 UTC (rev 289223)
@@ -28,6 +28,8 @@
#if ENABLE(WEBXR)
#include "MessageReceiver.h"
+#include "PlatformXRCoordinator.h"
+#include "ProcessThrottler.h"
#include "WebCoreArgumentCoders.h"
#include <WebCore/PlatformXR.h>
@@ -42,12 +44,15 @@
struct XRDeviceInfo;
-class PlatformXRSystem : public IPC::MessageReceiver {
+class PlatformXRSystem : public IPC::MessageReceiver, public PlatformXRCoordinator::SessionEventClient {
WTF_MAKE_FAST_ALLOCATED;
public:
PlatformXRSystem(WebPageProxy&);
virtual ~PlatformXRSystem();
+ using PlatformXRCoordinator::SessionEventClient::weakPtrFactory;
+ using WeakValueType = PlatformXRCoordinator::SessionEventClient::WeakValueType;
+
void invalidate();
private:
@@ -64,7 +69,12 @@
void requestFrame(CompletionHandler<void(PlatformXR::Device::FrameData&&)>&&);
void submitFrame();
+ // PlatformXRCoordinator::SessionEventClient
+ void sessionDidEnd(XRDeviceIdentifier) final;
+ void sessionDidUpdateVisibilityState(XRDeviceIdentifier, PlatformXR::VisibilityState) final;
+
WebPageProxy& m_page;
+ std::unique_ptr<ProcessThrottler::ForegroundActivity> m_immersiveSessionActivity;
};
} // namespace WebKit
Modified: trunk/Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.cpp (289222 => 289223)
--- trunk/Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.cpp 2022-02-07 16:21:48 UTC (rev 289222)
+++ trunk/Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.cpp 2022-02-07 17:01:12 UTC (rev 289223)
@@ -106,6 +106,12 @@
device->sessionDidEnd();
}
+void PlatformXRSystemProxy::sessionDidUpdateVisibilityState(XRDeviceIdentifier deviceIdentifier, PlatformXR::VisibilityState visibilityState)
+{
+ if (auto device = deviceByIdentifier(deviceIdentifier))
+ device->updateSessionVisibilityState(visibilityState);
+}
+
RefPtr<XRDeviceProxy> PlatformXRSystemProxy::deviceByIdentifier(XRDeviceIdentifier identifier)
{
for (auto& device : m_devices) {
Modified: trunk/Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.h (289222 => 289223)
--- trunk/Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.h 2022-02-07 16:21:48 UTC (rev 289222)
+++ trunk/Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.h 2022-02-07 17:01:12 UTC (rev 289223)
@@ -61,6 +61,7 @@
// Message handlers
void sessionDidEnd(XRDeviceIdentifier);
+ void sessionDidUpdateVisibilityState(XRDeviceIdentifier, PlatformXR::VisibilityState);
PlatformXR::Instance::DeviceList m_devices;
WebPage& m_page;
Modified: trunk/Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.messages.in (289222 => 289223)
--- trunk/Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.messages.in 2022-02-07 16:21:48 UTC (rev 289222)
+++ trunk/Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.messages.in 2022-02-07 17:01:12 UTC (rev 289223)
@@ -27,6 +27,7 @@
messages -> PlatformXRSystemProxy NotRefCounted {
SessionDidEnd(WebKit::XRDeviceIdentifier deviceIdentifier)
+ SessionDidUpdateVisibilityState(WebKit::XRDeviceIdentifier deviceIdentifier, PlatformXR::VisibilityState visibilityState)
}
#endif