| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// Builders sometime do not display the whole window viewport, so verify some
// of the viewport is detected as visible.
EXPECT_GT(playback_start_it->second, 50);50 sounds still flaky in the future. `EXPECT_GT(playback_start_it->second, 0);` might be better? WDYT?
If you take a param name (hidden, occluded, partial_occluded) to be "true" and the expected ratio param into each test, you can remove duplicate codes.
query_params.emplace_back("occluded", "true");I don't see the test for `partial_occluded`?
if (urlParams.get('opacity') === '0') { // New blockWhat does this mean?
// Ensure that the |visibility_tracker_| is detached when |this| is moved to
// a new document. Calling |ElementDidMoveToNewDocument| on the tracker at
// this point prevents having the tracker attached to an old document. The
// subsequent call to |UpdateVideoVisibilityTracker| will re-attach
// the tracker to the new document if needed.Why did this get removed?
ListBasedHitTestBehavior ComputeOcclusion(const ClientIdsSet& client_ids_set,Why did you move this method? Just regrouping? Or unnecessary change.
DCHECK(report_visibility_cb_);Removed this because now `report_visibility_cb_` can be null? Because no continous report is needed?
if (request_visibility_ratio_callback_) {
std::move(request_visibility_ratio_callback_).Run(0.0);
}Why do you call the callback with 0.0 here unnecessarily? If you intended to dispose it. `request_visibility_ratio_callback_ = nullptr;` should be enough?
auto intersection_area = ComputeArea(occlusion_state_.intersection_rect);Is this always zero rect since you did `occlusion_state_ = {};`?
auto intersection_area = ComputeArea(occlusion_state_.intersection_rect);Can you please clarify what `intersection_area` represents? Occlusion area is obvious to me but intersection area is not (intersection with what?).
// Detach if no continuous reporting is needed.This behavior is different from the previous behavior. Is this intentional? Because this MediaVideoVisibilityTracker has been there but the change will affect the existing behaviors.
You're changing the existing behavior not adding one more observer to report once for encrypted video visibility check.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// Builders sometime do not display the whole window viewport, so verify some
// of the viewport is detected as visible.
EXPECT_GT(playback_start_it->second, 50);50 sounds still flaky in the future. `EXPECT_GT(playback_start_it->second, 0);` might be better? WDYT?
Makes sense. Updated.
If you take a param name (hidden, occluded, partial_occluded) to be "true" and the expected ratio param into each test, you can remove duplicate codes.
Done
I don't see the test for `partial_occluded`?
Done
if (urlParams.get('opacity') === '0') { // New blockVikram PasupathyWhat does this mean?
Removed.
// Ensure that the |visibility_tracker_| is detached when |this| is moved to
// a new document. Calling |ElementDidMoveToNewDocument| on the tracker at
// this point prevents having the tracker attached to an old document. The
// subsequent call to |UpdateVideoVisibilityTracker| will re-attach
// the tracker to the new document if needed.Why did this get removed?
Done
}Vikram Pasupathynit: Unnecessary change
Its the result of git cl format
ListBasedHitTestBehavior ComputeOcclusion(const ClientIdsSet& client_ids_set,Why did you move this method? Just regrouping? Or unnecessary change.
Unnecessary, moved back down.
DCHECK(report_visibility_cb_);Removed this because now `report_visibility_cb_` can be null? Because no continous report is needed?
Yeah, it can be null because in `HTMLVideoElement::CreateVisibilityTrackerIfNeeded`, we sometimes don't pass a callback because continuous report is not needed.
if (request_visibility_ratio_callback_) {
std::move(request_visibility_ratio_callback_).Run(0.0);
}Why do you call the callback with 0.0 here unnecessarily? If you intended to dispose it. `request_visibility_ratio_callback_ = nullptr;` should be enough?
I will just drop the old callback and replace it with the new one.
auto intersection_area = ComputeArea(occlusion_state_.intersection_rect);Is this always zero rect since you did `occlusion_state_ = {};`?
`ComputeAreaOccludedByViewport` assigns values to `total_area` and `intersection_area`
auto intersection_area = ComputeArea(occlusion_state_.intersection_rect);Can you please clarify what `intersection_area` represents? Occlusion area is obvious to me but intersection area is not (intersection with what?).
Replaced with `total_area` and `intersection_area`, and added comments below in `ComputeAreaOccludedByViewport` for what they represent.
// Detach if no continuous reporting is needed.This behavior is different from the previous behavior. Is this intentional? Because this MediaVideoVisibilityTracker has been there but the change will affect the existing behaviors.
You're changing the existing behavior not adding one more observer to report once for encrypted video visibility check.
Refactored to keep most of it similar, and then added a comment on why we do the `base::TimeTicks::Now() - last_hit_test_timestamp_ >= hit_test_interval_` check.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
auto intersection_area = ComputeArea(occlusion_state_.intersection_rect);Vikram PasupathyIs this always zero rect since you did `occlusion_state_ = {};`?
`ComputeAreaOccludedByViewport` assigns values to `total_area` and `intersection_area`
I see but this is so confusing since you reset `occlusion_state_` and `ComputeAreaOccludedByViewport()` updates the `occlusion_state_` internally.
Why don't you move `occlusion_state_ = {};` into `ComputeVisibility()`?
auto intersection_area = ComputeArea(occlusion_state_.intersection_rect);Vikram PasupathyCan you please clarify what `intersection_area` represents? Occlusion area is obvious to me but intersection area is not (intersection with what?).
Replaced with `total_area` and `intersection_area`, and added comments below in `ComputeAreaOccludedByViewport` for what they represent.
Acknowledged
return;Now the line #837-838 are not being hit due to this `return;`. Is it intended?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
auto intersection_area = ComputeArea(occlusion_state_.intersection_rect);Vikram PasupathyIs this always zero rect since you did `occlusion_state_ = {};`?
Sangbaek Park`ComputeAreaOccludedByViewport` assigns values to `total_area` and `intersection_area`
I see but this is so confusing since you reset `occlusion_state_` and `ComputeAreaOccludedByViewport()` updates the `occlusion_state_` internally.
Why don't you move `occlusion_state_ = {};` into `ComputeVisibility()`?
Both use ComputeAreaOccludedByViewport, so moved it there.
// Detach if no continuous reporting is needed.Vikram PasupathyThis behavior is different from the previous behavior. Is this intentional? Because this MediaVideoVisibilityTracker has been there but the change will affect the existing behaviors.
You're changing the existing behavior not adding one more observer to report once for encrypted video visibility check.
Refactored to keep most of it similar, and then added a comment on why we do the `base::TimeTicks::Now() - last_hit_test_timestamp_ >= hit_test_interval_` check.
Done
Now the line #837-838 are not being hit due to this `return;`. Is it intended?
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
auto intersection_area = ComputeArea(occlusion_state_.intersection_rect);Vikram PasupathyIs this always zero rect since you did `occlusion_state_ = {};`?
Sangbaek Park`ComputeAreaOccludedByViewport` assigns values to `total_area` and `intersection_area`
Vikram PasupathyI see but this is so confusing since you reset `occlusion_state_` and `ComputeAreaOccludedByViewport()` updates the `occlusion_state_` internally.
Why don't you move `occlusion_state_ = {};` into `ComputeVisibility()`?
Both use ComputeAreaOccludedByViewport, so moved it there.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
=>bkeen to do a pass first since he wrote a lot of this code.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
FWIW, in the future I'd recommend splitting up a change like this. E.g., the visibility tracker changes seem like they'd more easily reviewed in a smaller more scoped change w/ tests.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
void HTMLVideoElement::CreateVisibilityTrackerIfNeeded(bool force_create) {I think this could be confusing, specially since what you really want is to configure based on the features. How about something like:
```
const bool autopip_video_heuristics_enabled =
RuntimeEnabledFeatures::AutoPictureInPictureVideoHeuristicsEnabled();
const bool encryption_media_occlussion_tracking_enabled =
base::FeatureList::IsEnabled(media::kEncryptedMediaOcclusionTracking);
// Exit if neither feature needs the tracker.
if (!autopip_video_heuristics_enabled && !encryption_media_occlussion_tracking_enabled) {
return;
}
if (autopip_video_heuristics_enabled) {
...
}
``` last_visibility_ratio_ = ComputeVisibilityRatio();Here you are missing some important checks that happen in `MaybeComputeVisibility`. For example: If the tracker is attached, checking we are in the outer main frame, etc.
Additionally, we shouldn't access the paint artifact (`GetPaintArtifact`) if the document is not in the paint clean [state](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/frame/local_frame_view.cc;l=4180;drc=6b7247341b28f7d52babcbbde257523c43b019e5).
void HTMLVideoElement::CreateVisibilityTrackerIfNeeded(bool force_create) {I think this could be confusing, specially since what you really want is to configure based on the features. How about something like:
```
const bool autopip_video_heuristics_enabled =
RuntimeEnabledFeatures::AutoPictureInPictureVideoHeuristicsEnabled();
const bool encryption_media_occlussion_tracking_enabled =
base::FeatureList::IsEnabled(media::kEncryptedMediaOcclusionTracking);// Exit if neither feature needs the tracker.
if (!autopip_video_heuristics_enabled && !encryption_media_occlussion_tracking_enabled) {
return;
}if (autopip_video_heuristics_enabled) {
...
}
```
Thanks. Done!
last_visibility_ratio_ = ComputeVisibilityRatio();Here you are missing some important checks that happen in `MaybeComputeVisibility`. For example: If the tracker is attached, checking we are in the outer main frame, etc.
Additionally, we shouldn't access the paint artifact (`GetPaintArtifact`) if the document is not in the paint clean [state](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/frame/local_frame_view.cc;l=4180;drc=6b7247341b28f7d52babcbbde257523c43b019e5).
The `HasValidFrameAndLayout() && IsPaintClean()` may also go above in line 810, but I don't think that makes sense, because the `HasValidFrameAndLayout() && IsPaintClean()` checks are only for `ComputeVisibility()`.
Just commenting this, to make sure that it is the intended behavior, and for you to keep me honest. Thanks!
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
void MediaVideoVisibilityTracker::RequestVisibilityRatio(I'm not familiar with the encryption code path. But, can you get multiple requests for the visibility ratio, and if so, would that be a problem? You'd only get the notification for the latest request.
if (ratio_requested_ && HasValidFrameAndLayout() && IsPaintClean()) {Optional: Please move this (lines 814-827) into a dedicated method (`MaybeComputeVisibilityRatio`?). And for the header comment mention that this will detach the tracker.
last_visibility_ratio_ = ComputeVisibilityRatio();Vikram PasupathyHere you are missing some important checks that happen in `MaybeComputeVisibility`. For example: If the tracker is attached, checking we are in the outer main frame, etc.
Additionally, we shouldn't access the paint artifact (`GetPaintArtifact`) if the document is not in the paint clean [state](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/frame/local_frame_view.cc;l=4180;drc=6b7247341b28f7d52babcbbde257523c43b019e5).
The `HasValidFrameAndLayout() && IsPaintClean()` may also go above in line 810, but I don't think that makes sense, because the `HasValidFrameAndLayout() && IsPaintClean()` checks are only for `ComputeVisibility()`.
Just commenting this, to make sure that it is the intended behavior, and for you to keep me honest. Thanks!
This looks good, thanks!
Yeah, moving the check to line 810 wouldn't make sense, since it would mean we could drop pending visibility requests.
Did you already get UKM approval for this change? Should be trivial, but is required IIRC.
void EncryptedMediaInitDataEncountered() final;`OnEncryptedMediaInitData()` naming would be more consistent?
FWIW, in the future I'd recommend splitting up a change like this. E.g., the visibility tracker changes seem like they'd more easily reviewed in a smaller more scoped change w/ tests.
Acknowledged
Did you already get UKM approval for this change? Should be trivial, but is required IIRC.
Added corresponding UKM approval bug.
`OnEncryptedMediaInitData()` naming would be more consistent?
Done
void MediaVideoVisibilityTracker::RequestVisibilityRatio(I'm not familiar with the encryption code path. But, can you get multiple requests for the visibility ratio, and if so, would that be a problem? You'd only get the notification for the latest request.
Currently, we are only requesting once, at playback start. But I was requesting it multiple times with this previously, and it was working as expected. What would be the issue with this?
if (ratio_requested_ && HasValidFrameAndLayout() && IsPaintClean()) {Optional: Please move this (lines 814-827) into a dedicated method (`MaybeComputeVisibilityRatio`?). And for the header comment mention that this will detach the tracker.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
void MediaVideoVisibilityTracker::RequestVisibilityRatio(Vikram PasupathyI'm not familiar with the encryption code path. But, can you get multiple requests for the visibility ratio, and if so, would that be a problem? You'd only get the notification for the latest request.
Currently, we are only requesting once, at playback start. But I was requesting it multiple times with this previously, and it was working as expected. What would be the issue with this?
No issues at all, as long as you only need the latest visibility ratio.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |