⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 282189 in webkit


Ignore:
Timestamp:
Sep 8, 2021, 7:46:01 PM (5 years ago)
Author:
timothy_horton@apple.com
Message:

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.

Location:
trunk/Source/WebKit
Files:
1 added
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r282177 r282189  
     12021-09-08  Tim Horton  <timothy_horton@apple.com>
     2
     3        WKWebView specific bug: WKWebView as the contents of a SceneKit/ARKit node doesn't work (UIWebView works)
     4        https://bugs.webkit.org/show_bug.cgi?id=203060
     5        <rdar://problem/82899923>
     6
     7        Reviewed by Dean Jackson.
     8
     9        SceneKit's snapshotter cannot handle CAMachPort-as-layer-contents.
     10
     11        If we get parented in a SceneKit snapshotting window, map all existing
     12        surfaces, and prefer using actual IOSurfaces instead of CAMachPort from then on.
     13
     14        * UIProcess/Cocoa/PageClientImplCocoa.h:
     15        * UIProcess/Cocoa/PageClientImplCocoa.mm:
     16        (WebKit::PageClientImplCocoa::windowKind):
     17        * UIProcess/WebPageProxy.cpp:
     18        (WebKit::WebPageProxy::webViewDidMoveToWindow):
     19        * UIProcess/WebPageProxy.h:
     20        * UIProcess/WindowKind.h: Added.
     21        Keep track of the kind of window we're currently in (the only special
     22        case at the moment is the SceneKit snapshotting window, but you could
     23        easily imagine us caring about others).
     24
     25        * UIProcess/DrawingAreaProxy.h:
     26        (WebKit::DrawingAreaProxy::windowKindDidChange):
     27        * UIProcess/PageClient.h:
     28        (WebKit::PageClient::windowKind):
     29        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h:
     30        * UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm:
     31        (WebKit::RemoteLayerTreeDrawingAreaProxy::windowKindDidChange):
     32        Map CAMachPorts to IOSurfaces when we move into a SceneKit snapshotting window.
     33
     34        * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h:
     35        * UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm:
     36        (WebKit::RemoteLayerTreeHost::layerContentsType const):
     37        (WebKit::RemoteLayerTreeHost::updateLayerTree):
     38        Prefer IOSurface if we're already in a SceneKit snapshotting window.
     39        Also factor this code out and improve the comments.
     40
    1412021-09-08  Fujii Hironori  <Hironori.Fujii@sony.com>
    242
  • trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.h

    r277505 r282189  
    8888    void cameraCaptureChanged() final;
    8989
     90    WindowKind windowKind() final;
     91
    9092protected:
    9193    WeakObjCPtr<WKWebView> m_webView;
  • trunk/Source/WebKit/UIProcess/Cocoa/PageClientImplCocoa.mm

    r277505 r282189  
    194194}
    195195
    196 }
     196WindowKind PageClientImplCocoa::windowKind()
     197{
     198    auto window = [m_webView window];
     199    if (!window)
     200        return WindowKind::Unparented;
     201    if ([window isKindOfClass:NSClassFromString(@"_SCNSnapshotWindow")])
     202        return WindowKind::InProcessSnapshotting;
     203    return WindowKind::Normal;
     204}
     205
     206}
  • trunk/Source/WebKit/UIProcess/DrawingAreaProxy.h

    r278253 r282189  
    8585    virtual void minimumSizeForAutoLayoutDidChange() { }
    8686    virtual void sizeToContentAutoSizeMaximumSizeDidChange() { }
     87    virtual void windowKindDidChange() { }
    8788
    8889    virtual void adjustTransientZoom(double, WebCore::FloatPoint) { }
  • trunk/Source/WebKit/UIProcess/PageClient.h

    r281279 r282189  
    3737#include "WebDateTimePicker.h"
    3838#include "WebPopupMenuProxy.h"
     39#include "WindowKind.h"
    3940#include <WebCore/ActivityState.h>
    4041#include <WebCore/AlternativeTextClient.h>
    … …  
    245246    // Return the layer hosting mode for the view.
    246247    virtual LayerHostingMode viewLayerHostingMode() { return LayerHostingMode::InProcess; }
     248
     249    virtual WindowKind windowKind() { return isViewInWindow() ? WindowKind::Normal : WindowKind::Unparented; }
    247250
    248251    virtual void processDidExit() = 0;
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.h

    r278799 r282189  
    6262
    6363private:
    64     void sizeDidChange() override;
    65     void deviceScaleFactorDidChange() override;
    66     void didUpdateGeometry() override;
     64    void sizeDidChange() final;
     65    void deviceScaleFactorDidChange() final;
     66    void windowKindDidChange() final;
     67    void didUpdateGeometry() final;
    6768   
    6869    // For now, all callbacks are called before committing changes, because that's what the only client requires.
    6970    // Once we have other callbacks, it may make sense to have a before-commit/after-commit option.
    70     void dispatchAfterEnsuringDrawing(WTF::Function<void (CallbackBase::Error)>&&) override;
     71    void dispatchAfterEnsuringDrawing(WTF::Function<void (CallbackBase::Error)>&&) final;
    7172
    7273#if PLATFORM(MAC)
    73     void didChangeViewExposedRect() override;
     74    void didChangeViewExposedRect() final;
    7475#endif
    7576
    … …  
    7980
    8081    float indicatorScale(WebCore::IntSize contentsSize) const;
    81     void updateDebugIndicator() override;
     82    void updateDebugIndicator() final;
    8283    void updateDebugIndicator(WebCore::IntSize contentsSize, bool rootLayerChanged, float scale, const WebCore::IntPoint& scrollPosition);
    8384    void updateDebugIndicatorPosition();
    8485    void initializeDebugIndicator();
    8586
    86     void waitForDidUpdateActivityState(ActivityStateChangeID) override;
    87     void hideContentUntilPendingUpdate() override;
    88     void hideContentUntilAnyUpdate() override;
    89     bool hasVisibleContent() const override;
     87    void waitForDidUpdateActivityState(ActivityStateChangeID) final;
     88    void hideContentUntilPendingUpdate() final;
     89    void hideContentUntilAnyUpdate() final;
     90    bool hasVisibleContent() const final;
    9091
    9192    void prepareForAppSuspension() final;
    … …  
    9495
    9596    // IPC::MessageReceiver
    96     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
     97    void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
    9798
    9899    // Message handlers
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeDrawingAreaProxy.mm

    r278799 r282189  
    508508}
    509509
     510void RemoteLayerTreeDrawingAreaProxy::windowKindDidChange()
     511{
     512    if (m_webPageProxy.windowKind() == WindowKind::InProcessSnapshotting)
     513        m_remoteLayerTreeHost->mapAllIOSurfaceBackingStore();
     514}
     515
    510516} // namespace WebKit
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.h

    r266342 r282189  
    8282    void layerWillBeRemoved(WebCore::GraphicsLayer::PlatformLayerID);
    8383
     84    RemoteLayerBackingStore::LayerContentsType layerContentsType() const;
     85
    8486    RemoteLayerTreeDrawingAreaProxy* m_drawingArea { nullptr };
    8587    RemoteLayerTreeNode* m_rootNode { nullptr };
  • trunk/Source/WebKit/UIProcess/RemoteLayerTree/RemoteLayerTreeHost.mm

    r278799 r282189  
    6565}
    6666
     67RemoteLayerBackingStore::LayerContentsType RemoteLayerTreeHost::layerContentsType() const
     68{
     69#if PLATFORM(MAC) || PLATFORM(MACCATALYST)
     70    // CAMachPort currently does not work on macOS (or macCatalyst): rdar://problem/31247730
     71    return RemoteLayerBackingStore::LayerContentsType::IOSurface;
     72#else
     73    // If a surface will be referenced by multiple layers (as in the tile debug indicator), CAMachPort cannot be used.
     74    if (m_drawingArea->hasDebugIndicator())
     75        return RemoteLayerBackingStore::LayerContentsType::IOSurface;
     76
     77    // If e.g. SceneKit will be doing an in-process snapshot of the layer tree, CAMachPort cannot be used: rdar://problem/47481972
     78    if (m_drawingArea->page().windowKind() == WindowKind::InProcessSnapshotting)
     79        return RemoteLayerBackingStore::LayerContentsType::IOSurface;
     80
     81    return RemoteLayerBackingStore::LayerContentsType::CAMachPort;
     82#endif
     83}
     84
    6785bool RemoteLayerTreeHost::updateLayerTree(const RemoteLayerTreeTransaction& transaction, float indicatorScaleFactor)
    6886{
    … …  
    90108    Vector<LayerAndClone> clonesToUpdate;
    91109
    92 #if PLATFORM(MAC) || PLATFORM(MACCATALYST)
    93     // Can't use the iOS code on macOS yet: rdar://problem/31247730
    94     auto layerContentsType = RemoteLayerBackingStore::LayerContentsType::IOSurface;
    95 #else
    96     auto layerContentsType = m_drawingArea->hasDebugIndicator() ? RemoteLayerBackingStore::LayerContentsType::IOSurface : RemoteLayerBackingStore::LayerContentsType::CAMachPort;
    97 #endif
    98    
     110    auto layerContentsType = this->layerContentsType();
    99111    for (auto& [layerID, propertiesPointer] : transaction.changedLayerProperties()) {
    100112        const RemoteLayerTreeTransaction::LayerProperties& properties = *propertiesPointer;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r281964 r282189  
    1057710577        observer.value->webViewDidMoveToWindow();
    1057810578    }
     10579
     10580    auto newWindowKind = pageClient().windowKind();
     10581    if (m_windowKind != newWindowKind) {
     10582        m_windowKind = newWindowKind;
     10583        if (m_drawingArea)
     10584            m_drawingArea->windowKindDidChange();   
     10585    }
    1057910586}
    1058010587
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r281964 r282189  
    8080#include "WebUndoStepID.h"
    8181#include "WebsitePoliciesData.h"
     82#include "WindowKind.h"
    8283#include <WebCore/ActivityState.h>
    8384#include <WebCore/AutoplayEvent.h>
    … …  
    729730    bool isViewFocused() const { return m_activityState.contains(WebCore::ActivityState::IsFocused); }
    730731    bool isViewWindowActive() const { return m_activityState.contains(WebCore::ActivityState::WindowIsActive); }
     732
     733    WindowKind windowKind() const { return m_windowKind; };
    731734
    732735    void addMIMETypeWithCustomContentProvider(const String& mimeType);
    … …  
    30993102
    31003103    bool m_needsSiteSpecificViewportQuirks { true };
     3104
     3105    WindowKind m_windowKind { WindowKind::Unparented };
    31013106};
    31023107
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r282130 r282189  
    34663466                2D8949EE182044F600E898AA /* PlatformCALayerRemoteTiledBacking.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformCALayerRemoteTiledBacking.cpp; sourceTree = "<group>"; };
    34673467                2D8949EF182044F600E898AA /* PlatformCALayerRemoteTiledBacking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformCALayerRemoteTiledBacking.h; sourceTree = "<group>"; };
     3468                2D922D8A26E990FC00EC1A59 /* WindowKind.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WindowKind.h; sourceTree = "<group>"; };
    34683469                2D9CD5EB21FA503F0029ACFA /* TextCheckingControllerProxy.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = TextCheckingControllerProxy.messages.in; sourceTree = "<group>"; };
    34693470                2D9CD5EC21FA503F0029ACFA /* TextCheckingControllerProxy.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextCheckingControllerProxy.mm; sourceTree = "<group>"; };
    … …  
    1029010291                                51D124271E6D3F1F002B2820 /* WebURLSchemeTask.h */,
    1029110292                                572FD44122265CE200A1ECC3 /* WebViewDidMoveToWindowObserver.h */,
     10293                                2D922D8A26E990FC00EC1A59 /* WindowKind.h */,
    1029210294                        );
    1029310295                        path = UIProcess;
Note: See TracChangeset for help on using the changeset viewer.