Skip to content

Commit

Permalink
[Site Isolation][iOS] Remove hosted layer as subview instead of sublayer
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=269610
rdar://123113647

Reviewed by Alex Christensen.

On iOS, RemoteLayerTreeNode is backed by UIView, so we should modify remote layer tree by updating
the hierachy of UIView. This patch also adds a helper function to avoid this issue in the future.

* Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::updateLayerTree):
(WebKit::RemoteLayerTreeHost::createLayer):
(WebKit::RemoteLayerTreeHost::remotePageProcessCrashed):
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h:
* Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.mm:
(WebKit::RemoteLayerTreeNode::addToHostingNode):
(WebKit::RemoteLayerTreeNode::removeFromHostingNode):

Canonical link: https://commits.webkit.org/275004@main
  • Loading branch information
szewai authored and achristensen07 committed Feb 19, 2024
1 parent 4fc58fd commit 93760c4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
18 changes: 5 additions & 13 deletions Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,8 @@
return HashSet<WebCore::PlatformLayerIdentifier>();
}).iterator->value.add(rootNode->layerID());
rootNode->setRemoteContextHostedIdentifier(*contextHostedID);
if (auto* remoteRootNode = nodeForID(m_hostingLayers.get(*contextHostedID))) {
#if PLATFORM(IOS_FAMILY)
[remoteRootNode->uiView() addSubview:rootNode->uiView()];
#else
[remoteRootNode->layer() addSublayer:rootNode->layer()];
#endif
}
if (auto* remoteRootNode = nodeForID(m_hostingLayers.get(*contextHostedID)))
rootNode->addToHostingNode(*remoteRootNode);
}

for (auto& changedLayer : transaction.changedLayerProperties()) {
Expand Down Expand Up @@ -384,11 +379,7 @@
if (auto* hostIdentifier = std::get_if<WebCore::LayerHostingContextIdentifier>(&properties.additionalData)) {
m_hostingLayers.set(*hostIdentifier, properties.layerID);
if (auto* hostedNode = nodeForID(m_hostedLayers.get(*hostIdentifier)))
#if PLATFORM(IOS_FAMILY)
[node->uiView() addSubview:hostedNode->uiView()];
#else
[node->layer() addSublayer:hostedNode->layer()];
#endif
hostedNode->addToHostingNode(*node);
}

m_nodes.add(properties.layerID, WTFMove(node));
Expand Down Expand Up @@ -501,7 +492,8 @@ static void recursivelyMapIOSurfaceBackingStore(CALayer *layer)
void RemoteLayerTreeHost::remotePageProcessCrashed(WebCore::ProcessIdentifier processIdentifier)
{
for (auto layerID : m_hostedLayersInProcess.take(processIdentifier)) {
[layerForID(layerID) removeFromSuperlayer];
if (auto* node = nodeForID(layerID))
node->removeFromHostingNode();
layerWillBeRemoved(processIdentifier, layerID);
}
}
Expand Down
2 changes: 2 additions & 0 deletions Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class RemoteLayerTreeNode : public CanMakeWeakPtr<RemoteLayerTreeNode> {
Markable<WebCore::LayerHostingContextIdentifier> remoteContextHostingIdentifier() const { return m_remoteContextHostingIdentifier; }
Markable<WebCore::LayerHostingContextIdentifier> remoteContextHostedIdentifier() const { return m_remoteContextHostedIdentifier; }
void setRemoteContextHostedIdentifier(WebCore::LayerHostingContextIdentifier identifier) { m_remoteContextHostedIdentifier = identifier; }
void addToHostingNode(RemoteLayerTreeNode&);
void removeFromHostingNode();

// A cached CAIOSurface object to retain CA render resources.
struct CachedContentsBuffer {
Expand Down
18 changes: 18 additions & 0 deletions Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,24 @@
return [description stringByAppendingString:layerDescription];
}

void RemoteLayerTreeNode::addToHostingNode(RemoteLayerTreeNode& hostingNode)
{
#if PLATFORM(IOS_FAMILY)
[hostingNode.uiView() addSubview:uiView()];
#else
[hostingNode.layer() addSublayer:layer()];
#endif
}

void RemoteLayerTreeNode::removeFromHostingNode()
{
#if PLATFORM(IOS_FAMILY)
[uiView() removeFromSuperview];
#else
[layer() removeFromSuperlayer];
#endif
}

#if ENABLE(THREADED_ANIMATION_RESOLUTION)
void RemoteLayerTreeNode::setAcceleratedEffectsAndBaseValues(const WebCore::AcceleratedEffects& effects, const WebCore::AcceleratedEffectValues& baseValues, RemoteLayerTreeHost& host)
{
Expand Down

0 comments on commit 93760c4

Please sign in to comment.