Diff
Modified: trunk/LayoutTests/ChangeLog (288895 => 288896)
--- trunk/LayoutTests/ChangeLog 2022-02-01 18:36:10 UTC (rev 288895)
+++ trunk/LayoutTests/ChangeLog 2022-02-01 18:37:19 UTC (rev 288896)
@@ -1,3 +1,14 @@
+2022-02-01 Ada Chan <[email protected]>
+
+ [WebXR] Handle changes in XRSession's visibility state
+ https://bugs.webkit.org/show_bug.cgi?id=235898
+
+ Reviewed by Sergio Villar Senin.
+
+ * TestExpectations:
+ Unskip xrSession_visibilityState.https.html
+ * platform/mac/imported/w3c/web-platform-tests/webxr/xrSession_visibilityState.https-expected.txt: Removed.
+
2022-02-01 Eric Carlson <[email protected]>
[macOS] Expose screen and window capture state to WKWebView
Modified: trunk/LayoutTests/TestExpectations (288895 => 288896)
--- trunk/LayoutTests/TestExpectations 2022-02-01 18:36:10 UTC (rev 288895)
+++ trunk/LayoutTests/TestExpectations 2022-02-01 18:37:19 UTC (rev 288896)
@@ -4863,7 +4863,6 @@
webkit.org/b/208988 imported/w3c/web-platform-tests/webxr/getInputPose_pointer.https.html [ Skip ]
webkit.org/b/208988 imported/w3c/web-platform-tests/webxr/xrDevice_disconnect_ends.https.html [ Skip ]
webkit.org/b/208988 imported/w3c/web-platform-tests/webxr/xrFrame_getViewerPose_getPose_identities.https.html [ Skip ]
-webkit.org/b/208988 imported/w3c/web-platform-tests/webxr/xrSession_visibilityState.https.html [ Skip ]
webkit.org/b/208988 imported/w3c/web-platform-tests/webxr/xr_viewport_scale.https.html [ Skip ]
# WebXR - Currently failing and needs more investigation.
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (288895 => 288896)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2022-02-01 18:36:10 UTC (rev 288895)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2022-02-01 18:37:19 UTC (rev 288896)
@@ -1,3 +1,14 @@
+2022-02-01 Ada Chan <[email protected]>
+
+ [WebXR] Handle changes in XRSession's visibility state
+ https://bugs.webkit.org/show_bug.cgi?id=235898
+
+ Reviewed by Sergio Villar Senin.
+
+ Update expectation with passing results.
+
+ * web-platform-tests/webxr/xrSession_visibilityState.https-expected.txt:
+
2022-02-01 Antoine Quint <[email protected]>
Redefining @keyframes does not work
Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/xrSession_visibilityState.https-expected.txt (288895 => 288896)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/xrSession_visibilityState.https-expected.txt 2022-02-01 18:36:10 UTC (rev 288895)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/webxr/xrSession_visibilityState.https-expected.txt 2022-02-01 18:37:19 UTC (rev 288896)
@@ -1,3 +1,4 @@
-FAIL Ensures that the XRSession's visibilityState is correctly reported and that the associated visibilitychange event fires. promise_test: Unhandled rejection with value: "Session with params \"immersive-vr\" was rejected on device {\"supportsImmersive\":true,\"supportedModes\":[\"inline\",\"immersive-vr\"],\"views\":[{\"eye\":\"left\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[-0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}},{\"eye\":\"right\",\"projectionMatrix\":[1,0,0,0,0,1,0,0,3,2,-1,-1,0,0,-0.2,0],\"viewOffset\":{\"position\":[0.1,0,0],\"orientation\":[0,0,0,1]},\"resolution\":{\"width\":200,\"height\":200}}],\"viewerOrigin\":{\"
;position\":[0,0,0],\"orientation\":[0,0,0,1]},\"supportedFeatures\":[\"viewer\",\"local\",\"local-floor\",\"bounded-floor\",\"unbounded\",\"hit-test\",\"dom-overlay\",\"light-estimation\",\"anchors\"]} with error: OperationError: Unable to allocate XRWebGLLayer GPU resources."
+PASS Ensures that the XRSession's visibilityState is correctly reported and that the associated visibilitychange event fires. - webgl
+PASS Ensures that the XRSession's visibilityState is correctly reported and that the associated visibilitychange event fires. - webgl2
Deleted: trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/webxr/xrSession_visibilityState.https-expected.txt (288895 => 288896)
--- trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/webxr/xrSession_visibilityState.https-expected.txt 2022-02-01 18:36:10 UTC (rev 288895)
+++ trunk/LayoutTests/platform/mac/imported/w3c/web-platform-tests/webxr/xrSession_visibilityState.https-expected.txt 2022-02-01 18:37:19 UTC (rev 288896)
@@ -1,6 +0,0 @@
-
-Harness Error (TIMEOUT), message = null
-
-TIMEOUT Ensures that the XRSession's visibilityState is correctly reported and that the associated visibilitychange event fires. - webgl Test timed out
-NOTRUN Ensures that the XRSession's visibilityState is correctly reported and that the associated visibilitychange event fires. - webgl2
-
Modified: trunk/Source/WebCore/ChangeLog (288895 => 288896)
--- trunk/Source/WebCore/ChangeLog 2022-02-01 18:36:10 UTC (rev 288895)
+++ trunk/Source/WebCore/ChangeLog 2022-02-01 18:37:19 UTC (rev 288896)
@@ -1,3 +1,27 @@
+2022-02-01 Ada Chan <[email protected]>
+
+ [WebXR] Handle changes in XRSession's visibility state
+ https://bugs.webkit.org/show_bug.cgi?id=235898
+
+ Reviewed by Sergio Villar Senin.
+
+ Add a new method in WebXRSession for handling visibility state updates.
+ When the session regains visibility and there are pending frame update
+ requests, trigger a frame request. Also dispatch a visibilitychange
+ event when the visibility state changes.
+
+ * Modules/webxr/WebXRSession.cpp:
+ (WebCore::WebXRSession::updateSessionVisibilityState):
+ (WebCore::WebXRSession::onFrame):
+ Bail early if the visibility state is hidden.
+ * Modules/webxr/WebXRSession.h:
+ * Modules/webxr/XRVisibilityState.h:
+ * platform/xr/PlatformXR.h:
+ * testing/WebFakeXRDevice.cpp:
+ (WebCore::SimulatedXRDevice::setVisibilityState):
+ (WebCore::WebFakeXRDevice::simulateVisibilityChange):
+ * testing/WebFakeXRDevice.h:
+
2022-02-01 Eric Carlson <[email protected]>
[macOS] Expose screen and window capture state to WKWebView
Modified: trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp (288895 => 288896)
--- trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp 2022-02-01 18:36:10 UTC (rev 288895)
+++ trunk/Source/WebCore/Modules/webxr/WebXRSession.cpp 2022-02-01 18:37:19 UTC (rev 288896)
@@ -446,6 +446,25 @@
shutdown(InitiatedBySystem::Yes);
}
+void WebXRSession::updateSessionVisibilityState(PlatformXR::VisibilityState visibilityState)
+{
+ if (m_visibilityState == visibilityState)
+ return;
+
+ bool wasHidden = m_visibilityState == XRVisibilityState::Hidden;
+
+ m_visibilityState = visibilityState;
+
+ if (wasHidden && !m_ended && !m_callbacks.isEmpty())
+ requestFrame();
+
+ // From https://immersive-web.github.io/webxr/#event-types
+ // A user agent MUST dispatch a visibilitychange event on an XRSession each time the
+ // visibility state of the XRSession has changed. The event MUST be of type XRSessionEvent.
+ auto event = XRSessionEvent::create(eventNames().visibilitychangeEvent, { RefPtr { this } });
+ queueTaskToDispatchEvent(*this, TaskSource::WebXR, WTFMove(event));
+}
+
void WebXRSession::applyPendingRenderState()
{
// https: //immersive-web.github.io/webxr/#apply-the-pending-render-state
@@ -518,9 +537,16 @@
if (m_ended)
return;
+ // From https://immersive-web.github.io/webxr/#xrsession-visibility-state
+ // A state of hidden indicates that imagery rendered by the XRSession cannot be seen by the user.
+ // requestAnimationFrame() callbacks will not be processed until the visibility state changes.
+ // Input is not processed by the XRSession.
+ if (m_visibilityState == XRVisibilityState::Hidden)
+ return;
+
// Queue a task to perform the following steps.
queueTaskKeepingObjectAlive(*this, TaskSource::WebXR, [this, frameData = WTFMove(frameData)]() mutable {
- if (m_ended)
+ if (m_ended || m_visibilityState == XRVisibilityState::Hidden)
return;
m_frameData = WTFMove(frameData);
Modified: trunk/Source/WebCore/Modules/webxr/WebXRSession.h (288895 => 288896)
--- trunk/Source/WebCore/Modules/webxr/WebXRSession.h 2022-02-01 18:36:10 UTC (rev 288895)
+++ trunk/Source/WebCore/Modules/webxr/WebXRSession.h 2022-02-01 18:37:19 UTC (rev 288896)
@@ -114,6 +114,7 @@
// PlatformXR::TrackingAndRenderingClient
void sessionDidInitializeInputSources(Vector<PlatformXR::Device::FrameData::InputSource>&&) final;
void sessionDidEnd() final;
+ void updateSessionVisibilityState(PlatformXR::VisibilityState) final;
enum class InitiatedBySystem : bool { No, Yes };
void shutdown(InitiatedBySystem);
Modified: trunk/Source/WebCore/Modules/webxr/XRVisibilityState.h (288895 => 288896)
--- trunk/Source/WebCore/Modules/webxr/XRVisibilityState.h 2022-02-01 18:36:10 UTC (rev 288895)
+++ trunk/Source/WebCore/Modules/webxr/XRVisibilityState.h 2022-02-01 18:37:19 UTC (rev 288896)
@@ -27,13 +27,11 @@
#if ENABLE(WEBXR)
+#include "PlatformXR.h"
+
namespace WebCore {
-enum class XRVisibilityState {
- Visible,
- VisibleBlurred,
- Hidden
-};
+using XRVisibilityState = PlatformXR::VisibilityState;
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/xr/PlatformXR.h (288895 => 288896)
--- trunk/Source/WebCore/platform/xr/PlatformXR.h 2022-02-01 18:36:10 UTC (rev 288895)
+++ trunk/Source/WebCore/platform/xr/PlatformXR.h 2022-02-01 18:37:19 UTC (rev 288896)
@@ -59,6 +59,12 @@
Right,
};
+enum class VisibilityState {
+ Visible,
+ VisibleBlurred,
+ Hidden
+};
+
using LayerHandle = int;
#if ENABLE(WEBXR)
@@ -312,8 +318,8 @@
// Per-frame input source updates are handled via session.requestAnimationFrame which calls Device::requestFrame.
virtual void sessionDidInitializeInputSources(Vector<Device::FrameData::InputSource>&&) = 0;
virtual void sessionDidEnd() = 0;
+ virtual void updateSessionVisibilityState(VisibilityState) = 0;
// FIXME: handle frame update
- // FIXME: handle visibility changes
};
class Instance {
Modified: trunk/Source/WebCore/testing/WebFakeXRDevice.cpp (288895 => 288896)
--- trunk/Source/WebCore/testing/WebFakeXRDevice.cpp 2022-02-01 18:36:10 UTC (rev 288895)
+++ trunk/Source/WebCore/testing/WebFakeXRDevice.cpp 2022-02-01 18:37:19 UTC (rev 288896)
@@ -91,6 +91,12 @@
m_frameData.isTrackingValid = false;
}
+void SimulatedXRDevice::setVisibilityState(XRVisibilityState visibilityState)
+{
+ if (m_trackingAndRenderingClient)
+ m_trackingAndRenderingClient->updateSessionVisibilityState(visibilityState);
+}
+
void SimulatedXRDevice::simulateShutdownCompleted()
{
if (m_trackingAndRenderingClient)
@@ -250,8 +256,9 @@
m_device.setEmulatedPosition(emulatedPosition);
}
-void WebFakeXRDevice::simulateVisibilityChange(XRVisibilityState)
+void WebFakeXRDevice::simulateVisibilityChange(XRVisibilityState visibilityState)
{
+ m_device.setVisibilityState(visibilityState);
}
void WebFakeXRDevice::setFloorOrigin(FakeXRRigidTransformInit origin)
Modified: trunk/Source/WebCore/testing/WebFakeXRDevice.h (288895 => 288896)
--- trunk/Source/WebCore/testing/WebFakeXRDevice.h 2022-02-01 18:36:10 UTC (rev 288895)
+++ trunk/Source/WebCore/testing/WebFakeXRDevice.h 2022-02-01 18:37:19 UTC (rev 288896)
@@ -78,6 +78,7 @@
void setFloorOrigin(std::optional<FrameData::Pose>&& origin) { m_frameData.floorTransform = WTFMove(origin); }
void setEmulatedPosition(bool emulated) { m_frameData.isPositionEmulated = emulated; }
void setSupportsShutdownNotification(bool supportsShutdownNotification) { m_supportsShutdownNotification = supportsShutdownNotification; }
+ void setVisibilityState(XRVisibilityState);
void simulateShutdownCompleted();
void scheduleOnNextFrame(Function<void()>&&);
void addInputConnection(Ref<WebFakeXRInputController>&& input) { m_inputConnections.append(WTFMove(input)); };