New issue
Advanced search Search tips

Issue 842584 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner: ----
Closed: May 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 1
Type: Bug



Sign in to add a comment

In <media>, setting .currentTime to a value slightly smaller than the duration value increases duration value.

Project Member Reported by agamem...@gmail.com, May 14 2018

Issue description

Windows 10, Chrome 65.0.3325.146 64-bit

(This could be a security risk (i.e.: buffer overflow), perhaps.)

See attached file:
1) Add a canplay event listener to a media element.
2) Media.currentTime = media.duration * .9999
3) Canplay runs
4) Duration is higher than before
5) Rinse and repeat (once or twice)
6) Delete the event listener.

What is the expected result?
media.duration stays THE SAME.

What happens instead?
media.duration gets BIGGER (causes problems with my web-app!)
 
duration_haywire.zip
14.0 MB Download
Status: WontFix (was: Untriaged)
This is expected to happen when there's an unknown duration or if decoding doesn't reach the specified duration. Can you explain why you expect it to remain the same?

Comment 2 by agamem...@gmail.com, May 14 2018

Status: (was: WontFix)
??!!!??

Try it on every other browser.

The duration should stay the same because the duration is exactly 1875.957551 seconds. It should not be any bigger than this!

Comment 3 by agamem...@gmail.com, May 14 2018

Try changing it to" Media.currentTime = media.duration * .99" or "Media.currentTime = media.duration * 1" also.
Status: WontFix
When given an invalid file there's no guarantees on the behavior. As a best effort we update to whatever was possible to decode.

Comment 5 by agamem...@gmail.com, May 14 2018

Status: (was: WontFix)
I don't think you understand me.

1) Invalid file? It is not an invalid file...???

2) You have it backwards... "whatever was possible to decode" means you start with a smaller size and get to the true size, but the true size is 1875.957551 seconds. It goes to a bigger value than this instead which is 1876.188996 seconds. It should not go to 1876.188996 seconds!!!

Comment 6 by agamem...@gmail.com, May 14 2018

3) How do you explain the fact that the result is different between setting currentTime to .9999 of the value and 1.000 of the value?

Comment 7 by agamem...@gmail.com, May 14 2018

4) Behavior shouldn't be different across browsers. canplay is called after setting the currentTime.........

Unless it truly is an "invalid [corrupt] file", I guess, which I don't think it is -- seems fine to me (created with Audacity).
Status: WontFix
Sorry, I misunderstood, you tagged the bug with "(This could be a security risk (i.e.: buffer overflow), perhaps.)". But after looking at it again this isn't an invalid file it's just untagged VBR mp3 which by necessity has a variable duration (since unless we decode the whole file we can't know the true duration). This is similar to  issue 419974  and  776663 .

Either way this is still WontFix per the previous bugs. Adding appropriate tagging with the duration information fixes the issue and improves playback performance (we don't need to scan 1mb+ [max ffmpeg scan size] looking for a non-existing duration tag anymore):

$ ffmpeg -i duration_haywire.mp3 -acodec copy fixed_duration.mp3

Comment 9 by agamem...@gmail.com, May 14 2018

Ah, thanks.

But, Chrome is running this estimate only if the currentTime is set to near-1, but not 1, and Chrome runs multiple canplay events when currentTime changes. Is this what it's supposed to do? Neither Edge nor Firefox do this.
If you let the whole file play out and be cached before seeking, the seeking duration will be correct afterwards. The estimate is just an artifact of not having enough information to determine the duration. We enable fast seek in these files too, so we seek based on estimated position. Otherwise we'd have to load quite a bit of data which is painful on a slow connection.

canplay is supposed to fire on "readyState newly increased to HAVE_FUTURE_DATA or greater." seeks set the readyState to have_metadata, unlike other events on the spec, "canplay" doesn't have "for the first time." So the chrome behavior is per spec. I can't comment on what the intent there is though.

https://html.spec.whatwg.org/multipage/media.html#event-media-canplay

I suspect in Edge and Firefox in a fresh profile on a slow connection playback will take quite some time to start.
Ok, got it. Thanks for your help on this.

Sign in to add a comment