Bug 230370

Summary: Add an experimental SceneKit mode to explore <model> and separated layers
Product: WebKit Reporter: Tim Horton <thorton>
Component: New BugsAssignee: Tim Horton <thorton>
Status: NEW ---    
Severity: Normal CC: benjamin, cdumez, cmarcelo, dino, ews-watchlist, sam, simon.fraser, webkit-bug-importer, wenson_hsieh
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
ews-feeder: commit-queue-
Patch
ews-feeder: commit-queue-
Patch thorton: review?, ews-feeder: commit-queue-

Description Tim Horton 2021-09-16 12:52:13 PDT
Add an experimental SceneKit mode to explore <model> and separated layers
Comment 1 Tim Horton 2021-09-16 12:52:36 PDT
Created attachment 438389 [details]
Patch
Comment 2 Tim Horton 2021-09-16 13:04:30 PDT
Created attachment 438390 [details]
Patch
Comment 3 Tim Horton 2021-09-16 14:02:38 PDT
Created attachment 438399 [details]
Patch
Comment 4 Simon Fraser (smfr) 2021-09-16 14:16:41 PDT
Comment on attachment 438390 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=438390&action=review

> Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:3640
> +    _page->preferences().setCSSTransformStyleOptimized3DEnabled(true);
> +    _page->preferences().setModelElementEnabled(true);

A bit weird that setting a SceneKit node has side effects.

> Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:216
> +    RetainPtr<SCNNode> _sceneKitNode;

_sceneKitRootNode?

> Source/WebKit/UIProcess/API/Cocoa/WKWebViewPrivate.h:416
> +// Assign a node that has this view as a material.
> +@property (nonatomic, retain, setter=_setSceneKitNode:) SCNNode *_sceneKitNode;

So does the caller have to set this view as a material or does that happen automatically?

> Source/WebKit/UIProcess/RemoteLayerTree/cocoa/SceneKitHost.h:50
> +    static constexpr uint64_t portalContentsCategory = 2;
> +    static constexpr uint64_t portalMaskCategory = 4;

Magic

> Source/WebKit/UIProcess/RemoteLayerTree/cocoa/SceneKitHost.mm:80
> +SCNNode *SceneKitHost::ensureNodeForLayer(CALayer *layer)

Could this return a RetainPtr<SCNNode> so I don't have to think too hard about ownership?

> Source/WebKit/UIProcess/RemoteLayerTree/cocoa/SceneKitHost.mm:94
> +void SceneKitHost::setCustomChildNodeForLayer(CALayer *layer, SCNNode *node)

Take a RetainPtr<SCNNode>&&?

> Source/WebKit/UIProcess/RemoteLayerTree/cocoa/SceneKitHost.mm:99
> +static SCNNode *customNodeForLayer(CALayer *layer)

Return a RetainPtr<SCNNode>?

> Source/WebKit/UIProcess/RemoteLayerTree/cocoa/SceneKitHost.mm:104
> +static SCNNode *ensurePortalNodeForLayer(CALayer *layer)

Return a RetainPtr<SCNNode>?

> Source/WebKit/UIProcess/RemoteLayerTree/cocoa/SceneKitHost.mm:117
> +void SceneKitHost::updateLayer(CALayer *layer, bool isInPortalSubtree, bool& isPortal)

This looks like it's updating the node for the layer, not updating the layer?

> Source/WebKit/UIProcess/RemoteLayerTree/cocoa/SceneKitHost.mm:130
> +    node.transform = SCNMatrix4Translate(toSCN(layer.transform), position.x - (parentSize.width / 2), -position.y + (parentSize.height / 2), layer.zPosition + zEpsilon);
> +    node.pivot = SCNMatrix4MakeTranslation(-(0.5 - layer.anchorPoint.x) * size.width, (0.5 - layer.anchorPoint.y) * size.height, -layer.anchorPointZ);

I guess at some point we'll have to map animation of transform and transform origin to node animations? How does that work?

> Tools/3DMiniBrowser/3DMiniBrowser/sample.html:39
> +        document.getElementById("flap").style.transform = `translateZ(10px) rotateX(${ 15 * (Math.sin(ts / 300) + 1) }deg)`;

CSS animations??
Comment 5 Radar WebKit Bug Importer 2021-09-23 12:53:23 PDT
<rdar://problem/83461384>