Bug 172023

Summary: Add UIClient callback for when picture-in-picture is activated.
Product: WebKit Reporter: Jeremy Jones <jeremyj-wk>
Component: WebKit2Assignee: Jeremy Jones <jeremyj-wk>
Status: REOPENED ---    
Severity: Normal CC: buildbot, commit-queue, jlewis3, ryanhaddad, simon.fraser, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on: 172121    
Bug Blocks: 172048    
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews115 for mac-elcapitan
none
Patch
none
Patch none

Description Jeremy Jones 2017-05-12 01:17:15 PDT
Add UIClient callback for when picture-in-picture is activated.
Comment 1 Jeremy Jones 2017-05-12 01:28:00 PDT
Created attachment 309882 [details]
Patch
Comment 2 Jeremy Jones 2017-05-12 01:28:34 PDT
rdar://problem/30882102
Comment 3 Build Bot 2017-05-12 02:50:49 PDT
Comment on attachment 309882 [details]
Patch

Attachment 309882 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/3724924

New failing tests:
fast/dom/Window/querySelectorAll-with-pseudo-elements.html
Comment 4 Build Bot 2017-05-12 02:50:51 PDT
Created attachment 309886 [details]
Archive of layout-test-results from ews115 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews115  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 5 Jeremy Jones 2017-05-12 10:37:38 PDT
Created attachment 309913 [details]
Patch
Comment 6 Simon Fraser (smfr) 2017-05-12 10:47:13 PDT
Comment on attachment 309913 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=309913&action=review

> Source/WebKit2/UIProcess/API/APIUIClient.h:82
> +    virtual void setPictureInPictureActive(WebKit::WebPageProxy*, bool) { }

I think "active" is too vague here. It could be taken to mean that the PIP window was brought to the front. Maybe setIsShowingPictureInPicture or something?
Comment 7 Jeremy Jones 2017-05-12 11:29:25 PDT
Created attachment 309920 [details]
Patch
Comment 8 Jeremy Jones 2017-05-12 11:35:27 PDT
(In reply to Simon Fraser (smfr) from comment #6)
> Comment on attachment 309913 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=309913&action=review
> 
> > Source/WebKit2/UIProcess/API/APIUIClient.h:82
> > +    virtual void setPictureInPictureActive(WebKit::WebPageProxy*, bool) { }
> 
> I think "active" is too vague here. It could be taken to mean that the PIP
> window was brought to the front. Maybe setIsShowingPictureInPicture or
> something?

OK. setHasVideoInPictureInPicture
Comment 9 Simon Fraser (smfr) 2017-05-12 11:44:08 PDT
Comment on attachment 309920 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=309920&action=review

> Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:373
> +    m_page->uiClient().setHasVideoInPictureInPicture(m_page, videoFullscreenMode & MediaPlayerEnums::VideoFullscreenModePictureInPicture);

Do we always want to call the UI client, even when the PiP mode doesn't change?

> Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:502
> +    m_page->uiClient().setHasVideoInPictureInPicture(m_page, mode & MediaPlayerEnums::VideoFullscreenModePictureInPicture);

Ditto.

> Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PictureInPictureDelegate.mm:131
> +    sleep(1); // Wait for PIPAgent to launch, or it won't call -pipDidClose: callback.

Is 1 second always enough, even on loaded bots?
Comment 10 Jeremy Jones 2017-05-12 13:20:58 PDT
Comment on attachment 309920 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=309920&action=review

>> Source/WebKit2/UIProcess/Cocoa/WebVideoFullscreenManagerProxy.mm:373
>> +    m_page->uiClient().setHasVideoInPictureInPicture(m_page, videoFullscreenMode & MediaPlayerEnums::VideoFullscreenModePictureInPicture);
> 
> Do we always want to call the UI client, even when the PiP mode doesn't change?

With semantics of a setter, it s fine. And that prevents us from having to cache the value here.

>> Tools/TestWebKitAPI/Tests/WebKit2Cocoa/PictureInPictureDelegate.mm:131
>> +    sleep(1); // Wait for PIPAgent to launch, or it won't call -pipDidClose: callback.
> 
> Is 1 second always enough, even on loaded bots?

Unknown. It has worked consistently in my testing.
Comment 11 WebKit Commit Bot 2017-05-12 13:49:30 PDT
Comment on attachment 309920 [details]
Patch

Clearing flags on attachment: 309920

Committed r216791: <http://trac.webkit.org/changeset/216791>
Comment 12 WebKit Commit Bot 2017-05-12 13:49:31 PDT
All reviewed patches have been landed.  Closing bug.
Comment 13 Ryan Haddad 2017-05-13 17:23:53 PDT
(In reply to WebKit Commit Bot from comment #11)
> Comment on attachment 309920 [details]
> Patch
> 
> Clearing flags on attachment: 309920
> 
> Committed r216791: <http://trac.webkit.org/changeset/216791>

The API test added with this change has been timing out on El Capitan since it was added:

PictureInPicture.WKPageUIClient

https://build.webkit.org/builders/Apple%20El%20Capitan%20Release%20WK1%20%28Tests%29/builds/1610
Comment 14 WebKit Commit Bot 2017-05-15 09:29:04 PDT
Re-opened since this is blocked by bug 172121