Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebTorrent: Autoplay is sometimes blocked if media metadata is not ready yet #5471

Closed
feross opened this issue Jul 31, 2019 · 11 comments · Fixed by brave/brave-core#3052
Closed

Comments

@feross
Copy link

feross commented Jul 31, 2019

Description

If the media element does not have metadata available immediately when the media viewer loads, then autoplay will fail with a DOMException.

Steps to Reproduce

  1. Load the torrent from https://ia802608.us.archive.org/18/items/gd1975-06-17.aud.unknown.87560.flac16/gd1975-06-17.aud.unknown.87560.flac16_archive.torrent
  2. Start the download.
  3. Scroll to the bottom of the file list and select the last MP3 file in the list (file number 111). (This is so that the file data is not likely to be downloaded by webtorrent yet.)
  4. The file should eventually start playing. There should be no warning that autoplay was blocked.

Actual result:

Media sometimes does not autoplay.

Expected result:

Media should always autoplay.

Reproduces how often:

Intermittent issue

Brave version (brave://version info)

master

@feross feross added QA/Yes QA/Test-Plan-Specified feature/webtorrent Label for webtorrent related issues labels Jul 31, 2019
@feross feross self-assigned this Jul 31, 2019
@feross feross added the bug label Jul 31, 2019
feross added a commit to brave/brave-core that referenced this issue Jul 31, 2019
Fix: brave/brave-browser#5471

If the media element does not have metadata available immediately when the media viewer loads, then autoplay will fail with a `DOMException`.

So, we now wait for the metadata to be loaded before calling `play()`.
@yrliou yrliou added this to the 0.70.x - Nightly milestone Jul 31, 2019
@kjozwiak
Copy link
Member

@feross looks like this is still happening here and there. It takes a few tries to reproduce on a new profile, but you'll eventually run into the following:

Screen Shot 2019-09-19 at 10 19 24 PM

Used the following build:

Brave 0.69.128 Chromium: 77.0.3865.75 (Official Build) (64-bit)
Revision 201e747d032611c5f2785cae06e894cf85be7f8a-refs/branch-heads/3865@{#776}
OS macOS Version 10.14.6 (Build 18G95)

I couldn't reproduce the above using https://webtorrent.io/torrents/wired-cd.torrent though. Maybe it's based on timing? I was running through the case pretty quickly. We can definitely label this as verified as it's a big improvement compared the previous behaviouor. @feross thoughts?

@feross
Copy link
Author

feross commented Sep 20, 2019

Yeah, I noticed this as well. The fix felt a little hacky, but it now works like 95% of the time, which is better than 0%. I wish there was some easy way to just disable autoplay policy for the WebTorrent extension. I wonder if @yrliou has any ideas how to do this or who to ask.

@rebron
Copy link
Collaborator

rebron commented Sep 20, 2019

@darkdh suggestions for this one?

@darkdh
Copy link
Member

darkdh commented Sep 20, 2019

We have autoplay whitelist (https://github.com/brave/autoplay-whitelist) but it only support url host right now (https://github.com/brave/autoplay-whitelist/blob/master/data/autoplay.json)
Maybe we can make it support extension id like webtorrent's case
chrome-extension://lgjmpdmojkpocjcopdikifhejkkjglho/extension/brave_webtorrent.html?https://webtorrent.io/torrents/wired-cd.torrent

@darkdh
Copy link
Member

darkdh commented Sep 20, 2019

For example, I added webtorrent to autoplay content setting like this
Screen Shot 2019-09-19 at 20 40 08
Screen Shot 2019-09-19 at 20 40 56
This allows any media from webtorrent to autoplay.

@kjozwiak
Copy link
Member

I can confirm that adding chrome-extension://lgjmpdmojkpocjcopdikifhejkkjglho/ into the auto play content settings fixes what I ran into #5471 (comment). Couldn't reproduce the issue after several attempts.

@kjozwiak
Copy link
Member

@rebron @darkdh should we create a new issue for adding the ability to add extensions into the autoplay whitelist? We can continue verifying this one as it works ~95% of the time and can address the issue in more detail in another GH. Thoughts?

@feross
Copy link
Author

feross commented Sep 20, 2019

should we create a new issue for adding the ability to add extensions into the autoplay whitelist?

Didn't you say that you were already able to add the WebTorrent extension URL into the whitelist? So shouldn't the issue actually be to add WebTorrent to the list by default?

@darkdh
Copy link
Member

darkdh commented Sep 20, 2019

The thing we added above is "Content Setting", the brave autoplay list is beyond that.
Every time autoplay permission request coming, we check brave autoplay whitelist first and then check content setting if host doesn't match anything in the whitelist

@feross
Copy link
Author

feross commented Sep 20, 2019

@darkdh Thanks for explaining the distinction. Makes sense!

@btlechowski
Copy link

btlechowski commented Sep 27, 2019

Verification passed on

Brave 0.69.129 Chromium: 77.0.3865.90 (Official Build) (64-bit)
Revision 58c425ba843df2918d9d4b409331972646c393dd-refs/branch-heads/3865@{#830}
OS Ubuntu 18.04 LTS

The issue still reproduces. Logged #6195.
image

Verification PASSED on macOS 10.14.6 x64 using the following build:

Brave 0.69.129 Chromium: 77.0.3865.90 (Official Build) (64-bit)
Revision 58c425ba843df2918d9d4b409331972646c393dd-refs/branch-heads/3865@{#830}
OS macOS Version 10.14.6 (Build 18G95)

Verification passed on

Brave 0.69.130 Chromium: 77.0.3865.90 (Official Build) (64-bit)
Revision 58c425ba843df2918d9d4b409331972646c393dd-refs/branch-heads/3865@{#830}
OS Windows 10 OS Version 1803 (Build 17134.1006)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment