Bug 167132 - Pass down website autoplay policies to media elements
Summary: Pass down website autoplay policies to media elements
Status: RESOLVED DUPLICATE of bug 167355
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 167354
Blocks:
  Show dependency treegraph
 
Reported: 2017-01-17 12:51 PST by Matt Rajca
Modified: 2017-01-24 13:12 PST (History)
4 users (show)

See Also:


Attachments
Patch (1.85 KB, patch)
2017-01-17 13:13 PST, Matt Rajca
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-elcapitan (714.46 KB, application/zip)
2017-01-17 14:13 PST, Build Bot
no flags Details
Patch (11.22 KB, patch)
2017-01-17 15:26 PST, Matt Rajca
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews102 for mac-elcapitan (717.37 KB, application/zip)
2017-01-17 17:00 PST, Build Bot
no flags Details
Patch (11.00 KB, patch)
2017-01-19 13:39 PST, Matt Rajca
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews125 for ios-simulator-wk2 (9.38 MB, application/zip)
2017-01-19 14:55 PST, Build Bot
no flags Details
Patch (10.88 KB, patch)
2017-01-19 15:06 PST, Matt Rajca
no flags Details | Formatted Diff | Diff
Patch (10.91 KB, patch)
2017-01-19 16:12 PST, Matt Rajca
no flags Details | Formatted Diff | Diff
Patch (10.81 KB, patch)
2017-01-23 12:26 PST, Matt Rajca
no flags Details | Formatted Diff | Diff
Patch (10.90 KB, patch)
2017-01-23 13:39 PST, Matt Rajca
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Matt Rajca 2017-01-17 12:51:08 PST
Website autoplay policies passed to the web frame loader should be respected by media elements.
Comment 1 Matt Rajca 2017-01-17 13:13:59 PST
Created attachment 299054 [details]
Patch
Comment 2 Build Bot 2017-01-17 14:13:20 PST
Comment on attachment 299054 [details]
Patch

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

New failing tests:
imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-protocol-setter-non-broken.html
Comment 3 Build Bot 2017-01-17 14:13:22 PST
Created attachment 299059 [details]
Archive of layout-test-results from ews102 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 4 Matt Rajca 2017-01-17 15:26:00 PST
Created attachment 299073 [details]
Patch
Comment 5 Matt Rajca 2017-01-17 15:26:46 PST
(In reply to comment #4)
> Created attachment 299073 [details]
> Patch

I don't think that bot failure is related. That test was added just a few hours ago.
Comment 6 Build Bot 2017-01-17 17:00:15 PST
Comment on attachment 299073 [details]
Patch

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

New failing tests:
imported/w3c/web-platform-tests/html/browsers/history/the-location-interface/location-protocol-setter-non-broken.html
Comment 7 Build Bot 2017-01-17 17:00:18 PST
Created attachment 299087 [details]
Archive of layout-test-results from ews102 for mac-elcapitan

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-elcapitan  Platform: Mac OS X 10.11.6
Comment 8 Matt Rajca 2017-01-17 19:40:13 PST
Working on a new patch with tests that also run on iOS.
Comment 9 Alex Christensen 2017-01-18 09:48:43 PST
Comment on attachment 299073 [details]
Patch

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

> Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:821
> +    if (coreFrame && !websitePolicies.autoplayEnabled) {

I don't think we need to check coreFrame.  It was dereferenced on line 804, so if it were null we would have already crashed.

> Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:824
> +        settings.setVideoPlaybackRequiresUserGesture(true);
> +        settings.setAudioPlaybackRequiresUserGesture(true);

Are these values set back to their default value for the next navigation?  Add a test that sets autoplayEnabled back to true and does another navigation to make sure that it behaves as expected.

> Tools/TestWebKitAPI/Tests/WebKit2/autoplayCheck.html:12
> +                }, 100)

Is 100ms enough time for the video to have always started playing when it is allowed to?
Comment 10 Matt Rajca 2017-01-19 13:38:25 PST
(In reply to comment #9)
> Comment on attachment 299073 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=299073&action=review
> 
> > Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:821
> > +    if (coreFrame && !websitePolicies.autoplayEnabled) {
> 
> I don't think we need to check coreFrame.  It was dereferenced on line 804,
> so if it were null we would have already crashed.

Removed.

> 
> > Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:824
> > +        settings.setVideoPlaybackRequiresUserGesture(true);
> > +        settings.setAudioPlaybackRequiresUserGesture(true);
> 
> Are these values set back to their default value for the next navigation? 
> Add a test that sets autoplayEnabled back to true and does another
> navigation to make sure that it behaves as expected.

Good catch. I polished this up and added a test.

> 
> > Tools/TestWebKitAPI/Tests/WebKit2/autoplayCheck.html:12
> > +                }, 100)
> 
> Is 100ms enough time for the video to have always started playing when it is
> allowed to?

It should be, given the video file is around 100 KB and loaded locally.
Comment 11 Matt Rajca 2017-01-19 13:39:47 PST
Created attachment 299267 [details]
Patch
Comment 12 Build Bot 2017-01-19 14:55:19 PST
Comment on attachment 299267 [details]
Patch

Attachment 299267 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: http://webkit-queues.webkit.org/results/2916574

New failing tests:
media/ios/autoplay-only-in-main-document.html
Comment 13 Build Bot 2017-01-19 14:55:23 PST
Created attachment 299272 [details]
Archive of layout-test-results from ews125 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews125  Port: ios-simulator-wk2  Platform: Mac OS X 10.11.6
Comment 14 Matt Rajca 2017-01-19 15:06:11 PST
Created attachment 299275 [details]
Patch
Comment 15 Matt Rajca 2017-01-19 16:12:50 PST
Created attachment 299278 [details]
Patch
Comment 16 Alex Christensen 2017-01-23 11:46:36 PST
Comment on attachment 299278 [details]
Patch

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

> Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:821
> +    coreFrame->settings().setAudioPlaybackRequiresUserGesture(!websitePolicies.autoplayEnabled);

This overrides the existing settings.setAudioPlaybackRequiresUserGesture.  We should remove that if it no longer works.
Comment 17 WebKit Commit Bot 2017-01-23 12:13:08 PST
Comment on attachment 299278 [details]
Patch

Rejecting attachment 299278 [details] from commit-queue.

Failed to run "['/Volumes/Data/EWS/WebKit/Tools/Scripts/webkit-patch', '--status-host=webkit-queues.webkit.org', '--bot-id=webkit-cq-01', 'build', '--no-clean', '--no-update', '--build-style=release', '--port=mac']" exit_code: 2 cwd: /Volumes/Data/EWS/WebKit

Last 500 characters of output:
TestWebKitAPI/Tests/WebKit2/ForceRepaint.cpp -o /Volumes/Data/EWS/WebKit/WebKitBuild/TestWebKitAPI.build/Release/TestWebKitAPILibrary.build/Objects-normal/x86_64/ForceRepaint.o

** BUILD FAILED **


The following build commands failed:
	CompileC /Volumes/Data/EWS/WebKit/WebKitBuild/TestWebKitAPI.build/Release/TestWebKitAPILibrary.build/Objects-normal/x86_64/WebsitePolicies.o Tests/WebKit2Cocoa/WebsitePolicies.mm normal x86_64 objective-c++ com.apple.compilers.llvm.clang.1_0.compiler
(1 failure)

Full output: http://webkit-queues.webkit.org/results/2936483
Comment 18 Matt Rajca 2017-01-23 12:26:37 PST
Created attachment 299532 [details]
Patch
Comment 19 Matt Rajca 2017-01-23 13:39:59 PST
Created attachment 299537 [details]
Patch
Comment 20 WebKit Commit Bot 2017-01-23 14:27:17 PST
Comment on attachment 299537 [details]
Patch

Clearing flags on attachment: 299537

Committed r211062: <http://trac.webkit.org/changeset/211062>
Comment 21 WebKit Commit Bot 2017-01-23 14:27:22 PST
All reviewed patches have been landed.  Closing bug.
Comment 22 Ryan Haddad 2017-01-23 15:09:32 PST
This change appears to have caused 4 API test failures:

Tests that failed:
  RequiresUserActionForPlaybackTest.DeprecatedRequiresUserActionForAudioAndVideoPlayback
  RequiresUserActionForPlaybackTest.DeprecatedRequiresUserActionForAudioButNotVideoPlayback
  RequiresUserActionForPlaybackTest.RequiresUserActionForAudioAndVideoPlayback
  RequiresUserActionForPlaybackTest.RequiresUserActionForAudioButNotVideoPlayback

https://build.webkit.org/builders/Apple%20Sierra%20Release%20WK1%20(Tests)/builds/3030
Comment 23 Matt Rajca 2017-01-23 15:33:32 PST
(In reply to comment #22)
> This change appears to have caused 4 API test failures:
> 
> Tests that failed:
>  
> RequiresUserActionForPlaybackTest.
> DeprecatedRequiresUserActionForAudioAndVideoPlayback
>  
> RequiresUserActionForPlaybackTest.
> DeprecatedRequiresUserActionForAudioButNotVideoPlayback
>  
> RequiresUserActionForPlaybackTest.RequiresUserActionForAudioAndVideoPlayback
>  
> RequiresUserActionForPlaybackTest.
> RequiresUserActionForAudioButNotVideoPlayback
> 
> https://build.webkit.org/builders/Apple%20Sierra%20Release%20WK1%20(Tests)/
> builds/3030

A follow-up patch that addresses these is almost ready.
Comment 24 Matt Rajca 2017-01-23 17:42:52 PST
https://bugs.webkit.org/show_bug.cgi?id=167346 is tracking a fix. Just waiting for one other patch to land on the commit queue. Thanks for the heads up!
Comment 25 WebKit Commit Bot 2017-01-23 18:19:07 PST
Re-opened since this is blocked by bug 167354
Comment 26 Matt Rajca 2017-01-24 13:12:49 PST
Take 2 of this work has landed with regressions fixed: https://bugs.webkit.org/show_bug.cgi?id=167355

*** This bug has been marked as a duplicate of bug 167355 ***