Bug 86113 - Replace WebMediaPlayer::bytesLoaded() with an explicit didLoadingProgress()
Summary: Replace WebMediaPlayer::bytesLoaded() with an explicit didLoadingProgress()
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Ami Fischman
URL:
Keywords:
Depends on: 88007
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-10 10:46 PDT by Ami Fischman
Modified: 2012-06-04 13:41 PDT (History)
14 users (show)

See Also:


Attachments
Patch (26.07 KB, patch)
2012-05-31 00:36 PDT, Ami Fischman
no flags Details | Formatted Diff | Diff
Patch (26.05 KB, patch)
2012-05-31 00:55 PDT, Ami Fischman
no flags Details | Formatted Diff | Diff
Patch (26.22 KB, patch)
2012-05-31 09:07 PDT, Ami Fischman
no flags Details | Formatted Diff | Diff
Patch (26.19 KB, patch)
2012-05-31 09:26 PDT, Ami Fischman
eric.carlson: review+
webkit.review.bot: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ami Fischman 2012-05-10 10:46:09 PDT
Today WebMediaPlayer::bytesLoaded() is used only to detect loading progress happening (in HTMLMediaElement::changeNetworkStateFromLoadingToIdle()).  Instead, WebMediaPlayer could expose a
bool didLoadingProgress();
method that returned whether loading progress happened since the last time this function was called.  This would allow simplifying WMP implementations that don't otherwise need to track counts of bytes buffered.

(I hear scherkus/eric.carlson/acolwell discussed this f2f; feel free to add color to this bug if there's more to it that I missed)
Comment 1 Andrew Scherkus 2012-05-10 10:56:52 PDT
Yeah the idea was to let ports have more choice in deciding what the definition of "progress" is.

There are a few options:
  1) Monitor changes in buffered() TimeRanges (would this be sufficient?)
  2) Ask ports for a loading percentage (a more abstract version of what we have today)
  3) Ask ports a "did you progress since the last time I asked you?" method (what you propose here)

While (3) is a bit more complex I believe the added flexibility is warranted here. Monitoring changes in buffered() as well as a load percentage assumes that the underlying port is actually buffering. For example, what would a port report in (1) and (2) if it was an infinite live stream?
Comment 2 Philippe Normand 2012-05-10 11:23:56 PDT
bytesLoaded() is also used in HTMLMediaElement::progressEventTimerFired() BTW.

Anyway yes, this change proposed by Ami seems like a good approach to me.
Comment 3 Ami Fischman 2012-05-31 00:36:45 PDT
Created attachment 145005 [details]
Patch
Comment 4 WebKit Review Bot 2012-05-31 00:39:28 PDT
Please wait for approval from abarth@webkit.org, dglazkov@chromium.org, fishd@chromium.org, jamesr@chromium.org or tkent@chromium.org before submitting, as this patch contains changes to the Chromium public API. See also https://trac.webkit.org/wiki/ChromiumWebKitAPI.
Comment 5 Early Warning System Bot 2012-05-31 00:44:02 PDT
Comment on attachment 145005 [details]
Patch

Attachment 145005 [details] did not pass qt-ews (qt):
Output: http://queues.webkit.org/results/12866126
Comment 6 Early Warning System Bot 2012-05-31 00:46:41 PDT
Comment on attachment 145005 [details]
Patch

Attachment 145005 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/12861204
Comment 7 Build Bot 2012-05-31 00:53:40 PDT
Comment on attachment 145005 [details]
Patch

Attachment 145005 [details] did not pass mac-ews (mac):
Output: http://queues.webkit.org/results/12868135
Comment 8 Ami Fischman 2012-05-31 00:55:10 PDT
Created attachment 145010 [details]
Patch
Comment 9 Eric Carlson 2012-05-31 08:05:30 PDT
Comment on attachment 145010 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=145010&action=review

> Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:374
> +    unsigned currentMaxTimeLoaded = maxTimeLoaded();

"unsigned"? Do you really only want to report loading progress once every second?

> Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:375
> +    bool ret = currentMaxTimeLoaded != m_maxTimeLoadedAtLastDidLoadingProgress;

"ret"? Be bold, use a few more letters and spell out the name of the variable ;-)
Comment 10 Ami Fischman 2012-05-31 09:07:28 PDT
Created attachment 145099 [details]
Patch
Comment 11 Ami Fischman 2012-05-31 09:08:44 PDT
Comment on attachment 145010 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=145010&action=review

>> Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:374
>> +    unsigned currentMaxTimeLoaded = maxTimeLoaded();
> 
> "unsigned"? Do you really only want to report loading progress once every second?

Nope; that was a bug.  Fixed.

>> Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:375
>> +    bool ret = currentMaxTimeLoaded != m_maxTimeLoadedAtLastDidLoadingProgress;
> 
> "ret"? Be bold, use a few more letters and spell out the name of the variable ;-)

On your head be it when the Character Availability Crisis of 2012 hits webkit-dev worldwide!
Comment 12 Eric Carlson 2012-05-31 09:21:49 PDT
Comment on attachment 145099 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=145099&action=review

This looks correct to me. Not marking r+ pending review by abarth, dglazkov, fishd, jamesr, or tkent.

> Source/WebCore/html/HTMLMediaElement.cpp:1850
> +    } else {
> +        if (timedelta > 3.0 && !m_sentStalledEvent) {

Nit: this could be made into an "else if ( ... ) { "
Comment 13 Eric Carlson 2012-05-31 09:22:30 PDT
(In reply to comment #11)
> (From update of attachment 145010 [details])
> >> Source/WebCore/platform/graphics/avfoundation/MediaPlayerPrivateAVFoundation.cpp:375
> >> +    bool ret = currentMaxTimeLoaded != m_maxTimeLoadedAtLastDidLoadingProgress;
> > 
> > "ret"? Be bold, use a few more letters and spell out the name of the variable ;-)
> 
> On your head be it when the Character Availability Crisis of 2012 hits webkit-dev worldwide!

Oh dear, now I am in for it!
Comment 14 Ami Fischman 2012-05-31 09:26:12 PDT
Comment on attachment 145099 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=145099&action=review

>> Source/WebCore/html/HTMLMediaElement.cpp:1850
>> +        if (timedelta > 3.0 && !m_sentStalledEvent) {
> 
> Nit: this could be made into an "else if ( ... ) { "

Done.
Comment 15 Ami Fischman 2012-05-31 09:26:36 PDT
Created attachment 145104 [details]
Patch
Comment 16 Dimitri Glazkov (Google) 2012-05-31 09:29:59 PDT
Comment on attachment 145104 [details]
Patch

Chromium WebKit API changes LGTM.
Comment 17 WebKit Review Bot 2012-05-31 11:00:17 PDT
Comment on attachment 145104 [details]
Patch

Rejecting attachment 145104 [details] from commit-queue.

Failed to run "['/mnt/git/webkit-commit-queue/Tools/Scripts/webkit-patch', '--status-host=queues.webkit.org', '-..." exit_code: 2

Last 500 characters of output:
webkit-commit-queue/Source/WebKit/chromium/webkit --revision 139747 --non-interactive --force --accept theirs-conflict --ignore-externals' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium'
48>At revision 139747.

________ running '/usr/bin/python tools/clang/scripts/update.py --mac-only' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium'

________ running '/usr/bin/python gyp_webkit' in '/mnt/git/webkit-commit-queue/Source/WebKit/chromium'
Updating webkit projects from gyp files...

Full output: http://queues.webkit.org/results/12866281
Comment 18 Ami Fischman 2012-05-31 11:03:38 PDT
Committed r119125: <http://trac.webkit.org/changeset/119125>
Comment 19 WebKit Review Bot 2012-05-31 14:06:49 PDT
Re-opened since this is blocked by 88007