Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3faa7e4c4945b792290462314a65a3a906f016ac
      
https://github.com/WebKit/WebKit/commit/3faa7e4c4945b792290462314a65a3a906f016ac
  Author: Rupin Mittal <[email protected]>
  Date:   2026-01-09 (Fri, 09 Jan 2026)

  Changed paths:
    M Source/WebCore/platform/ios/MotionManagerClient.h
    M Source/WebKit/Sources.txt
    M Source/WebKit/UIProcess/RemotePageProxy.cpp
    M Source/WebKit/UIProcess/RemotePageProxy.h
    A 
Source/WebKit/UIProcess/RemotePageWebDeviceOrientationUpdateProviderProxy.cpp
    A 
Source/WebKit/UIProcess/RemotePageWebDeviceOrientationUpdateProviderProxy.h
    M Source/WebKit/UIProcess/WebPageProxy.cpp
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.h
    M Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm
    M Source/WebKit/WebKit.xcodeproj/project.pbxproj

  Log Message:
  -----------
  [Site Isolation] REGRESSION(304018@main): Triggers assertions in Site 
Isolation iOS API tests
https://bugs.webkit.org/show_bug.cgi?id=305164
rdar://167455575

Reviewed by Alex Christensen.

304018@main added support for DeviceOrientationEvents in cross-site iframes with
Site Isolation enabled.

One of the fixes it made was to ensure that the cross-site iframe's WebProcess
could send IPC messages to the WebDeviceOrientationUpdateProviderProxy in the
UI Process. To make sure that WebDeviceOrientationUpdateProviderProxy was a
message receiver for this Web Process, new functions were added to it to add
and remove itself as a message receiver for the cross-site Web Process, which
would be called by the RemotePageProxy on its construction and destruction.

The crash report shows that WebDeviceOrientationUpdateProviderProxy is being
destroyed before the RemotePageProxy. So it is still registered as a message
receiver, causing this assertion to be hit: ASSERT(!m_messageReceiverMapCount);

So we refactor the code to follow a common pattern in site isolation:
WebDeviceOrientationUpdateProviderProxy will not receive messages directly from
the cross-site Web Processes. Rather, a new object is created which will receive
these messages and forward them to WebDeviceOrientationUpdateProviderProxy. This
new object will be the one registered as a message receiver and the 
RemotePageProxy
will register and unregister it from injectPageIntoNewProcess() and 
disconnect().
The new object is called RemotePageWebDeviceOrientationUpdateProviderProxy.

In order to forward messages to WebDeviceOrientationUpdateProviderProxy,
RemotePageWebDeviceOrientationUpdateProviderProxy must hold a reference to it.
This must be weak because it doesn't want to manage the lifetime of
WebDeviceOrientationUpdateProviderProxy. The issue here is that
WebDeviceOrientationUpdateProviderProxy inherits from two different classes that
both inherit from CanMakeWeakPtr so the construction of the WeakPtr is ambiguous
and fails. To fix this, we instead make 
RemotePageWebDeviceOrientationUpdateProviderProxy
hold a weak reference to one of these parent classes (MotionManagerClient) which
will dynamically downcasted to WebDeviceOrientationUpdateProviderProxy when 
needed.

The testing of the change is covered by the existing test:
(SiteIsolation.CrossSiteIFrameCanReceiveDeviceOrientationEvents) as well as the
tests that were broken by 304018@main and are fixed by this patch (such as
SiteIsolation.LoadHTMLString).

* Source/WebCore/platform/ios/MotionManagerClient.h:
(WebCore::MotionManagerClient::isWebDeviceOrientationUpdateProviderProxy const):
* Source/WebKit/Sources.txt:
* Source/WebKit/UIProcess/RemotePageProxy.cpp:
(WebKit::RemotePageProxy::RemotePageProxy):
(WebKit::RemotePageProxy::disconnect):
(WebKit::RemotePageProxy::injectPageIntoNewProcess):
* Source/WebKit/UIProcess/RemotePageProxy.h:
* 
Source/WebKit/UIProcess/RemotePageWebDeviceOrientationUpdateProviderProxy.cpp: 
Added.
(WebKit::RemotePageWebDeviceOrientationUpdateProviderProxy::create):
(WebKit::RemotePageWebDeviceOrientationUpdateProviderProxy::RemotePageWebDeviceOrientationUpdateProviderProxy):
(WebKit::RemotePageWebDeviceOrientationUpdateProviderProxy::~RemotePageWebDeviceOrientationUpdateProviderProxy):
(WebKit::RemotePageWebDeviceOrientationUpdateProviderProxy::didReceiveMessage):
* Source/WebKit/UIProcess/RemotePageWebDeviceOrientationUpdateProviderProxy.h: 
Added.
* Source/WebKit/UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::protectedWebDeviceOrientationUpdateProviderProxy):
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.h:
(isType):
* Source/WebKit/UIProcess/ios/WebDeviceOrientationUpdateProviderProxy.mm:
(WebKit::WebDeviceOrientationUpdateProviderProxy::addAsMessageReceiverForProcess):
 Deleted.
(WebKit::WebDeviceOrientationUpdateProviderProxy::removeAsMessageReceiverForProcess):
 Deleted.
* Source/WebKit/WebKit.xcodeproj/project.pbxproj:

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



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to