New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 718647 link

Starred by 1 user

Issue metadata

Status: Fixed
Owner:
Closed: Jan 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 713394



Sign in to add a comment

<source> within <video> makes play() promise never throw error

Project Member Reported by crouleau@chromium.org, May 4 2017

Issue description

Repro instructions:

Use one of these two html layouts:

html version 1:
<video controls preload='none' src="tulip2.mp4"></video>

html version 2:
<video controls preload='none'>
  <source src="tulip2.mp4" type="video/mp4" />
</video>


Run this javascript in devtools:

vid = document.getElementsByTagName('video')[0]
vid.play().then(function () {
      console.log('played!');
}).catch(function(error) {
      console.log('did not play.');
      console.log(error);
});

If, for example, the tulip2.mp4 file is just an empty file instead of a real mp4, then for html version 1 an error will be thrown "DOMException: Failed to load because no supported source was found." for html version 2 no error will be thrown and the promise will simply never return.

This was reported here https://plus.google.com/101269094069807548838/posts/isvhk7amEZx a year ago.

This is one example of the general problem that play() does not reliably let me know whether or not it worked.
 
Cc: -mlamo...@google.com mlamouri@chromium.org
Cc: sande...@chromium.org
Cc: timvolod...@chromium.org
I believe it's a bug in the Promise play() implementation.

Caleb, what other unreliability did you have in mind? If promise resolved, play() worked, if it threw an exception, it didn't.
Oftentimes the promise never gets resolved either way. For example, if I pass a path to a media file that doesn't exist. I get an error in that case, but the promise doesn't get resolved.
(The error doesn't occur in the "catch" of the promise.)
Cc: -timvolod...@chromium.org foolip@chromium.org
Components: -Internals>Media Blink>Media
-timvolodine@ +foolip@

My understanding is that the issue is WAI as when <source> is used, we are running the resource selection algorithm [1] in the "children" mode which will wait for another <source>. I'm pretty sure there was another bug open about this but I can't find it.

foolip@, is my understanding correct?

[1] https://html.spec.whatwg.org/multipage/embedded-content.html#concept-media-load-algorithm
Yeah, unfortunately this isn't really possible to solve without deciding to stop waiting for source elements at some arbitrary point. This was mentioned in https://github.com/whatwg/html/pull/509#issuecomment-177914176 but I think we might have discussed it on crbug somewhere as well.
Perhaps you could provide guidance to a web developer who wants to figure out

1. Did the video start playing successfully? (boolean)
2. If it failed, why did it fail? (Error text string)

How can a web developer figure out both 1 and 2 and then use that data for future decisions in the code? For example, 

A. Is there a way to check to see whether the resource selection algorithm is waiting? 
B. Is there a way to figure out that there was a network error in loading one of the sources?
Cc: jmedley@chromium.org
+ tech writer jmedley@

If we could figure out how to do these things, we could update https://developers.google.com/web/updates/2016/03/play-returns-promise to help developers.
This makes no sense.
Why would anybody assume what calling play() before sources are present would work?

Cc: -jmedley@chromium.org
Owner: jmedley@chromium.org
Status: Assigned (was: Available)
Okay, after some discussion in Kirkland, it seems like this is true:

1. For <video src="video.format"\>, 
the promise works as expected and explained in the blog post. (One caveat is that if "video.format" does not exist on the server, you get the unhelpful "Failed to load because no supported source was found." error instead of a more helpful error.)

2. For <video><source src="video.format" type='blah/blah'></video>
the promise only works for the gesture requirement. It does not work to check, as the blog post suggested where "Automatic playback failed."

It would be helpful to explain this somehow in the blog post so that developers aren't confused.

jmedley@, would you be able to take this on? otherwise feel free to take yourself out of this bug.
Cc: fbeaufort@chromium.org
Thanks for the ping! I'll make sure our doc is updated and will let you know when it's live.
Cc: jmedley@chromium.org
Owner: fbeaufort@chromium.org
Pull Request is available at https://github.com/google/WebFundamentals/pull/5697

Sign in to add a comment