[webkit-changes] [WebKit/WebKit] 95f954: [Cocoa] Video doesn't resize on YouTube.com in the...

Jer Noble noreply at github.com
Mon May 8 16:27:14 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 95f95436a7cdf8752aaa4e411c35ca32cd921c0e
      https://github.com/WebKit/WebKit/commit/95f95436a7cdf8752aaa4e411c35ca32cd921c0e
  Author: Jer Noble <jer.noble at apple.com>
  Date:   2023-05-08 (Mon, 08 May 2023)

  Changed paths:
    M Source/WebCore/platform/cocoa/VideoFullscreenModel.h
    M Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h
    M Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm
    M Source/WebCore/platform/cocoa/WebAVPlayerLayer.h
    M Source/WebCore/platform/cocoa/WebAVPlayerLayer.mm
    M Source/WebCore/platform/cocoa/WebAVPlayerLayerView.mm
    M Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm
    M Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm
    M Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h
    M Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm

  Log Message:
  -----------
  [Cocoa] Video doesn't resize on YouTube.com in theater mode
https://bugs.webkit.org/show_bug.cgi?id=256473
rdar://105929105

Reviewed by Simon Fraser.

A rare timing issue will sometimes cause WebAVPlayerLayer to get "stuck" thinking it has an empty
videoDimensions. This seems to occur when layerCreationProperies are initialized in the WebContent
process before the video element has a valid nativeSize, but the video element's "resize" event
is fired before the layer is created in the UI process.

One cause of this symptom is that not all the relevant objects are notified when the videoDimensions
change in the UI process. The VideoFullscreenModelContext object has a videoDimensions() method whose
instance variable is never modified. And notifying the relevent objects becomes a job of the
VideoFullscreenManagerProxy itself, and that coverage was spotty.

Instead, fully implement VideoFullscreenModelContext::setVideoDimensions() and use the pre-existing
VideoFullscreenModelClient callbacks to notify both the VideoFullscreenInterface{Mac,AVKit} and the
WebAVPlayerLayer when the underlying video dimensions change.

WebAVPlayerLayer will therefore need a VideoFullscreenModelClient proxy object to use as the client
for the model, and since the only thing it uses a VideoFullscreenInteraface object for is to get its
associated model, it should just keep a weak reference to the model itself. Adding the model to the
WebAVPlayerLayer will cause its videoDimensions property to update. And when the videoDimensions
change, it can mark itself as needing layout.

Drive-by fix: In WebAVPlayerLayer, the -layoutSublayers method would bail out early if its own
affineTransform property was identity. This was incorrect, it should have checked it's videoSublayer's
affineTransform property, as that's what is actually changed later in the method. Also, don't
disable animations in the -layoutSublayers method, as this will cause animated property changes
to break (such as PiP animations on iOS).

* Source/WebCore/platform/cocoa/VideoFullscreenModel.h:
(WebCore::VideoFullscreenModel::logIdentifier const):
(WebCore::VideoFullscreenModel::loggerPtr const):
* Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.h:
* Source/WebCore/platform/cocoa/VideoFullscreenModelVideoElement.mm:
(WebCore::VideoFullscreenModelVideoElement::logIdentifier const):
(WebCore::VideoFullscreenModelVideoElement::logIdentifier): Deleted.
* Source/WebCore/platform/cocoa/WebAVPlayerLayer.h:
* Source/WebCore/platform/cocoa/WebAVPlayerLayer.mm:
(WebCore::WebAVPlayerLayerFullscreenModelClient::WebAVPlayerLayerFullscreenModelClient):
(WebCore::WebAVPlayerLayerFullscreenModelClient::videoDimensionsChanged):
(-[WebAVPlayerLayer init]):
(-[WebAVPlayerLayer fullscreenModel]):
(-[WebAVPlayerLayer setFullscreenModel:]):
(-[WebAVPlayerLayer videoDimensions]):
(-[WebAVPlayerLayer setVideoDimensions:]):
(-[WebAVPlayerLayer layoutSublayers]):
(-[WebAVPlayerLayer resolveBounds]):
(-[WebAVPlayerLayer setVideoGravity:]):
(-[WebAVPlayerLayer logIdentifier]):
(-[WebAVPlayerLayer loggerPtr]):
(-[WebAVPlayerLayer fullscreenInterface]): Deleted.
(-[WebAVPlayerLayer setFullscreenInterface:]): Deleted.
* Source/WebCore/platform/cocoa/WebAVPlayerLayerView.mm:
(WebCore::WebAVPlayerLayerView_startRoutingVideoToPictureInPicturePlayerLayerView):
* Source/WebCore/platform/ios/VideoFullscreenInterfaceAVKit.mm:
(VideoFullscreenInterfaceAVKit::doSetup):
* Source/WebCore/platform/mac/VideoFullscreenInterfaceMac.mm:
(-[WebVideoFullscreenInterfaceMacObjC setUpPIPForVideoView:withFrame:inWindow:]):
(WebCore::boolString): Deleted.
* Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
* Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
(WebKit::VideoFullscreenModelContext::setVideoDimensions):
(WebKit::VideoFullscreenManagerProxy::createLayerWithID):
(WebKit::VideoFullscreenManagerProxy::createViewWithID):
(WebKit::VideoFullscreenManagerProxy::setVideoDimensions):

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




More information about the webkit-changes mailing list