WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 132077
[Mac, iOS] Stop buffering media when on an inactive tab
https://bugs.webkit.org/show_bug.cgi?id=132077
Summary
[Mac, iOS] Stop buffering media when on an inactive tab
Brent Fulgham
Reported
2014-04-23 14:23:56 PDT
We shouldn't waste bandwidth and energy downloading and decoding media if the user isn't playing the media, and has switched to a different tab.
Attachments
Patch
(10.42 KB, patch)
2014-04-23 14:33 PDT
,
Brent Fulgham
no flags
Details
Formatted Diff
Diff
Patch
(11.11 KB, patch)
2014-04-23 16:19 PDT
,
Brent Fulgham
no flags
Details
Formatted Diff
Diff
Patch
(10.82 KB, patch)
2014-04-23 17:10 PDT
,
Brent Fulgham
eric.carlson
: review+
Details
Formatted Diff
Diff
Show Obsolete
(2)
View All
Add attachment
proposed patch, testcase, etc.
Brent Fulgham
Comment 1
2014-04-23 14:24:36 PDT
<
rdar://problem/15349921
>
Brent Fulgham
Comment 2
2014-04-23 14:33:12 PDT
Created
attachment 230011
[details]
Patch
Eric Carlson
Comment 3
2014-04-23 15:03:50 PDT
Comment on
attachment 230011
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=230011&action=review
> Source/WebCore/platform/audio/MediaSession.h:105 > + bool m_elementIsHidden;
This is never initialized, but I don't know how it can be. Maybe it makes more sense to not cache this state but to always ask the client?
Brent Fulgham
Comment 4
2014-04-23 16:19:45 PDT
Created
attachment 230018
[details]
Patch
Eric Carlson
Comment 5
2014-04-23 16:30:27 PDT
Comment on
attachment 230018
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=230018&action=review
> Source/WebCore/html/HTMLMediaElement.cpp:6147 > +void HTMLMediaElement::shouldBufferData(bool shouldBuffer)
I should have noticed this before, but "shouldBufferData" sounds like it is a getter. Maybe "setShouldBufferData"?
> Source/WebCore/html/HTMLMediaElement.cpp:6150 > + return m_player->shouldBufferData(shouldBuffer);
Ditto.
> Source/WebCore/platform/audio/MediaSession.cpp:64 > + , m_elementIsHidden(false)
This isn't used.
> Source/WebCore/platform/audio/MediaSession.cpp:111 > + clientShouldBufferDataIfNotHiddenOrPlaying();
Nit: this name is a mouthful!
> Source/WebCore/platform/audio/MediaSession.cpp:175 > +void MediaSession::clientShouldBufferDataIfNotHiddenOrPlaying() > +{ > + if (m_client.elementIsHidden() && m_state != Playing) > + m_client.shouldBufferData(false); > + else > + m_client.shouldBufferData(true); > +}
I think part of the reason the name is so long is because it is used by the client and internally by the session. I would prefer something like "visibilityChanged()" for the client and "updateClientDataBuffering" for use within the session.
Brent Fulgham
Comment 6
2014-04-23 17:10:13 PDT
Created
attachment 230024
[details]
Patch
Brent Fulgham
Comment 7
2014-04-23 17:17:02 PDT
(In reply to
comment #5
)
> (From update of
attachment 230018
[details]
) > View in context:
https://bugs.webkit.org/attachment.cgi?id=230018&action=review
> > > Source/WebCore/html/HTMLMediaElement.cpp:6147 > > +void HTMLMediaElement::shouldBufferData(bool shouldBuffer) > > I should have noticed this before, but "shouldBufferData" sounds like it is a getter. Maybe "setShouldBufferData"? > > > Source/WebCore/html/HTMLMediaElement.cpp:6150 > > + return m_player->shouldBufferData(shouldBuffer); > > Ditto. > > > Source/WebCore/platform/audio/MediaSession.cpp:64 > > + , m_elementIsHidden(false) > > This isn't used. > > > Source/WebCore/platform/audio/MediaSession.cpp:111 > > + clientShouldBufferDataIfNotHiddenOrPlaying(); > > Nit: this name is a mouthful! > > > Source/WebCore/platform/audio/MediaSession.cpp:175 > > +void MediaSession::clientShouldBufferDataIfNotHiddenOrPlaying() > > +{ > > + if (m_client.elementIsHidden() && m_state != Playing) > > + m_client.shouldBufferData(false); > > + else > > + m_client.shouldBufferData(true); > > +} > > I think part of the reason the name is so long is because it is used by the client and internally by the session. I would prefer something like "visibilityChanged()" for the client and "updateClientDataBuffering" for use within the session.
Agreed. I've changed it.
Eric Carlson
Comment 8
2014-04-23 18:08:56 PDT
Comment on
attachment 230024
[details]
Patch View in context:
https://bugs.webkit.org/attachment.cgi?id=230024&action=review
Thanks!
> Source/WebCore/platform/audio/MediaSession.h:130 > +#if ENABLE(PAGE_VISIBILITY_API) > + virtual bool elementIsHidden() const { return false; } > +#endif
I don't think this is necessary.
Brent Fulgham
Comment 9
2014-04-23 18:24:26 PDT
Committed
r167734
: <
http://trac.webkit.org/changeset/167734
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug