New issue
Advanced search Search tips

Issue 671765 link

Starred by 5 users

Issue metadata

Status: WontFix
Owner:
Closed: Jan 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

Media event 'playing' should be fired when sound/video begin rendering, not when bytes first arrive

Reported by davidswa...@gmail.com, Dec 6 2016

Issue description

UserAgent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36

Steps to reproduce the problem:
1. Create an audio element whose source is a stream
2. Add a callback for the 'isplaying' event that logs a timestamp for when the first bytes arrived and when this event fires.
3. It may be necessary to throttle the stream to make the time difference noticeable

What is the expected behavior?
'isplaying' should fire approximately when sound is first heard through a speaker or video begins playing. Firefox does this.

What went wrong?
'isplaying' fires 270-1100 msec before any sound leaves the speakers.

Did this work before? N/A 

Does this work in other browsers? Yes

Chrome version: 54.0.2840.99  Channel: n/a
OS Version: 10.0
Flash Version: Shockwave Flash 23.0 r0

This seemed related to an already-filed bug, so I reported it as a comment there: https://bugs.chromium.org/p/chromium/issues/detail?id=73609#c77

But I was encouraged there to create a bug on its own.
 
Components: Internals>Media Blink>Media
Summary: Media event 'playing' should be fired when sound/video begin rendering, not when bytes first arrive (was: Media event 'isplaying' should be fired when sound/video begin rendering, not when bytes first arrive)
You mean "playing", not "isplaying".

If you can provide a test case that reproduces the issue (using JSFiddle or similar), that would expedite the fix.
Cc: chcunningham@chromium.org
Repeating my comment from the other bug: "We don't 100% know when audio will leave the speaker. Probably we could make the estimate better, but you'll never get it perfect for the first frame of audio."

Typically the advice for figuring out the true value for this (if you need it as accurate as possible) is a requestAnimationFrame that checks currentTime > 0.

I'm surprised this is fairly accurate in other browsers though.
Labels: M-57
Cc: qin...@chromium.org
 Issue 512019  has been merged into this issue.

Comment 5 by ajha@chromium.org, Dec 16 2016

Labels: TE-NeedsTriageHelp
My read of the spec is that these things aren't required to be perfectly sync'ed. Still, its nice to do better. 

I don't have any simple suggestions but I could imagine ways to estimate. The first time we play audio on a given system we really don't know how long it will take to play out on the speaker. But we could determine this after the first render call (especially now that we have the delay + *delay_timestamp*). We could then save this info (potentially to disk) for the next OnBufferingStateChange(HAVE_ENOUGH) - rather than posting the task as soon as the queue is full, post a delayed task with delay = the average observed delay from previous playbacks. 

Delayed tasks aren't guaranteed to wait a precise time, and there's still the delay of firing the "playing" event once scheduled, but I suspect they do better than the 200 - 1100 msec noted in the report. Buuuut this is pretty elaborate and I'm not sure it would do anybetter than the currentTime check Dale suggested. 

Really, the most accurate playout time can be known via WebAudio. We've almost got a change landed to implement getOutputTimestamp()
https://codereview.chromium.org/2060833002/

See here for example usage
https://webaudio.github.io/web-audio-api/#widl-AudioContext-getOutputTimestamp-AudioTimestamp
Status: Untriaged (was: Unconfirmed)
Cc: -chcunningham@chromium.org
Owner: chcunningham@chromium.org
Status: Assigned (was: Untriaged)
give to chris as per c#6. Chris, it's your call to fix it or not.
Status: WontFix (was: Assigned)
Wontfix as complexity tradeoffs are IMO not worth it. Workarounds from comments 2 and 6 should unblock reporter. Yell if thats not the case. 

Alternatively, yell if anyone has a more clever idea on how to implement. 

Sign in to add a comment