[webkit-changes] [WebKit/WebKit] b42eaa: Fullscreen video size/position is incorrect on You...

Aditya Keerthi noreply at github.com
Tue Apr 18 10:54:51 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: b42eaa63ce43d533c18d3ffc18ef29ef6b8f3ee1
      https://github.com/WebKit/WebKit/commit/b42eaa63ce43d533c18d3ffc18ef29ef6b8f3ee1
  Author: Aditya Keerthi <akeerthi at apple.com>
  Date:   2023-04-18 (Tue, 18 Apr 2023)

  Changed paths:
    M Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm
    M Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h
    M Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm

  Log Message:
  -----------
  Fullscreen video size/position is incorrect on YouTube when minimumEffectiveDeviceWidth is set
https://bugs.webkit.org/show_bug.cgi?id=255556
rdar://101557743

Reviewed by Tim Horton.

Entering fullscreen on youtube.com for a `WKWebView` with a non-zero
`minimumEffectiveDeviceWidth` currently results in portions of the video
becoming clipped, the top of the video being incorrectly offset from the top of
the window.

In fullscreen, YouTube explicitly sets the width/height of the video element to
the `clientWidth`/`clientHeight` of the fullscreen element, inside the
`fullscreenchange` event. The fullscreen element is a wrapper `<div>` containing
the video element, with width/height: 100%.

Currently, the `WKWebView`'s frame is adjusted prior to dispatching the
`fullscreenchange` event, but the `minimumEffectiveDeviceWidth` is not. This
results in the viewport state continuing to incorporate the
`minimumEffectiveDeviceWidth`, which may be larger than the width of the
fullscreen window. The larger size also results in an offset from the top of the
window, as the video element has `object-fit: contain`. The video is smaller
than its element's size, and is vertically centered relative to the larger size.

To fix, ensure `minimumEffectiveDeviceWidth` is unset prior to dispatching the
`fullscreenchange` event. However, simply updating the value in the UI process
prior to dispatching `willEnterFullscreen` is not enough, as the visible content
rect update is asynchronous in both the UI and web processes. This means that
there is no guarantee that the viewport state in the web process will be correct
at the time of `fullscreenchange` event dispatch. To fix the secondary issue,
introduce `-[WKWebView _doAfterNextVisibleContentRectAndPresentationUpdate]` to
ensure the correct viewport state is reflected in the web process prior to
dispatching the `fullscreenchange` event.

* Source/WebKit/UIProcess/API/Cocoa/WKWebView.mm:
(-[WKWebView _doAfterNextVisibleContentRectAndPresentationUpdate:]):
* Source/WebKit/UIProcess/API/Cocoa/WKWebViewInternal.h:

Introduce `_doAfterNextVisibleContentRectAndPresentationUpdate`, used to ensure
ensure that the next visible content rect update is accurately reflected in
the web process, prior to performing the update block.

* Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenWindowControllerIOS.mm:
(-[WKFullScreenWindowController enterFullScreen:]):

Unset `minimumEffectiveDeviceWidth` prior to dispatching the `fullscreenchange`
event, so that the viewport state accurately reflects the size of the fullscreen
window.

The original value is already stored `WKWebViewState`, and is restored on
fullscreen exit.

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




More information about the webkit-changes mailing list