WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
223125
document pictureInPictureElement is null if you Enter Picture in Picture from contextual menu
https://bugs.webkit.org/show_bug.cgi?id=223125
Summary
document pictureInPictureElement is null if you Enter Picture in Picture from...
Jeff Johnson
Reported
2021-03-12 09:25:33 PST
Overview: If you enter PiP using the contextual menu item "Enter Picture in Picture", then document.pictureInPictureElement is null. Whereas document.pictureInPictureElement returns the <video> element if you enter PiP using the widget at the top left corner of the video. Steps to Reproduce: 1) Open
https://developer.apple.com/videos/play/wwdc2020/102/
2) Start playing the video 3) Open contextual menu on the video and select "Enter Picture in Picture" 4) Show JavaScript Console 5) document.pictureInPictureElement Expected Results: <video id="video"... Actual Results: null Additional Builds and Platforms: This also happens in Safari 14.0.3 on macOS 10.14.6. And it happens with the latest Safari Technology Preview 122 on macOS 11.
Attachments
Patch
(3.19 KB, patch)
2021-03-15 22:30 PDT
,
Peng Liu
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Jeff Johnson
Comment 1
2021-03-12 10:37:51 PST
I also just discovered that the video enterpictureinpicture event doesn't get posted when you using the contextual menu. The enterpictureinpicture does get posted when you use the PiP widget.
Jeff Johnson
Comment 2
2021-03-14 07:37:16 PDT
I debugged with the WebKit source code and discovered the problem. In the case of clicking the PiP widget it follows this code path: HTMLVideoElementPictureInPicture::requestPictureInPicture HTMLVideoElement::setPresentationMode HTMLMediaElement::enterFullscreen In the case of the contextual menu it follows this code path: HitTestResult::toggleEnhancedFullscreenForVideo HTMLMediaElement::enterFullscreen In both cases, eventually this code gets called at
https://github.com/WebKit/WebKit/blob/main/Source/WebCore/html/HTMLVideoElement.cpp#L504
void HTMLVideoElement::didEnterFullscreenOrPictureInPicture(const FloatSize& size) { if (m_enteringPictureInPicture) { However, m_enteringPictureInPicture is false with the contextual menu. With the PiP widget m_enteringPictureInPicture is true, because it gets set to true in HTMLVideoElement::setPresentationMode at
https://github.com/WebKit/WebKit/blob/main/Source/WebCore/html/HTMLVideoElement.cpp#L490
Peng Liu
Comment 3
2021-03-15 22:20:51 PDT
Thanks for the investigation! I will upload a patch to fix it.
Peng Liu
Comment 4
2021-03-15 22:30:52 PDT
Created
attachment 423299
[details]
Patch
EWS
Comment 5
2021-03-16 21:22:10 PDT
Committed
r274551
: <
https://commits.webkit.org/r274551
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 423299
[details]
.
Radar WebKit Bug Importer
Comment 6
2021-03-16 21:23:16 PDT
<
rdar://problem/75510164
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug