Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Issue 1329853004: Include viewport visibility checks for autoplay experiment. (Closed)

Created:
5 years, 3 months ago by liberato (no reviews please)
Modified:
5 years, 2 months ago
CC:
blink-reviews, blink-reviews-rendering, blink-reviews-html_chromium.org, szager+layoutwatch_chromium.org, zoltan1, mlamouri+watch-blink_chromium.org, eae+blinkwatch, vivekg, philipj_slow, gasubic, fs, eric.carlson_apple.com, leviw+renderwatch, feature-media-reviews_chromium.org, dglazkov+blink, nessy, vivekg_samsung, Inactive, jchaffraix+rendering, pdr+renderingwatchlist_chromium.org, vcarbune.chromium
Base URL:
https://chromium.googlesource.com/chromium/blink.git@autoplay_step1
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

CLOSED in favor of the post-blink-merge https://codereview.chromium.org/1370723002 . Please redirect reviews there! ==== Include viewport visibility checks for autoplay experiment. If the value of the autoplayExperimentMode setting contains "-ifviewport", then the autoplay experiment will additionally require that the media is located in the viewport bounds. Autoplay is deferred until it comes into view, assuming that it passes any other autoplay experiment checks that have been turned on. BUG=487345, 402044

Patch Set 1 #

Total comments: 1

Patch Set 2 : git cl try #

Patch Set 3 : readded "wait for scroll to end" logic #

Patch Set 4 : rebased. #

Total comments: 34

Patch Set 5 : Rebased onto merged blink repo. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+618 lines, -78 lines) Patch
M third_party/WebKit/LayoutTests/media/video-autoplay-experiment-modes.html View 1 2 3 4 12 chunks +101 lines, -12 lines 0 comments Download
M third_party/WebKit/LayoutTests/media/video-autoplay-experiment-modes-expected.txt View 1 2 3 4 2 chunks +48 lines, -42 lines 0 comments Download
M third_party/WebKit/Source/core/frame/FrameView.cpp View 1 2 3 4 1 chunk +5 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/html/AutoplayExperimentConfig.h View 1 2 3 4 1 chunk +13 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/core/html/AutoplayExperimentConfig.cpp View 1 2 3 4 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/html/AutoplayExperimentHelper.h View 1 2 3 4 3 chunks +61 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/html/AutoplayExperimentHelper.cpp View 1 2 3 4 7 chunks +243 lines, -15 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLMediaElement.h View 1 2 3 4 2 chunks +6 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLMediaElement.cpp View 1 2 3 4 1 chunk +10 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutMedia.h View 1 2 3 4 2 chunks +24 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutMedia.cpp View 1 2 3 4 2 chunks +58 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutVideo.h View 1 2 3 4 1 chunk +0 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutVideo.cpp View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutView.h View 1 2 3 4 3 chunks +12 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutView.cpp View 1 2 3 4 2 chunks +22 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/testing/Internals.h View 1 2 3 4 1 chunk +3 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/testing/Internals.cpp View 1 2 3 4 1 chunk +5 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/testing/Internals.idl View 1 2 3 4 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 15 (2 generated)
liberato (no reviews please)
Here's where the other half of the autoplay experiment CL went :) it does address ...
5 years, 3 months ago (2015-09-04 06:58:16 UTC) #2
philipj_slow
https://codereview.chromium.org/1329853004/diff/1/Source/core/html/AutoplayExperimentConfig.h File Source/core/html/AutoplayExperimentConfig.h (right): https://codereview.chromium.org/1329853004/diff/1/Source/core/html/AutoplayExperimentConfig.h#newcode30 Source/core/html/AutoplayExperimentConfig.h:30: IfViewport = 1 << 2, Ah, here it is. ...
5 years, 3 months ago (2015-09-04 08:47:56 UTC) #3
liberato (no reviews please)
I've separated the viewport visibility check into two: one that does page visibility only, and ...
5 years, 3 months ago (2015-09-14 14:50:12 UTC) #5
liberato (no reviews please)
all feedback is welcome! thanks -fl
5 years, 3 months ago (2015-09-16 20:12:47 UTC) #6
esprehn
I'll review this today, thanks for being patient! On Wed, Sep 16, 2015 at 1:12 ...
5 years, 3 months ago (2015-09-16 21:26:25 UTC) #7
esprehn
I'm still reviewing this, I'm not a fan of "Helper" classes like this. We don't ...
5 years, 3 months ago (2015-09-17 07:09:49 UTC) #8
liberato (no reviews please)
On 2015/09/17 07:09:49, esprehn wrote: > I'm still reviewing this, I'm not a fan of ...
5 years, 3 months ago (2015-09-17 13:58:19 UTC) #9
liberato (no reviews please)
hi all friendly reminder! thanks -fl
5 years, 3 months ago (2015-09-21 14:04:20 UTC) #10
philipj_slow
I've looked at core/html, if possible I'd like to leave core/layout to one of the ...
5 years, 3 months ago (2015-09-21 15:02:05 UTC) #11
liberato (no reviews please)
i believe that this addresses the outstanding feedback, though i understand that the layout code ...
5 years, 3 months ago (2015-09-23 06:14:57 UTC) #12
liberato (no reviews please)
i believe that this addresses the outstanding feedback, though i understand that the layout code ...
5 years, 3 months ago (2015-09-23 06:14:57 UTC) #13
esprehn
I'll try to review this tomorrow. To unsubscribe from this group and stop receiving emails ...
5 years, 3 months ago (2015-09-23 06:55:06 UTC) #14
philipj_slow
5 years, 2 months ago (2015-09-25 15:32:28 UTC) #15
My comments seem to have been addressed, so LGTM. However, the base URL is still
blink.git, so I think you'll have to create a new review. When you do, it would
be great if you start it with PS4, so I can see the whole diff to PS5, here I
had to look and compare by hand, and probably missed some things.

https://codereview.chromium.org/1329853004/diff/80001/LayoutTests/media/video...
File LayoutTests/media/video-autoplay-experiment-modes.html (right):

https://codereview.chromium.org/1329853004/diff/80001/LayoutTests/media/video...
LayoutTests/media/video-autoplay-experiment-modes.html:169: // Pick whether the
element will be visible when canPlayThrough.
On 2015/09/23 06:14:56, liberato wrote:
> On 2015/09/21 15:02:04, philipj wrote:
> > What does the "when canPlayThrough" bit mean? The layout will be done
roughly
> > instantly.
> 
> At some point, canplaythrough will be generated, and the autoplay experiment
> checks will be done.  we are choosing if we want to pass or fail the
visibility
> checks when that happens.
> 
> why does this necessarily happen right away, though?

I mean that this code is appending the element either to an onscreen element or
an offscreen element right now, but the comment makes it sound like it has
something to do with the canplaythrough event.

https://codereview.chromium.org/1329853004/diff/80001/LayoutTests/media/video...
LayoutTests/media/video-autoplay-experiment-modes.html:204:
window.internals.triggerAutoplayViewportCheck(element);
On 2015/09/23 06:14:56, liberato wrote:
> On 2015/09/21 15:02:04, philipj wrote:
> > What's going on here, isn't the scroll itself supposed to trigger the play,
or
> > was that idea abandoned? (I don't think it's a sane behavior, but IIRC it
> would
> > still be tested to see how people react.)
> 
> the trigger happens after scrolling stops, not when it starts.  as in,
flinging
> the page to the bottom won't automatically start every video on the page.

Yes, but shouldn't the call to element.scrollIntoView() eventually trigger the
check again, or why is the manual triggerAutoplayViewportCheck needed here?

https://codereview.chromium.org/1329853004/diff/80001/Source/core/html/Autopl...
File Source/core/html/AutoplayExperimentHelper.cpp (right):

https://codereview.chromium.org/1329853004/diff/80001/Source/core/html/Autopl...
Source/core/html/AutoplayExperimentHelper.cpp:83: // Wait for viewport
visibility.
On 2015/09/23 06:14:57, liberato wrote:
> On 2015/09/21 15:02:04, philipj wrote:
> > I guess it actually waits for either page visiblity or element visibility
> > depending on settings?
> > 
> > Also, I guess you need to also register for changes in page visibility? This
> > might be hard to write a test for, unless page visibility works in iframes.
> 
> it doesn't register for page visibility because the callback from FrameView
> covers it.  we just register for that always.

Acknowledged.

https://codereview.chromium.org/1329853004/diff/80001/Source/core/html/Autopl...
Source/core/html/AutoplayExperimentHelper.cpp:184: return;
On 2015/09/23 06:14:56, liberato wrote:
> On 2015/09/21 15:02:04, philipj wrote:
> > Is this code path reached and if so when *is* positionChanged called? If it
> > isn't reached, then ASSERT
> 
> actually, the more i think about it, we don't want to check at all in case the
> timer did fire.

I see this block was removed.

https://codereview.chromium.org/1329853004/diff/80001/Source/core/html/Autopl...
Source/core/html/AutoplayExperimentHelper.cpp:224: // callers need to do it
separately, and we don't want to check more
On 2015/09/23 06:14:56, liberato wrote:
> On 2015/09/21 15:02:05, philipj wrote:
> > Are there some callers that don't check it, and if so doesn't it matter to
> them?
> > If all call paths have the check, then ASSERT something.
> 
> mVR() is called quite often during visibility checks.  they don't care about
the
> rest of it.
> 
> both mVR and isEligible are well-defined in the absence of the other, so i'm
not
> sure on what one should assert.

OK, I read "We could check for eligibility here, but we skip it" as "`if
(!isEligible()) return false` would make no difference" and so thought perhaps
there was invariant here.

https://codereview.chromium.org/1329853004/diff/80001/Source/core/html/Autopl...
Source/core/html/AutoplayExperimentHelper.cpp:343: if (!element.layoutObject())
On 2015/09/23 06:14:56, liberato wrote:
> On 2015/09/21 15:02:04, philipj wrote:
> > Should this updateLayoutIgnorePendingStylesheets(), or is the idea that the
> > resize callbacks will invalidate this when the layout has happened so that
it
> > doesn't matter?
> 
> i don't think that we need to update the layout here.  during scroll checking,
> the layout is valid so it doesn't matter.
> 
> i've certainly had bad luck with causing a layout previously.  :)
> 
> if we get here and it isn't available, then we'll just register for a callback
> and get notification when it's available.

Acknowledged.

https://codereview.chromium.org/1329853004/diff/80001/Source/core/html/Autopl...
Source/core/html/AutoplayExperimentHelper.cpp:366: // viewport, then be happy if
it covers it.
On 2015/09/23 06:14:56, liberato wrote:
> On 2015/09/21 15:02:04, philipj wrote:
> > This all seems pretty elaborate, why not just return
> element.intersects(screen)?
> 
> "contained in" just seemed nicer than "intersects with" when playing with it
on
> a device.

It seems like it could be a bit annoying in cases where the video is relatively
big, but OK, if you've tested it :) As you know I'm not too keen element
visibility checks, but let's see what the experiment reveals.

https://codereview.chromium.org/1329853004/diff/80001/Source/core/html/Autopl...
File Source/core/html/AutoplayExperimentHelper.h (right):

https://codereview.chromium.org/1329853004/diff/80001/Source/core/html/Autopl...
Source/core/html/AutoplayExperimentHelper.h:87: // "not valid", in case some of
the information isn't available.
On 2015/09/23 06:14:57, liberato wrote:
> On 2015/09/21 15:02:05, philipj wrote:
> > I looks like PageVisibilityState is doesn't have an "invalid" state, so I
> guess
> > this is for m_element and m_screen. Can't those invalid states then simply
be
> > expressed by one or both of those being the empty rect? Less stuff to keep
in
> > sync.
> 
> i don't see a way to make it work automatically.  intersects() always returns
> false for empty rectangles, but contains() does not.  we'd still have to check
> explicitly for isEmpty().
> 
> anyway, it does remove the flag so i'll give it a try.  i suspect that it will
> be less clear.

OK, looks like it was successfully removed.

https://codereview.chromium.org/1329853004/diff/80001/Source/core/html/Autopl...
Source/core/html/AutoplayExperimentHelper.h:121: // Return true if any only if
this player meets (most) of the eligibility
Another "player" here if you want to fix it.

https://codereview.chromium.org/1329853004/diff/80001/Source/core/html/Autopl...
Source/core/html/AutoplayExperimentHelper.h:127: // not visible, and we care
that it must be visible.
On 2015/09/23 06:14:57, liberato wrote:
> On 2015/09/21 15:02:05, philipj wrote:
> > It's pretty hard to tell from this header when you should pass the
> LocationState
> > and when you don't need to. It looks like it has to do with comparing the
> > before/after state.
> 
> if yuo have LocationState, pass it in.  if not, then the second form will
> construct one for you.  i'll update the docs to make that clearer.

Acknowledged.

Powered by Google App Engine
This is Rietveld 408576698