Skip to content

Commit

Permalink
[visionOS] Attempting to fullscreen a portrait video on twitter.com d…
Browse files Browse the repository at this point in the history
…isplays the feed

https://bugs.webkit.org/show_bug.cgi?id=270958
rdar://124180748

Reviewed by Abrar Rahman Protyasha.

Fullscreen video on visionOS is intended to be presented at the aspect ratio of
the video element. However, twitter.com tears down its video player if the
fullscreen window has a portrait size, when the original window has a landscape
size. This results in the video disappearing in fullscreen, leaving behind the
feed.

Add a quirk to disable the aspect-ratio based fullscreen window sizing behavior
for twitter.com.

This issue was not caught earlier due to a crash when entering fullscreen on
twitter.com (fixed in 273885@main), and an issue with fullscreen event
ordering (fixed in 275115@main) that resulted in the same bug happening for
*all* videos on twitter.com. Additionally, the issue was temporarily hidden
until a recent regression which accidentally disabled the aspect ratio based
sizing behavior was fixed by 276059@main.

* Source/WebCore/page/Quirks.cpp:
(WebCore::Quirks::shouldDisableFullscreenVideoAspectRatioAdaptiveSizing const):
* Source/WebCore/page/Quirks.h:
* Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp:
(WebKit::WebFullScreenManager::enterFullScreenForElement):

Canonical link: https://commits.webkit.org/276121@main
  • Loading branch information
pxlcoder committed Mar 14, 2024
1 parent c326bc3 commit 12aecd5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
11 changes: 11 additions & 0 deletions Source/WebCore/page/Quirks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,17 @@ bool Quirks::allowLayeredFullscreenVideos() const
}
#endif

#if PLATFORM(VISION)
// twitter.com: rdar://124180748
bool Quirks::shouldDisableFullscreenVideoAspectRatioAdaptiveSizing() const
{
if (!needsQuirks())
return false;

return isDomain("twitter.com"_s);
}
#endif

bool Quirks::shouldEnableApplicationCacheQuirk() const
{
// FIXME: Remove this when deleting ApplicationCache APIs.
Expand Down
4 changes: 4 additions & 0 deletions Source/WebCore/page/Quirks.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ class Quirks {
bool shouldEnableFontLoadingAPIQuirk() const;
bool needsVideoShouldMaintainAspectRatioQuirk() const;

#if PLATFORM(VISION)
WEBCORE_EXPORT bool shouldDisableFullscreenVideoAspectRatioAdaptiveSizing() const;
#endif

bool shouldDisableLazyIframeLoadingQuirk() const;

bool shouldDisableFetchMetadata() const;
Expand Down
12 changes: 10 additions & 2 deletions Source/WebKit/WebProcess/FullScreen/WebFullScreenManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,17 @@ void WebFullScreenManager::enterFullScreenForElement(WebCore::Element* element,

#if PLATFORM(VISION)
if (m_mainVideoElement) {
bool fullscreenElementIsVideoElement = is<HTMLVideoElement>(element);

auto mainVideoElementSize = [&]() -> FloatSize {
if (!fullscreenElementIsVideoElement && element->document().quirks().shouldDisableFullscreenVideoAspectRatioAdaptiveSizing())
return { };
return FloatSize(m_mainVideoElement->videoWidth(), m_mainVideoElement->videoHeight());
}();

mediaDetails = {
is<HTMLVideoElement>(element) ? FullScreenMediaDetails::Type::Video : FullScreenMediaDetails::Type::ElementWithVideo,
FloatSize(m_mainVideoElement->videoWidth(), m_mainVideoElement->videoHeight())
fullscreenElementIsVideoElement ? FullScreenMediaDetails::Type::Video : FullScreenMediaDetails::Type::ElementWithVideo,
mainVideoElementSize
};
}
#endif
Expand Down

0 comments on commit 12aecd5

Please sign in to comment.