Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: a3fcf4fdfbc19460ad56323d2c0dbb4c26906d2f
      
https://github.com/WebKit/WebKit/commit/a3fcf4fdfbc19460ad56323d2c0dbb4c26906d2f
  Author: Ada Chan <[email protected]>
  Date:   2024-06-26 (Wed, 26 Jun 2024)

  Changed paths:
    M Source/WebCore/Modules/webxr/WebXRSession.cpp
    M Source/WebCore/platform/xr/PlatformXR.h
    M Source/WebKit/Shared/XR/XRDeviceProxy.cpp
    M Source/WebKit/Shared/XR/XRDeviceProxy.h
    M Source/WebKit/UIProcess/XR/PlatformXRSystem.cpp
    M Source/WebKit/UIProcess/XR/PlatformXRSystem.h
    M Source/WebKit/UIProcess/XR/PlatformXRSystem.messages.in
    M Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.cpp
    M Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.h

  Log Message:
  -----------
  [WebXR] Fix MESSAGE_CHECK failure in PlatformXRSystem::RequestFrame()
https://bugs.webkit.org/show_bug.cgi?id=275912
rdar://130300869

Reviewed by Mike Wyrzykowski and Dan Glastonbury.

If the WebXR immersive session was triggered by the system, 
PlatformXRSystem::sessionDidEnd()
would be called on the UI process side first, which updated the session state 
to Idle.
However, during the short period when the UI process had handled the session 
end request but
the web process had not handled it yet, PlatformXRSystem::requestFrame() could 
still be called
on the UI process side, which would fail the m_immersiveSessionState == 
SessionRunning check.

To fix this, we introduce two new immersive session states: 
SessionEndingFromSystem and
SessionEndingFromWebContent. If PlatformXRSystem::sessionDidEnd() is called 
while the state
is SessionRunning, that means the session end request comes from the system and 
we'll update
the state to SessionEndingFromSystem. The message check in 
PlatformXRSystem::requestFrame()
has been updated to allow the state to be either SessionRunning and 
SessionEndingFromSystem,
but will skip the actual frame update if it's SessionEndingFromSystem. When the 
web process
has ended the XR session, it'll send the 
PlatformXRSystem::didCompleteShutdownTriggeredBySystem
message which will reset PlatformXRSystem::m_immersiveSessionState back to Idle.

If the session end request comes from XRSession.end(), then 
PlatformXRSystem::shutDownTrackingAndRendering()
will be called first when the state is SessionRunning, and the session state 
will be updated
to SessionEndingFromWebContent. After the system has finished the work to end 
the session,
PlatformXRSystem::sessionDidEnd() will be called which will update the session 
state to Idle.

* Source/WebCore/Modules/webxr/WebXRSession.cpp:
(WebCore::WebXRSession::shutdown):
If the ending of the XR session is triggered by the system, call
PlatformXR::Device::didCompleteShutdownTriggeredBySystem() after
finishing the shutdown work.
* Source/WebCore/platform/xr/PlatformXR.h:
(PlatformXR::Device::didCompleteShutdownTriggeredBySystem):
* Source/WebKit/Shared/XR/XRDeviceProxy.cpp:
(WebKit::XRDeviceProxy::didCompleteShutdownTriggeredBySystem):
(WebKit::XRDeviceProxy::requestFrame):
Make sure the completion handler is always called.
* Source/WebKit/Shared/XR/XRDeviceProxy.h:
* Source/WebKit/UIProcess/XR/PlatformXRSystem.cpp:
(WebKit::PlatformXRSystem::shutDownTrackingAndRendering):
(WebKit::PlatformXRSystem::requestFrame):
Allow the session state to be either SessionRunning and SessionEndingFromSystem.
But skip the frame update if it's SessionEndingFromSystem.
Make sure the completion handler is called even if there's no xrCoordinator.
(WebKit::PlatformXRSystem::submitFrame):
Allow the session state to be either SessionRunning and SessionEndingFromSystem.
(WebKit::PlatformXRSystem::didCompleteShutdownTriggeredBySystem):
Make sure we'll only get here from handling a session end request from the 
system.
Reset the state back to Idle.
(WebKit::PlatformXRSystem::sessionDidEnd):
If this is called when the state is SessionRunning, the session is being ended
by the system so set the next state to be SessionEndingFromSystem. Otherwise,
reset it back to Idle.
(WebKit::PlatformXRSystem::invalidateImmersiveSessionState):
* Source/WebKit/UIProcess/XR/PlatformXRSystem.h:
* Source/WebKit/UIProcess/XR/PlatformXRSystem.messages.in:
* Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.cpp:
(WebKit::PlatformXRSystemProxy::didCompleteShutdownTriggeredBySystem):
* Source/WebKit/WebProcess/XR/PlatformXRSystemProxy.h:

Canonical link: https://commits.webkit.org/280392@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to