As promised in [7226094](https://chromium-review.googlesource.com/c/chromium/src/+/7226094), unit tests for the feature.
Please review, thanks!
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
As promised in [7226094](https://chromium-review.googlesource.com/c/chromium/src/+/7226094), unit tests for the feature.
Please review, thanks!
Sweet, thanks for following up! Tests look great, a few comments on other parts.
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kBusyLoopOnRendererMain);If these are only needed in the blink scheduler, they can go in https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/scheduler/common/features.h and .cc.
MaybeSetBusyLoop();I know this is existing, but does the `UpdatePolicy()` below not also call `MaybeSetBusyLoop()`? Or does it early-out before that?
if (!::features::IsEligibleForThrottleMainFrameTo60Hz() ||Optional since this matches existing code, but can you early exit this if the features aren't enabled, i.e. can we just do nothing in that case? That's a bit more idiomatic for feature code unless something below still needs to run.
void SetCurrentUseCase(UseCase use_case) {There's a `SetUseCaseAndUpdatePolicy()` that was added to main_thread_scheduler_impl_unittest.cc that allows overriding the `UseCase` that gets used within `UpdatePolicy()`. Could that be used (probably needs to be moved up to the main test class) instead of adding these two methods? I think that would allow MaybeSetBusyLoop() to be called via UpdatePolicy, which tests a bit more.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
BLINK_COMMON_EXPORT BASE_DECLARE_FEATURE(kBusyLoopOnRendererMain);If these are only needed in the blink scheduler, they can go in https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/scheduler/common/features.h and .cc.
Done
I know this is existing, but does the `UpdatePolicy()` below not also call `MaybeSetBusyLoop()`? Or does it early-out before that?
You are correct. Removed the line and verified that busy loop scale factor is indeed updated.
if (!::features::IsEligibleForThrottleMainFrameTo60Hz() ||Optional since this matches existing code, but can you early exit this if the features aren't enabled, i.e. can we just do nothing in that case? That's a bit more idiomatic for feature code unless something below still needs to run.
Done. I had to make the tests parametrized to achieve this but I agree that its better now that the production code is idiomatic, even if the tests are a bit more cumbersome to understand.
void SetCurrentUseCase(UseCase use_case) {There's a `SetUseCaseAndUpdatePolicy()` that was added to main_thread_scheduler_impl_unittest.cc that allows overriding the `UseCase` that gets used within `UpdatePolicy()`. Could that be used (probably needs to be moved up to the main test class) instead of adding these two methods? I think that would allow MaybeSetBusyLoop() to be called via UpdatePolicy, which tests a bit more.
The use case value is updated in UpdatePolicy() [(cs)](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc;l=1657;drc=e63596721df61bbc199c38c4a102597ad81ad154) which makes it difficult to test how busy-looping interacts with the use-case for all use-cases.
It also trips a few carefully placed asserts in UpdatePolicy() which expect use-cases to change in a specific manner or require other values to be set.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
float busy_loop_scale_factor;Initialize to 0?
void SetCurrentUseCase(UseCase use_case) {Anand RaviThere's a `SetUseCaseAndUpdatePolicy()` that was added to main_thread_scheduler_impl_unittest.cc that allows overriding the `UseCase` that gets used within `UpdatePolicy()`. Could that be used (probably needs to be moved up to the main test class) instead of adding these two methods? I think that would allow MaybeSetBusyLoop() to be called via UpdatePolicy, which tests a bit more.
The use case value is updated in UpdatePolicy() [(cs)](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc;l=1657;drc=e63596721df61bbc199c38c4a102597ad81ad154) which makes it difficult to test how busy-looping interacts with the use-case for all use-cases.
It also trips a few carefully placed asserts in UpdatePolicy() which expect use-cases to change in a specific manner or require other values to be set.
The use case value is updated in UpdatePolicy() [(cs)](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc;l=1657;drc=e63596721df61bbc199c38c4a102597ad81ad154) which makes it difficult to test how busy-looping interacts with the use-case for all use-cases.
`SetUseCaseAndUpdatePolicy()` sets a special `use_case_override_`, and `ComputeCurrentUseCase()` is overridden to return that [1], so that should just work when iterating over all use cases?
It also trips a few carefully placed asserts in UpdatePolicy() which expect use-cases to change in a specific manner or require other values to be set.
Hmm I tried this locally with your patch and didn't hit any checks (and the tests all pass). Which checks did you hit?
---
If that doesn't work, maybe consider moving `ForceSetBusyLoop()` into `MainThreadSchedulerImplForTest` since it's a friend class, to cut down on the number of test-only methods. You could also pass the UseCase to `MaybeSetBusyLoop()` to avoid having to set the use case. But it would be nice to go through `UpdatePolicy()` if possible just to ensure your method and side effects are being called, which can also helps prevent future regressions.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
float busy_loop_scale_factor;Anand RaviInitialize to 0?
Fixed.
void SetCurrentUseCase(UseCase use_case) {Anand RaviThere's a `SetUseCaseAndUpdatePolicy()` that was added to main_thread_scheduler_impl_unittest.cc that allows overriding the `UseCase` that gets used within `UpdatePolicy()`. Could that be used (probably needs to be moved up to the main test class) instead of adding these two methods? I think that would allow MaybeSetBusyLoop() to be called via UpdatePolicy, which tests a bit more.
Scott HaseleyThe use case value is updated in UpdatePolicy() [(cs)](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc;l=1657;drc=e63596721df61bbc199c38c4a102597ad81ad154) which makes it difficult to test how busy-looping interacts with the use-case for all use-cases.
It also trips a few carefully placed asserts in UpdatePolicy() which expect use-cases to change in a specific manner or require other values to be set.
The use case value is updated in UpdatePolicy() [(cs)](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/platform/scheduler/main_thread/main_thread_scheduler_impl.cc;l=1657;drc=e63596721df61bbc199c38c4a102597ad81ad154) which makes it difficult to test how busy-looping interacts with the use-case for all use-cases.
`SetUseCaseAndUpdatePolicy()` sets a special `use_case_override_`, and `ComputeCurrentUseCase()` is overridden to return that [1], so that should just work when iterating over all use cases?
It also trips a few carefully placed asserts in UpdatePolicy() which expect use-cases to change in a specific manner or require other values to be set.
Hmm I tried this locally with your patch and didn't hit any checks (and the tests all pass). Which checks did you hit?
---
If that doesn't work, maybe consider moving `ForceSetBusyLoop()` into `MainThreadSchedulerImplForTest` since it's a friend class, to cut down on the number of test-only methods. You could also pass the UseCase to `MaybeSetBusyLoop()` to avoid having to set the use case. But it would be nice to go through `UpdatePolicy()` if possible just to ensure your method and side effects are being called, which can also helps prevent future regressions.
I remember this check being tripped in the initial versions if I iterated on the use cases more than once. I modified the tests to use SetUseCaseAndUpdatePolicy() and iterate more than once on the use cases .. and the tests pass locally.
So I have switched it to use SetUseCaseAndUpdatePolicy().
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Victor, can you review the one line change in cc? Thanks!
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| 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. |
| Commit-Queue | +2 |
Looks to me like the GPU tests are flaky on Pixel 6. Trying to submit again.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Commit-Queue | +2 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
[blink] Add unit tests for BusyLoopOnRendererMain
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |