Skip to content
This repository has been archived by the owner on Nov 6, 2019. It is now read-only.

Disable autoplay policy enforcement in Chrome #552

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jugglinmike
Copy link
Collaborator

Recent changes in the Chrome browser's policy for media "autoplay" [1]
have implications for automated tests. At least 84 tests that were
previously known to pass in automated scenarios now fail with error
messages like:

play() failed because the user didn't interact with the document
first. https://goo.gl/xX8pDD

Extend the invocation of the Chrome browser with a flag which is
purported to disable this feature [2].

[1] https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
[2] https://peter.sh/experiments/chromium-command-line-switches/#no-user-gesture-required


Hi @beaufortfrancois! I'd like to avoid regressing with future releases of Chrome; do you know of a canonical source documenting the --autoplay-policy command-line option?

Listing of the 84 ests effected by policy change

These tests were identified by searching results data for references to
"https://goo.gl/xX8pDD"

  • mediacapture-fromelement/creation.html
  • mediacapture-fromelement/ended.html
  • mediacapture-fromelement/capture.html
  • media-source/mediasource-redundant-seek.html
  • media-source/mediasource-play-then-seek-back.html
  • media-source/mediasource-seek-during-pending-seek.html
  • media-source/mediasource-duration.html
  • media-source/mediasource-play.html
  • media-source/mediasource-seek-beyond-duration.html
  • webaudio/the-audio-api/the-mediaelementaudiosourcenode-interface/mediaElementAudioSourceToScriptProcessorTest.html
  • encrypted-media/drm-mp4-setmediakeys-again-after-resetting-src.https.html
  • encrypted-media/drm-mp4-waiting-for-a-key.https.html
  • encrypted-media/drm-mp4-playback-temporary-encrypted-clear-sources.https.html
  • encrypted-media/drm-mp4-playback-temporary-setMediaKeys-after-update.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-events.https.html
  • encrypted-media/drm-mp4-playback-temporary-clear-encrypted.https.html
  • encrypted-media/drm-mp4-playback-temporary.https.html
  • encrypted-media/drm-mp4-playback-temporary-multikey-sequential.https.html
  • encrypted-media/drm-mp4-playback-temporary-two-videos.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-encrypted-clear-sources.https.html
  • encrypted-media/clearkey-mp4-setmediakeys-again-after-resetting-src.https.html
  • encrypted-media/drm-mp4-setmediakeys-again-after-playback.https.html
  • encrypted-media/drm-mp4-playback-temporary-multikey.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-multikey-sequential.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-waitingforkey.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-multikey.https.html
  • encrypted-media/drm-mp4-playback-temporary-setMediaKeys-after-src.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-setMediaKeys-onencrypted.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-encrypted-clear.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-setMediaKeys-after-src.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-multikey-sequential-readyState.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-multisession.https.html
  • encrypted-media/drm-mp4-playback-temporary-encrypted-clear.https.html
  • encrypted-media/clearkey-mp4-waiting-for-a-key.https.html
  • encrypted-media/drm-mp4-playback-temporary-multikey-sequential-readyState.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-two-videos.https.html
  • encrypted-media/drm-mp4-playback-temporary-setMediaKeys-immediately.https.html
  • encrypted-media/clearkey-mp4-playback-temporary.https.html
  • encrypted-media/drm-mp4-playback-temporary-waitingforkey.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-setMediaKeys-after-update.https.html
  • encrypted-media/drm-mp4-playback-temporary-multisession.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-setMediaKeys-immediately.https.html
  • encrypted-media/clearkey-mp4-setmediakeys-again-after-playback.https.html
  • encrypted-media/drm-mp4-playback-temporary-setMediaKeys-onencrypted.https.html
  • encrypted-media/clearkey-mp4-playback-temporary-clear-encrypted.https.html
  • encrypted-media/drm-mp4-playback-temporary-events.https.html
  • html/semantics/embedded-content/media-elements/ready-states/autoplay.html
  • html/semantics/embedded-content/media-elements/event_pause_noautoplay.html
  • html/semantics/embedded-content/media-elements/audio_loop_base.html
  • html/semantics/embedded-content/media-elements/event_timeupdate_noautoplay.html
  • html/semantics/embedded-content/media-elements/paused_true_during_pause.html
  • html/semantics/embedded-content/media-elements/video_loop_base.html
  • html/semantics/embedded-content/media-elements/event_play_noautoplay.html
  • html/semantics/embedded-content/media-elements/track/track-element/track-cues-sorted-before-dispatch.html
  • html/semantics/embedded-content/media-elements/track/track-element/track-remove-active-cue.html
  • html/semantics/embedded-content/media-elements/track/track-element/track-disabled-addcue.html
  • html/semantics/embedded-content/media-elements/track/track-element/track-disabled.html
  • html/semantics/embedded-content/media-elements/track/track-element/track-cue-negative-duration.html
  • html/semantics/embedded-content/media-elements/track/track-element/track-cues-enter-exit.html
  • html/semantics/embedded-content/media-elements/track/track-element/track-cues-cuechange.html
  • html/semantics/embedded-content/media-elements/track/track-element/track-cue-negative-timestamp-events.html
  • html/semantics/embedded-content/media-elements/track/track-element/track-cues-missed.html
  • html/semantics/embedded-content/media-elements/track/track-element/track-mode.html
  • html/semantics/embedded-content/media-elements/track/track-element/track-remove-insert-ready-state.html
  • html/semantics/embedded-content/media-elements/track/track-element/track-cue-rendering-empty-cue.html
  • html/semantics/embedded-content/media-elements/interfaces/TextTrack/cues.html
  • html/semantics/embedded-content/media-elements/event_playing_noautoplay.html
  • html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document.html
  • html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-move-to-other-document.html
  • html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-remove-from-document-networkState.html
  • html/semantics/embedded-content/media-elements/playing-the-media-resource/pause-move-within-document.html

Recent changes in the Chrome browser's policy for media "autoplay" [1]
have implications for automated tests. At least 84 tests that were
previously known to pass in automated scenarios now fail with error
messages like:

> play() failed because the user didn't interact with the document
> first.  https://goo.gl/xX8pDD

Extend the invocation of the Chrome browser with a flag which is
purported to disable this feature [2].

[1] https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
[2] https://peter.sh/experiments/chromium-command-line-switches/#no-user-gesture-required
@@ -83,7 +83,10 @@ def makeWptRunCommand(properties):
# Chrome to call getUserMedia without failing out.
command.extend([
'--binary-arg=--use-fake-ui-for-media-stream',
'--binary-arg=--use-fake-device-for-media-stream'
'--binary-arg=--use-fake-device-for-media-stream',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I wish we would put these flags in wptrunner directly rather than having special configuration here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. That feature needs a bit more definition before I can implement it, so I've opened gh-10823 to discuss it further.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...which is in another repository, so I'll need a URL:

web-platform-tests/wpt#10823

@beaufortfrancois
Copy link

@mounirlamouri will know for sure what you need there.

'--binary-arg=--use-fake-device-for-media-stream',
# See
# https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
'--binary-arg=--autoplay-policy=no-user-gesture-required'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@zcorpan
Copy link
Member

zcorpan commented May 3, 2018

@mounirlamouri or @foolip are the flags here the same as when tests are run in your infrastructure? Is there some other flag that we're missing (generally, not specifically about these 84 tests)?

@foolip
Copy link
Member

foolip commented May 4, 2018

I'm included to say that rather than disabling the requirement, tests should be adapted to pass the requirement. A bit of work, though, for sure.

@jugglinmike
Copy link
Collaborator Author

There are a few ways to interpret the statement "tests should be adapted to pass the requirement":

  • the test uses standard web APIs to circumvent the policy
  • the test is authored to include metadata which the WPT CLI reacts to by enabling this flag
  • the test uses WPT's testdriver tool to instruct WebDriver to disable the policy (via an as-yet-undefined WebDriver command)
  • the test does not rely on autoplay and instead uses WPT's testdriver tool to trigger playback by simulating user input

Did you have one of these in mind? Or something else?

@foolip
Copy link
Member

foolip commented May 7, 2018

I mean tests using the existing test_driver.click to satisfy the requirement, i.e. the last option, "the test does not rely on autoplay and instead uses WPT's testdriver tool to trigger playback by simulating user input"

@mounirlamouri
Copy link

I think the overhead may not be worth it in most cases. In Chrome, we run all tests without autoplay policy and have a virtual test suite with some tests running with the policy enabled.

@foolip
Copy link
Member

foolip commented May 8, 2018

@mounirlamouri, I can't find where --autoplay-policy=no-user-gesture-required is passed when running LayoutTests, but I do see --autoplay-policy=document-user-activation-required for the virtual test suite you mentioned, so presumably something other than that is the default.

For the two existing command line arguments we have a plan to get rid of them, and IMHO we should prefer WebDriver solutions where they exist because then we need not solve the problem once for every browser. In this case, we'll presumably have to do something for Safari as well.

@kereliuk, WDYT?

@foolip
Copy link
Member

foolip commented May 8, 2018

OK, looks like --autoplay-policy=no-user-gesture-required actually is still the default code-wise, to be flipped after a successful autoplay launch? Details aren't important for this issue, the question is only whether we should pass --autoplay-policy=no-user-gesture-required for wpt.fyi, or change some affected tests.

@zcorpan, you must have written a bunch of these tests originally, do you have some hunch about how long it might take to change them to use test_driver.click, and do you think that's a good idea?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants