<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[282189] trunk/Source/WebKit</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/282189">282189</a></dd>
<dt>Author</dt> <dd>timothy_horton@apple.com</dd>
<dt>Date</dt> <dd>2021-09-08 19:46:01 -0700 (Wed, 08 Sep 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>WKWebView specific bug: WKWebView as the contents of a SceneKit/ARKit node doesn't work (UIWebView works)
https://bugs.webkit.org/show_bug.cgi?id=203060
<rdar://problem/82899923>

Reviewed by Dean Jackson.

SceneKit's snapshotter cannot handle CAMachPort-as-layer-contents.

If we get parented in a SceneKit snapshotting window, map all existing
surfaces, and prefer using actual IOSurfaces instead of CAMachPort from then on.

* UIProcess/Cocoa/PageClientImplCocoa.h:
* UIProcess/Cocoa/PageClientImplCocoa.mm:
(WebKit::PageClientImplCocoa::windowKind):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::webViewDidMoveToWindow):
* UIProcess/WebPageProxy.h:
* UIProcess/WindowKind.h: Added.
Keep track of the kind of window we're currently in (the only special
case at the moment is the SceneKit snapshotting window, but you could
easily imagine us caring about others).

* UIProcess/DrawingAreaProxy.h:
(WebKit::DrawingAreaProxy::windowKindDidChange):
* UIProcess/PageClient.h:
(WebKit::PageClient::windowKind):
* UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h:
* UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
(WebKit::RemoteLayerTreeDrawingAreaProxy::windowKindDidChange):
Map CAMachPorts to IOSurfaces when we move into a SceneKit snapshotting window.

* UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h:
* UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
(WebKit::RemoteLayerTreeHost::layerContentsType const):
(WebKit::RemoteLayerTreeHost::updateLayerTree):
Prefer IOSurface if we're already in a SceneKit snapshotting window.
Also factor this code out and improve the comments.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitChangeLog">trunk/Source/WebKit/ChangeLog</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaPageClientImplCocoah">trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessCocoaPageClientImplCocoamm">trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessDrawingAreaProxyh">trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessPageClienth">trunk/Source/WebKit/UIProcess/PageClient.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessRemoteLayerTreeRemoteLayerTreeDrawingAreaProxyh">trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessRemoteLayerTreeRemoteLayerTreeDrawingAreaProxymm">trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessRemoteLayerTreeRemoteLayerTreeHosth">trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h</a></li>
<li><a href="#trunkSourceWebKitUIProcessRemoteLayerTreeRemoteLayerTreeHostmm">trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxycpp">trunk/Source/WebKit/UIProcess/WebPageProxy.cpp</a></li>
<li><a href="#trunkSourceWebKitUIProcessWebPageProxyh">trunk/Source/WebKit/UIProcess/WebPageProxy.h</a></li>
<li><a href="#trunkSourceWebKitWebKitxcodeprojprojectpbxproj">trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKitUIProcessWindowKindh">trunk/Source/WebKit/UIProcess/WindowKind.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebKitChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/ChangeLog (282188 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/ChangeLog    2021-09-09 01:47:36 UTC (rev 282188)
+++ trunk/Source/WebKit/ChangeLog       2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -1,3 +1,43 @@
</span><ins>+2021-09-08  Tim Horton  <timothy_horton@apple.com>
+
+        WKWebView specific bug: WKWebView as the contents of a SceneKit/ARKit node doesn't work (UIWebView works)
+        https://bugs.webkit.org/show_bug.cgi?id=203060
+        <rdar://problem/82899923>
+
+        Reviewed by Dean Jackson.
+
+        SceneKit's snapshotter cannot handle CAMachPort-as-layer-contents.
+
+        If we get parented in a SceneKit snapshotting window, map all existing
+        surfaces, and prefer using actual IOSurfaces instead of CAMachPort from then on.
+
+        * UIProcess/Cocoa/PageClientImplCocoa.h:
+        * UIProcess/Cocoa/PageClientImplCocoa.mm:
+        (WebKit::PageClientImplCocoa::windowKind):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::webViewDidMoveToWindow):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WindowKind.h: Added.
+        Keep track of the kind of window we're currently in (the only special
+        case at the moment is the SceneKit snapshotting window, but you could
+        easily imagine us caring about others).
+
+        * UIProcess/DrawingAreaProxy.h:
+        (WebKit::DrawingAreaProxy::windowKindDidChange):
+        * UIProcess/PageClient.h:
+        (WebKit::PageClient::windowKind):
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h:
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
+        (WebKit::RemoteLayerTreeDrawingAreaProxy::windowKindDidChange):
+        Map CAMachPorts to IOSurfaces when we move into a SceneKit snapshotting window.
+
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h:
+        * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
+        (WebKit::RemoteLayerTreeHost::layerContentsType const):
+        (WebKit::RemoteLayerTreeHost::updateLayerTree):
+        Prefer IOSurface if we're already in a SceneKit snapshotting window.
+        Also factor this code out and improve the comments.
+
</ins><span class="cx"> 2021-09-08  Fujii Hironori  <Hironori.Fujii@sony.com>
</span><span class="cx"> 
</span><span class="cx">         REGRESSION(r282115): undefined reference to `IPC::messageArgumentDescriptions(IPC::MessageName)' in Debug build
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaPageClientImplCocoah"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h (282188 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h        2021-09-09 01:47:36 UTC (rev 282188)
+++ trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h   2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -87,6 +87,8 @@
</span><span class="cx">     void microphoneCaptureChanged() final;
</span><span class="cx">     void cameraCaptureChanged() final;
</span><span class="cx"> 
</span><ins>+    WindowKind windowKind() final;
+
</ins><span class="cx"> protected:
</span><span class="cx">     WeakObjCPtr<WKWebView> m_webView;
</span><span class="cx">     std::unique_ptr<WebCore::AlternativeTextUIController> m_alternativeTextUIController;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessCocoaPageClientImplCocoamm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm (282188 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm       2021-09-09 01:47:36 UTC (rev 282188)
+++ trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm  2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -193,4 +193,14 @@
</span><span class="cx">     [m_webView didChangeValueForKey:@"cameraCaptureState"];
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+WindowKind PageClientImplCocoa::windowKind()
+{
+    auto window = [m_webView window];
+    if (!window)
+        return WindowKind::Unparented;
+    if ([window isKindOfClass:NSClassFromString(@"_SCNSnapshotWindow")])
+        return WindowKind::InProcessSnapshotting;
+    return WindowKind::Normal;
</ins><span class="cx"> }
</span><ins>+
+}
</ins></span></pre></div>
<a id="trunkSourceWebKitUIProcessDrawingAreaProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h (282188 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h 2021-09-09 01:47:36 UTC (rev 282188)
+++ trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h    2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -84,6 +84,7 @@
</span><span class="cx">     virtual void colorSpaceDidChange() { }
</span><span class="cx">     virtual void minimumSizeForAutoLayoutDidChange() { }
</span><span class="cx">     virtual void sizeToContentAutoSizeMaximumSizeDidChange() { }
</span><ins>+    virtual void windowKindDidChange() { }
</ins><span class="cx"> 
</span><span class="cx">     virtual void adjustTransientZoom(double, WebCore::FloatPoint) { }
</span><span class="cx">     virtual void commitTransientZoom(double, WebCore::FloatPoint) { }
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessPageClienth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/PageClient.h (282188 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/PageClient.h       2021-09-09 01:47:36 UTC (rev 282188)
+++ trunk/Source/WebKit/UIProcess/PageClient.h  2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include "WebDataListSuggestionsDropdown.h"
</span><span class="cx"> #include "WebDateTimePicker.h"
</span><span class="cx"> #include "WebPopupMenuProxy.h"
</span><ins>+#include "WindowKind.h"
</ins><span class="cx"> #include <WebCore/ActivityState.h>
</span><span class="cx"> #include <WebCore/AlternativeTextClient.h>
</span><span class="cx"> #include <WebCore/ContactInfo.h>
</span><span class="lines">@@ -245,6 +246,8 @@
</span><span class="cx">     // Return the layer hosting mode for the view.
</span><span class="cx">     virtual LayerHostingMode viewLayerHostingMode() { return LayerHostingMode::InProcess; }
</span><span class="cx"> 
</span><ins>+    virtual WindowKind windowKind() { return isViewInWindow() ? WindowKind::Normal : WindowKind::Unparented; }
+
</ins><span class="cx">     virtual void processDidExit() = 0;
</span><span class="cx">     virtual void processWillSwap() { processDidExit(); }
</span><span class="cx">     virtual void didRelaunchProcess() = 0;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessRemoteLayerTreeRemoteLayerTreeDrawingAreaProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h (282188 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h  2021-09-09 01:47:36 UTC (rev 282188)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h     2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -61,16 +61,17 @@
</span><span class="cx">     CALayer *layerWithIDForTesting(uint64_t) const;
</span><span class="cx"> 
</span><span class="cx"> private:
</span><del>-    void sizeDidChange() override;
-    void deviceScaleFactorDidChange() override;
-    void didUpdateGeometry() override;
</del><ins>+    void sizeDidChange() final;
+    void deviceScaleFactorDidChange() final;
+    void windowKindDidChange() final;
+    void didUpdateGeometry() final;
</ins><span class="cx">     
</span><span class="cx">     // For now, all callbacks are called before committing changes, because that's what the only client requires.
</span><span class="cx">     // Once we have other callbacks, it may make sense to have a before-commit/after-commit option.
</span><del>-    void dispatchAfterEnsuringDrawing(WTF::Function<void (CallbackBase::Error)>&&) override;
</del><ins>+    void dispatchAfterEnsuringDrawing(WTF::Function<void (CallbackBase::Error)>&&) final;
</ins><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><del>-    void didChangeViewExposedRect() override;
</del><ins>+    void didChangeViewExposedRect() final;
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(IOS_FAMILY)
</span><span class="lines">@@ -78,15 +79,15 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     float indicatorScale(WebCore::IntSize contentsSize) const;
</span><del>-    void updateDebugIndicator() override;
</del><ins>+    void updateDebugIndicator() final;
</ins><span class="cx">     void updateDebugIndicator(WebCore::IntSize contentsSize, bool rootLayerChanged, float scale, const WebCore::IntPoint& scrollPosition);
</span><span class="cx">     void updateDebugIndicatorPosition();
</span><span class="cx">     void initializeDebugIndicator();
</span><span class="cx"> 
</span><del>-    void waitForDidUpdateActivityState(ActivityStateChangeID) override;
-    void hideContentUntilPendingUpdate() override;
-    void hideContentUntilAnyUpdate() override;
-    bool hasVisibleContent() const override;
</del><ins>+    void waitForDidUpdateActivityState(ActivityStateChangeID) final;
+    void hideContentUntilPendingUpdate() final;
+    void hideContentUntilAnyUpdate() final;
+    bool hasVisibleContent() const final;
</ins><span class="cx"> 
</span><span class="cx">     void prepareForAppSuspension() final;
</span><span class="cx">     
</span><span class="lines">@@ -93,7 +94,7 @@
</span><span class="cx">     WebCore::FloatPoint indicatorLocation() const;
</span><span class="cx"> 
</span><span class="cx">     // IPC::MessageReceiver
</span><del>-    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
</del><ins>+    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
</ins><span class="cx"> 
</span><span class="cx">     // Message handlers
</span><span class="cx">     void setPreferredFramesPerSecond(WebCore::FramesPerSecond);
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessRemoteLayerTreeRemoteLayerTreeDrawingAreaProxymm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm (282188 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm 2021-09-09 01:47:36 UTC (rev 282188)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm    2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -507,4 +507,10 @@
</span><span class="cx">     return m_remoteLayerTreeHost->layerWithIDForTesting(layerID);
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void RemoteLayerTreeDrawingAreaProxy::windowKindDidChange()
+{
+    if (m_webPageProxy.windowKind() == WindowKind::InProcessSnapshotting)
+        m_remoteLayerTreeHost->mapAllIOSurfaceBackingStore();
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessRemoteLayerTreeRemoteLayerTreeHosth"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h (282188 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h      2021-09-09 01:47:36 UTC (rev 282188)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h 2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -81,6 +81,8 @@
</span><span class="cx"> 
</span><span class="cx">     void layerWillBeRemoved(WebCore::GraphicsLayer::PlatformLayerID);
</span><span class="cx"> 
</span><ins>+    RemoteLayerBackingStore::LayerContentsType layerContentsType() const;
+
</ins><span class="cx">     RemoteLayerTreeDrawingAreaProxy* m_drawingArea { nullptr };
</span><span class="cx">     RemoteLayerTreeNode* m_rootNode { nullptr };
</span><span class="cx">     HashMap<WebCore::GraphicsLayer::PlatformLayerID, std::unique_ptr<RemoteLayerTreeNode>> m_nodes;
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessRemoteLayerTreeRemoteLayerTreeHostmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm (282188 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm     2021-09-09 01:47:36 UTC (rev 282188)
+++ trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm        2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -64,6 +64,24 @@
</span><span class="cx">     clearLayers();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+RemoteLayerBackingStore::LayerContentsType RemoteLayerTreeHost::layerContentsType() const
+{
+#if PLATFORM(MAC) || PLATFORM(MACCATALYST)
+    // CAMachPort currently does not work on macOS (or macCatalyst): rdar://problem/31247730
+    return RemoteLayerBackingStore::LayerContentsType::IOSurface;
+#else
+    // If a surface will be referenced by multiple layers (as in the tile debug indicator), CAMachPort cannot be used.
+    if (m_drawingArea->hasDebugIndicator())
+        return RemoteLayerBackingStore::LayerContentsType::IOSurface;
+
+    // If e.g. SceneKit will be doing an in-process snapshot of the layer tree, CAMachPort cannot be used: rdar://problem/47481972
+    if (m_drawingArea->page().windowKind() == WindowKind::InProcessSnapshotting)
+        return RemoteLayerBackingStore::LayerContentsType::IOSurface;
+
+    return RemoteLayerBackingStore::LayerContentsType::CAMachPort;
+#endif
+}
+
</ins><span class="cx"> bool RemoteLayerTreeHost::updateLayerTree(const RemoteLayerTreeTransaction& transaction, float indicatorScaleFactor)
</span><span class="cx"> {
</span><span class="cx">     if (!m_drawingArea)
</span><span class="lines">@@ -89,13 +107,7 @@
</span><span class="cx">     };
</span><span class="cx">     Vector<LayerAndClone> clonesToUpdate;
</span><span class="cx"> 
</span><del>-#if PLATFORM(MAC) || PLATFORM(MACCATALYST)
-    // Can't use the iOS code on macOS yet: rdar://problem/31247730
-    auto layerContentsType = RemoteLayerBackingStore::LayerContentsType::IOSurface;
-#else
-    auto layerContentsType = m_drawingArea->hasDebugIndicator() ? RemoteLayerBackingStore::LayerContentsType::IOSurface : RemoteLayerBackingStore::LayerContentsType::CAMachPort;
-#endif
-    
</del><ins>+    auto layerContentsType = this->layerContentsType();
</ins><span class="cx">     for (auto& [layerID, propertiesPointer] : transaction.changedLayerProperties()) {
</span><span class="cx">         const RemoteLayerTreeTransaction::LayerProperties& properties = *propertiesPointer;
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (282188 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp   2021-09-09 01:47:36 UTC (rev 282188)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp      2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -10576,6 +10576,13 @@
</span><span class="cx">             continue;
</span><span class="cx">         observer.value->webViewDidMoveToWindow();
</span><span class="cx">     }
</span><ins>+
+    auto newWindowKind = pageClient().windowKind();
+    if (m_windowKind != newWindowKind) {
+        m_windowKind = newWindowKind;
+        if (m_drawingArea)
+            m_drawingArea->windowKindDidChange();    
+    }
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void WebPageProxy::setCanShowPlaceholder(const WebCore::ElementContext& context, bool canShowPlaceholder)
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWebPageProxyh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (282188 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WebPageProxy.h     2021-09-09 01:47:36 UTC (rev 282188)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h        2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -79,6 +79,7 @@
</span><span class="cx"> #include "WebPreferences.h"
</span><span class="cx"> #include "WebUndoStepID.h"
</span><span class="cx"> #include "WebsitePoliciesData.h"
</span><ins>+#include "WindowKind.h"
</ins><span class="cx"> #include <WebCore/ActivityState.h>
</span><span class="cx"> #include <WebCore/AutoplayEvent.h>
</span><span class="cx"> #include <WebCore/Color.h>
</span><span class="lines">@@ -729,6 +730,8 @@
</span><span class="cx">     bool isViewFocused() const { return m_activityState.contains(WebCore::ActivityState::IsFocused); }
</span><span class="cx">     bool isViewWindowActive() const { return m_activityState.contains(WebCore::ActivityState::WindowIsActive); }
</span><span class="cx"> 
</span><ins>+    WindowKind windowKind() const { return m_windowKind; };
+
</ins><span class="cx">     void addMIMETypeWithCustomContentProvider(const String& mimeType);
</span><span class="cx"> 
</span><span class="cx">     void selectAll();
</span><span class="lines">@@ -3098,6 +3101,8 @@
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     bool m_needsSiteSpecificViewportQuirks { true };
</span><ins>+
+    WindowKind m_windowKind { WindowKind::Unparented };
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> #ifdef __OBJC__
</span></span></pre></div>
<a id="trunkSourceWebKitUIProcessWindowKindh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebKit/UIProcess/WindowKind.h (0 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/UIProcess/WindowKind.h                               (rev 0)
+++ trunk/Source/WebKit/UIProcess/WindowKind.h  2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -0,0 +1,36 @@
</span><ins>+/*
+ * Copyright (C) 2021 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+namespace WebKit {
+
+enum class WindowKind : uint8_t {
+    Unparented,
+    Normal,
+    InProcessSnapshotting,
+};
+
+} // namespace WebKit
</ins></span></pre></div>
<a id="trunkSourceWebKitWebKitxcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (282188 => 282189)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj     2021-09-09 01:47:36 UTC (rev 282188)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj        2021-09-09 02:46:01 UTC (rev 282189)
</span><span class="lines">@@ -3465,6 +3465,7 @@
</span><span class="cx">          2D8786221BDB58FF00D02ABB /* APIUserStyleSheet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIUserStyleSheet.h; sourceTree = "<group>"; };
</span><span class="cx">          2D8949EE182044F600E898AA /* PlatformCALayerRemoteTiledBacking.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformCALayerRemoteTiledBacking.cpp; sourceTree = "<group>"; };
</span><span class="cx">          2D8949EF182044F600E898AA /* PlatformCALayerRemoteTiledBacking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerRemoteTiledBacking.h; sourceTree = "<group>"; };
</span><ins>+               2D922D8A26E990FC00EC1A59 /* WindowKind.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WindowKind.h; sourceTree = "<group>"; };
</ins><span class="cx">           2D9CD5EB21FA503F0029ACFA /* TextCheckingControllerProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = TextCheckingControllerProxy.messages.in; sourceTree = "<group>"; };
</span><span class="cx">          2D9CD5EC21FA503F0029ACFA /* TextCheckingControllerProxy.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextCheckingControllerProxy.mm; sourceTree = "<group>"; };
</span><span class="cx">          2D9CD5ED21FA503F0029ACFA /* TextCheckingControllerProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextCheckingControllerProxy.h; sourceTree = "<group>"; };
</span><span class="lines">@@ -10289,6 +10290,7 @@
</span><span class="cx">                          51E8B68D1E712873001B7132 /* WebURLSchemeTask.cpp */,
</span><span class="cx">                          51D124271E6D3F1F002B2820 /* WebURLSchemeTask.h */,
</span><span class="cx">                          572FD44122265CE200A1ECC3 /* WebViewDidMoveToWindowObserver.h */,
</span><ins>+                               2D922D8A26E990FC00EC1A59 /* WindowKind.h */,
</ins><span class="cx">                   );
</span><span class="cx">                  path = UIProcess;
</span><span class="cx">                  sourceTree = "<group>";
</span></span></pre>
</div>
</div>

</body>
</html>