Skip to content

Commit

Permalink
REGRESSION(260575@main): YouTube videos sometimes do not resize prope…
Browse files Browse the repository at this point in the history
…rly in fullscreen and theater modes

https://bugs.webkit.org/show_bug.cgi?id=260025
rdar://112780721

Reviewed by Mike Wyrzykowski.

WebAVPlayerLayer needs to know its video's dimensions in order to properly lay out its sublayers.
When video dimensions change, VideoFullscreenManagerProxy caches the dimensions in its
VideoFullscreenModelContext, updates the WebAVPlayerLayer with the new dimensions, and calls
-setNeedsLayout on the layer to trigger a re-layout of its sublayers. However, in rare cases, video
dimensions can change before the WebAVPlayerLayer is created. While VideoFullscreenModelContext
would cache the dimensions, the WebAVPlayerLayer would not be told about these cached dimensions
when it was created, leading it to believe the video had dimensions of 0x0 during -layoutSublayers.

Fixed this by setting VideoFullscreenModelContext's cached video dimensions on the WebAVPlayerLayer
at creation time to ensure it always lays out with the most recent video dimensions sent to it from
the WebContent process.

No new tests as I couldn't determine a way to capture the necessary timing in a test.

* Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.h:
* Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm:
(WebKit::VideoFullscreenModelContext::setPlayerLayer):

Canonical link: https://commits.webkit.org/266807@main
  • Loading branch information
aestes committed Aug 11, 2023
1 parent 3985bf0 commit e1c50af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class VideoFullscreenModelContext final
void setLayerHostView(RetainPtr<PlatformView>&& layerHostView) { m_layerHostView = WTFMove(layerHostView); }

WebAVPlayerLayer *playerLayer() const { return m_playerLayer.get(); }
void setPlayerLayer(RetainPtr<WebAVPlayerLayer>&& playerLayer) { m_playerLayer = WTFMove(playerLayer); }
void setPlayerLayer(RetainPtr<WebAVPlayerLayer>&&);

#if PLATFORM(IOS_FAMILY)
WebAVPlayerLayerView *playerView() const { return m_playerView.get(); }
Expand Down
6 changes: 6 additions & 0 deletions Source/WebKit/UIProcess/Cocoa/VideoFullscreenManagerProxy.mm
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ - (BOOL)prefersStatusBarHidden
m_clients.remove(&client);
}

void VideoFullscreenModelContext::setPlayerLayer(RetainPtr<WebAVPlayerLayer>&& playerLayer)
{
m_playerLayer = WTFMove(playerLayer);
[m_playerLayer setVideoDimensions:m_videoDimensions];
}

void VideoFullscreenModelContext::setVideoDimensions(const WebCore::FloatSize& videoDimensions)
{
if (m_videoDimensions == videoDimensions)
Expand Down

0 comments on commit e1c50af

Please sign in to comment.