[resource coordinator] TabManager discards via PageDiscardingHelper [chromium/src : main]

0 views
Skip to first unread message

Vovo Yang (Gerrit)

unread,
Nov 12, 2025, 9:49:41 AMNov 12
to Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org
Attention needed from Joe Mason

New activity on the change

Open in Gerrit

Related details

Attention is currently required from:
  • Joe Mason
Submit Requirements:
  • requirement satisfiedCode-Coverage
  • requirement is not satisfiedCode-Owners
  • requirement is not satisfiedCode-Review
  • requirement is not satisfiedReview-Enforcement
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: comment
Gerrit-Project: chromium/src
Gerrit-Branch: main
Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
Gerrit-Change-Number: 7129640
Gerrit-PatchSet: 11
Gerrit-Owner: Vovo Yang <vo...@chromium.org>
Gerrit-Reviewer: Joe Mason <joenot...@google.com>
Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
Gerrit-Attention: Joe Mason <joenot...@google.com>
Gerrit-Comment-Date: Wed, 12 Nov 2025 14:49:08 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: No
satisfied_requirement
unsatisfied_requirement
open
diffy

Joe Mason (Gerrit)

unread,
Nov 13, 2025, 5:03:00 PMNov 13
to Vovo Yang, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org
Attention needed from Vovo Yang

Joe Mason added 6 comments

Patchset-level comments
File-level comment, Patchset 11 (Latest):
Joe Mason . unresolved

I'm very excited to reduce the duplication!

I made a first pass at this. I still want to double-check the logic in TabLifecycleUnit::CanDiscard and make sure there are no important checks there missing from DiscardEligibilityPolicy, and go through the deleted tests and make sure there's test coverage for everything that's being removed.

File chrome/browser/resource_coordinator/tab_lifecycle_unit_source_unittest.cc
Line 277, Patchset 11 (Parent): ExpectCanDiscardFalseTrivialAllReasons(first_lifecycle_unit);
Joe Mason . unresolved

I think we still want to check that DiscardEligibilityPolicy::CanDiscard returns false here. Or else call Dicard and verify that it doesn't actually get discarded (as long as that's not expected to crash when CanDiscard returns false.)

Line 293, Patchset 11 (Parent): // Insert the tab into the second tab strip without focusing it. Verify that
Joe Mason . unresolved

Nit: I think this comment should be kept, since it helps understand what the rest of the test is doing.

File chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc
Line 223, Patchset 11 (Parent):TEST_F(TabLifecycleUnitTest, CanDiscardByDefault) {
Joe Mason . unresolved

Why delete this test?

Line 239, Patchset 11 (Parent): ExpectCanDiscardTrueAllReasons(&tab_lifecycle_unit);
Joe Mason . unresolved

I think we should be testing DiscardEligibilityPolicy::CanDiscard at all these points, if we're keeping this test at all.

File chrome/browser/resource_coordinator/tab_manager.h
Line 80, Patchset 11 (Latest): // |reason|. Exposes |minimum_time_in_background_to_discard| so test can set
Joe Mason . unresolved

Nit: "tests"

Open in Gerrit

Related details

Attention is currently required from:
  • Vovo Yang
Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
    Gerrit-Change-Number: 7129640
    Gerrit-PatchSet: 11
    Gerrit-Owner: Vovo Yang <vo...@chromium.org>
    Gerrit-Reviewer: Joe Mason <joenot...@google.com>
    Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
    Gerrit-Attention: Vovo Yang <vo...@chromium.org>
    Gerrit-Comment-Date: Thu, 13 Nov 2025 22:02:54 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Vovo Yang (Gerrit)

    unread,
    Nov 14, 2025, 8:30:21 AMNov 14
    to Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org
    Attention needed from Joe Mason

    Vovo Yang added 1 comment

    File chrome/browser/resource_coordinator/tab_lifecycle_unit_source_unittest.cc
    Line 277, Patchset 11 (Parent): ExpectCanDiscardFalseTrivialAllReasons(first_lifecycle_unit);
    Joe Mason . unresolved

    I think we still want to check that DiscardEligibilityPolicy::CanDiscard returns false here. Or else call Dicard and verify that it doesn't actually get discarded (as long as that's not expected to crash when CanDiscard returns false.)

    Vovo Yang

    Ok, I am working on adding back ExpectCanDiscard* functions and adding back some of the tests.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joe Mason
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
    Gerrit-Change-Number: 7129640
    Gerrit-PatchSet: 11
    Gerrit-Owner: Vovo Yang <vo...@chromium.org>
    Gerrit-Reviewer: Joe Mason <joenot...@google.com>
    Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
    Gerrit-Attention: Joe Mason <joenot...@google.com>
    Gerrit-Comment-Date: Fri, 14 Nov 2025 13:29:48 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Joe Mason <joenot...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Vovo Yang (Gerrit)

    unread,
    Nov 16, 2025, 11:59:15 PMNov 16
    to Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org
    Attention needed from Joe Mason

    Vovo Yang added 5 comments

    File chrome/browser/resource_coordinator/tab_lifecycle_unit_source_unittest.cc
    Line 277, Patchset 11 (Parent): ExpectCanDiscardFalseTrivialAllReasons(first_lifecycle_unit);
    Joe Mason . resolved

    I think we still want to check that DiscardEligibilityPolicy::CanDiscard returns false here. Or else call Dicard and verify that it doesn't actually get discarded (as long as that's not expected to crash when CanDiscard returns false.)

    Vovo Yang

    Ok, I am working on adding back ExpectCanDiscard* functions and adding back some of the tests.

    Vovo Yang

    Adds check to verify Discard() returns false when the tab is detached. Adds check to verify Discard() returns true when the tab is reattached.

    Line 293, Patchset 11 (Parent): // Insert the tab into the second tab strip without focusing it. Verify that
    Joe Mason . resolved

    Nit: I think this comment should be kept, since it helps understand what the rest of the test is doing.

    Vovo Yang

    Done

    File chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc
    Line 223, Patchset 11 (Parent):TEST_F(TabLifecycleUnitTest, CanDiscardByDefault) {
    Joe Mason . resolved

    Why delete this test?

    Vovo Yang

    Added back CanDiscardByDefault.

    Line 239, Patchset 11 (Parent): ExpectCanDiscardTrueAllReasons(&tab_lifecycle_unit);
    Joe Mason . resolved

    I think we should be testing DiscardEligibilityPolicy::CanDiscard at all these points, if we're keeping this test at all.

    Vovo Yang

    Added comments to explain why SetFocused and some other unit tests are removed.

    File chrome/browser/resource_coordinator/tab_manager.h
    Line 80, Patchset 11: // |reason|. Exposes |minimum_time_in_background_to_discard| so test can set
    Joe Mason . resolved

    Nit: "tests"

    Vovo Yang

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joe Mason
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
    Gerrit-Change-Number: 7129640
    Gerrit-PatchSet: 12
    Gerrit-Owner: Vovo Yang <vo...@chromium.org>
    Gerrit-Reviewer: Joe Mason <joenot...@google.com>
    Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
    Gerrit-Attention: Joe Mason <joenot...@google.com>
    Gerrit-Comment-Date: Mon, 17 Nov 2025 04:58:45 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Vovo Yang <vo...@chromium.org>
    Comment-In-Reply-To: Joe Mason <joenot...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Vovo Yang (Gerrit)

    unread,
    Nov 17, 2025, 7:08:33 AMNov 17
    to Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org
    Attention needed from Joe Mason

    Vovo Yang added 1 comment

    File chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc
    Line 239, Patchset 11 (Parent): ExpectCanDiscardTrueAllReasons(&tab_lifecycle_unit);
    Joe Mason . resolved

    I think we should be testing DiscardEligibilityPolicy::CanDiscard at all these points, if we're keeping this test at all.

    Vovo Yang

    Added comments to explain why SetFocused and some other unit tests are removed.

    Vovo Yang

    Updated the commit message to explain the reason to remove some unit tests.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joe Mason
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
    Gerrit-Change-Number: 7129640
    Gerrit-PatchSet: 15
    Gerrit-Owner: Vovo Yang <vo...@chromium.org>
    Gerrit-Reviewer: Joe Mason <joenot...@google.com>
    Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
    Gerrit-Attention: Joe Mason <joenot...@google.com>
    Gerrit-Comment-Date: Mon, 17 Nov 2025 12:07:58 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Joe Mason (Gerrit)

    unread,
    Nov 18, 2025, 5:35:29 PMNov 18
    to Vovo Yang, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org
    Attention needed from Vovo Yang

    Joe Mason added 2 comments

    Patchset-level comments
    File-level comment, Patchset 11:
    Joe Mason . unresolved

    I'm very excited to reduce the duplication!

    I made a first pass at this. I still want to double-check the logic in TabLifecycleUnit::CanDiscard and make sure there are no important checks there missing from DiscardEligibilityPolicy, and go through the deleted tests and make sure there's test coverage for everything that's being removed.

    Joe Mason

    Found one missed check in CanDiscard. Still need to check the tests.

    File chrome/browser/resource_coordinator/tab_lifecycle_unit.cc
    Line 307, Patchset 15 (Parent): if (tab_helper && tab_helper->is_in_app_window()) {
    Joe Mason . unresolved

    This check isn't in DiscardEligibilityPolicy::CanDiscard - it should be added there.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Vovo Yang
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
    Gerrit-Change-Number: 7129640
    Gerrit-PatchSet: 15
    Gerrit-Owner: Vovo Yang <vo...@chromium.org>
    Gerrit-Reviewer: Joe Mason <joenot...@google.com>
    Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
    Gerrit-Attention: Vovo Yang <vo...@chromium.org>
    Gerrit-Comment-Date: Tue, 18 Nov 2025 22:35:22 +0000
    Gerrit-HasComments: Yes
    Gerrit-Has-Labels: No
    Comment-In-Reply-To: Joe Mason <joenot...@google.com>
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Joe Mason (Gerrit)

    unread,
    Nov 18, 2025, 5:49:22 PMNov 18
    to Vovo Yang, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org
    Attention needed from Vovo Yang

    Joe Mason added 5 comments

    Patchset-level comments
    Joe Mason . unresolved

    I'm very excited to reduce the duplication!

    I made a first pass at this. I still want to double-check the logic in TabLifecycleUnit::CanDiscard and make sure there are no important checks there missing from DiscardEligibilityPolicy, and go through the deleted tests and make sure there's test coverage for everything that's being removed.

    Joe Mason

    Found one missed check in CanDiscard. Still need to check the tests.

    Joe Mason

    Looks good except for the WebAppTabHelper check and the few tests that I left "note to self" comments on.

    File chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc
    Line 231, Patchset 15 (Parent):TEST_F(TabLifecycleUnitTest, SetFocused) {
    Joe Mason . unresolved

    Note to self: check tests in this file.

    File chrome/browser/resource_coordinator/tab_manager_browsertest.cc
    Line 475, Patchset 15 (Parent): ProtectRecentlyUsedTabsFromUrgentDiscarding) {
    Joe Mason . unresolved

    Note to self: check this.

    File chrome/browser/resource_coordinator/test_lifecycle_unit.cc
    Line 71, Patchset 15 (Latest): performance_manager::PerformanceManager::GetGraph();
    Joe Mason . unresolved

    Nit: you can just use `page_node->GetGraph()` (which never returns null)

    Line 113, Patchset 15 (Latest): EXPECT_TRUE(find_result != failure_reasons.end());
    Joe Mason . unresolved

    Nit: prefer `EXPECT_TRUE(base::Contains(failure_reasons, failure_reason))`.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Vovo Yang
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
    Gerrit-Change-Number: 7129640
    Gerrit-PatchSet: 15
    Gerrit-Owner: Vovo Yang <vo...@chromium.org>
    Gerrit-Reviewer: Joe Mason <joenot...@google.com>
    Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
    Gerrit-Attention: Vovo Yang <vo...@chromium.org>
    Gerrit-Comment-Date: Tue, 18 Nov 2025 22:49:17 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Vovo Yang (Gerrit)

    unread,
    Nov 19, 2025, 1:16:52 AMNov 19
    to Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org
    Attention needed from Joe Mason

    Vovo Yang added 4 comments

    Patchset-level comments

    I'm very excited to reduce the duplication!

    I made a first pass at this. I still want to double-check the logic in TabLifecycleUnit::CanDiscard and make sure there are no important checks there missing from DiscardEligibilityPolicy, and go through the deleted tests and make sure there's test coverage for everything that's being removed.

    Joe Mason

    Found one missed check in CanDiscard. Still need to check the tests.

    Joe Mason

    Looks good except for the WebAppTabHelper check and the few tests that I left "note to self" comments on.

    Vovo Yang

    Added the WebAppTabHelper check in DiscardEligibilityPolicy::CanDiscard().

    File chrome/browser/resource_coordinator/tab_lifecycle_unit.cc
    Line 307, Patchset 15 (Parent): if (tab_helper && tab_helper->is_in_app_window()) {
    Joe Mason . resolved

    This check isn't in DiscardEligibilityPolicy::CanDiscard - it should be added there.

    Vovo Yang

    Added the web app check to DiscardEligibilityPolicy::CanDiscard().

    File chrome/browser/resource_coordinator/test_lifecycle_unit.cc
    Line 71, Patchset 15: performance_manager::PerformanceManager::GetGraph();
    Joe Mason . resolved

    Nit: you can just use `page_node->GetGraph()` (which never returns null)

    Vovo Yang

    Done

    Line 113, Patchset 15: EXPECT_TRUE(find_result != failure_reasons.end());
    Joe Mason . resolved

    Nit: prefer `EXPECT_TRUE(base::Contains(failure_reasons, failure_reason))`.

    Vovo Yang

    Done

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joe Mason
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
    Gerrit-Change-Number: 7129640
    Gerrit-PatchSet: 16
    Gerrit-Owner: Vovo Yang <vo...@chromium.org>
    Gerrit-Reviewer: Joe Mason <joenot...@google.com>
    Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
    Gerrit-Attention: Joe Mason <joenot...@google.com>
    Gerrit-Comment-Date: Wed, 19 Nov 2025 06:16:20 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Joe Mason (Gerrit)

    unread,
    Nov 19, 2025, 2:31:19 PMNov 19
    to Vovo Yang, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org
    Attention needed from Vovo Yang

    Joe Mason added 11 comments

    File chrome/browser/performance_manager/policies/discard_eligibility_policy_browsertest.cc
    Line 16, Patchset 21 (Latest):#include "testing/gtest/include/gtest/gtest.h"
    Joe Mason . unresolved

    Nit: please include the following headers for IWYU:

    ```
    <string>
    <string_view>
    <vector>

    base/memory/weak_ptr.h
    base/types/expected.h
    chrome/browser/performance_manager/policies/cannot_discard_reason.h
    chrome/browser/profiles/profile.h
    chrome/browser/ui/browser.h
    chrome/browser/ui/tabs/tab_strip_model.h
    components/performance_manager/public/graph/graph.h
    components/performance_manager/public/performance_manager.h
    components/webapps/common/web_app_id.h
    url/gurl.h
    content/public/browser/web_contents.h
    ```

    Line 51, Patchset 21 (Latest): ASSERT_EQ(apps::test::EnableLinkCapturingByUser(profile(), app_id),
    Joe Mason . resolved

    I recently had to fix quite a few flakes in WebApp tests that don't wait for all the different async steps, but AFAICT this test is doing everything right. (I didn't know about the EnableLinkCapturingByUser helper function - it would have saved me a lot of time.) Nice job!

    Line 64, Patchset 21 (Latest): // Wait for & get the web contents that was loaded.
    Joe Mason . unresolved

    Nit: I keep thinking the & here means "pointer". "...and get" would be clearer.

    Also I think this comment should go above the UrlLoadObserver?

    File chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc
    Line 231, Patchset 15 (Parent):TEST_F(TabLifecycleUnitTest, SetFocused) {
    Joe Mason . resolved

    Note to self: check tests in this file.

    Joe Mason

    Done

    Line 231, Patchset 21 (Parent):TEST_F(TabLifecycleUnitTest, SetFocused) {
    Joe Mason . resolved

    Confirmed: this is exercised by `PageDiscardingHelperBrowserTest.DiscardTabsWithOccludedWindow`

    Line 261, Patchset 21 (Parent):TEST_F(TabLifecycleUnitTest, SetFocusedSplit) {
    Joe Mason . unresolved

    I think we need to move this test into discard_eligibility_policy_unittest.cc or page_discarding_helper_unittest.cc/browsertest.cc.

    DiscardEligibilityPolicy doesn't include explicit split tab handling so we need test coverage.

    Line 373, Patchset 21 (Parent):TEST_F(TabLifecycleUnitTest, CannotDiscardCrashed) {
    Joe Mason . unresolved

    We still need a test for this. DiscardEligibilityPolicy doesn't explicitly check for crashed tabs, but a comment says "Don't discard tabs that don't have a main frame (..., crashed tab)." But we need test coverage to be sure the comment is correct.

    (Discarding a "crashed tab" would only be a minor regression, I think, so this could be a followup.)

    Line 383, Patchset 21 (Parent):TEST_F(TabLifecycleUnitTest, CannotDiscardActive) {
    Joe Mason . resolved

    Exercised by `PageDiscardingHelperBrowserTest.DiscardTabsWithOccludedWindow`.

    Line 404, Patchset 21 (Parent): LifecycleUnitDiscardReason::FROZEN_WITH_GROWING_MEMORY);
    Joe Mason . unresolved

    Please add `FROZEN_WITH_GROWING_MEMORY` tests to chrome/browser/performance_manager/policies/discard_eligibility_policy_unittest.cc (this specific one is covered by `DiscardEligibilityPolicyTest.TestCannotDiscardRecentlyVisiblePageUnlessExplicitlyRequested`)

    Line 459, Patchset 21 (Parent):TEST_F(TabLifecycleUnitTest, CannotDiscardVideoCapture) {
    Joe Mason . resolved

    The rest of these all have obvious counterparts in `DiscardEligibilityPolicyTest`

    File chrome/browser/resource_coordinator/tab_manager_browsertest.cc
    Line 475, Patchset 15 (Parent): ProtectRecentlyUsedTabsFromUrgentDiscarding) {
    Joe Mason . resolved

    Note to self: check this.

    Joe Mason

    I can't actually find any end-to-end browsertest that checks minimum time in background, but there's plenty of end-to-end coverage of foreground vs. background tabs. (eg. `PageDiscardingHelperBrowserTest.DiscardTabsWithOccludedWindow`) and there are unit tests. So losing this is probably fine.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Vovo Yang
    Submit Requirements:
    • requirement satisfiedCode-Coverage
    • requirement is not satisfiedCode-Owners
    • requirement is not satisfiedCode-Review
    • requirement is not satisfiedNo-Unresolved-Comments
    • requirement is not satisfiedReview-Enforcement
    Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
    Gerrit-MessageType: comment
    Gerrit-Project: chromium/src
    Gerrit-Branch: main
    Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
    Gerrit-Change-Number: 7129640
    Gerrit-PatchSet: 21
    Gerrit-Owner: Vovo Yang <vo...@chromium.org>
    Gerrit-Reviewer: Joe Mason <joenot...@google.com>
    Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
    Gerrit-Attention: Vovo Yang <vo...@chromium.org>
    Gerrit-Comment-Date: Wed, 19 Nov 2025 19:31:11 +0000
    satisfied_requirement
    unsatisfied_requirement
    open
    diffy

    Vovo Yang (Gerrit)

    unread,
    Nov 24, 2025, 6:24:26 AMNov 24
    to Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org
    Attention needed from Joe Mason

    Vovo Yang voted and added 5 comments

    Votes added by Vovo Yang

    Commit-Queue+1

    5 comments

    File chrome/browser/performance_manager/policies/discard_eligibility_policy_browsertest.cc
    Line 16, Patchset 21:#include "testing/gtest/include/gtest/gtest.h"
    Joe Mason . resolved

    Nit: please include the following headers for IWYU:

    ```
    <string>
    <string_view>
    <vector>

    base/memory/weak_ptr.h
    base/types/expected.h
    chrome/browser/performance_manager/policies/cannot_discard_reason.h
    chrome/browser/profiles/profile.h
    chrome/browser/ui/browser.h
    chrome/browser/ui/tabs/tab_strip_model.h
    components/performance_manager/public/graph/graph.h
    components/performance_manager/public/performance_manager.h
    components/webapps/common/web_app_id.h
    url/gurl.h
    content/public/browser/web_contents.h
    ```

    Vovo Yang

    Done

    Line 64, Patchset 21: // Wait for & get the web contents that was loaded.
    Joe Mason . resolved

    Nit: I keep thinking the & here means "pointer". "...and get" would be clearer.

    Also I think this comment should go above the UrlLoadObserver?

    Vovo Yang

    Done

    File chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc
    Line 261, Patchset 21 (Parent):TEST_F(TabLifecycleUnitTest, SetFocusedSplit) {
    Joe Mason . resolved

    I think we need to move this test into discard_eligibility_policy_unittest.cc or page_discarding_helper_unittest.cc/browsertest.cc.

    DiscardEligibilityPolicy doesn't include explicit split tab handling so we need test coverage.

    Vovo Yang

    Added test DiscardEligibilityPolicyBrowserTest::CannotDiscardVisibleInSplit to
    replaces TabLifecycleUnitTest::SetFocusedSplit.

    Line 373, Patchset 21 (Parent):TEST_F(TabLifecycleUnitTest, CannotDiscardCrashed) {
    Joe Mason . resolved

    We still need a test for this. DiscardEligibilityPolicy doesn't explicitly check for crashed tabs, but a comment says "Don't discard tabs that don't have a main frame (..., crashed tab)." But we need test coverage to be sure the comment is correct.

    (Discarding a "crashed tab" would only be a minor regression, I think, so this could be a followup.)

    Vovo Yang

    This CL is already quite large. I think it's better to add the test in another CL. I added a TODO(crbug.com/463291982) in chrome/browser/performance_manager/policies/discard_eligibility_policy.cc comments.

    Line 404, Patchset 21 (Parent): LifecycleUnitDiscardReason::FROZEN_WITH_GROWING_MEMORY);
    Joe Mason . resolved

    Please add `FROZEN_WITH_GROWING_MEMORY` tests to chrome/browser/performance_manager/policies/discard_eligibility_policy_unittest.cc (this specific one is covered by `DiscardEligibilityPolicyTest.TestCannotDiscardRecentlyVisiblePageUnlessExplicitlyRequested`)

    Vovo Yang

    Added FROZEN_WITH_GROWING_MEMORY and SUGGESTED checks in chrome/browser/performance_manager/policies/discard_eligibility_policy_unittest.cc.

    Open in Gerrit

    Related details

    Attention is currently required from:
    • Joe Mason
    Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement is not satisfiedCode-Owners
      • requirement is not satisfiedCode-Review
      • requirement is not satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
      Gerrit-Change-Number: 7129640
      Gerrit-PatchSet: 26
      Gerrit-Owner: Vovo Yang <vo...@chromium.org>
      Gerrit-Reviewer: Joe Mason <joenot...@google.com>
      Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
      Gerrit-Attention: Joe Mason <joenot...@google.com>
      Gerrit-Comment-Date: Mon, 24 Nov 2025 11:23:55 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      Comment-In-Reply-To: Joe Mason <joenot...@google.com>
      satisfied_requirement
      unsatisfied_requirement
      open
      diffy

      Joe Mason (Gerrit)

      unread,
      Nov 25, 2025, 4:48:10 PMNov 25
      to Vovo Yang, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org
      Attention needed from Vovo Yang

      Joe Mason voted and added 1 comment

      Votes added by Joe Mason

      Code-Review+1

      1 comment

      Patchset-level comments
      File-level comment, Patchset 26 (Latest):
      Joe Mason . resolved

      Thanks for all the hard work on this!

      Open in Gerrit

      Related details

      Attention is currently required from:
      • Vovo Yang
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
      Gerrit-Change-Number: 7129640
      Gerrit-PatchSet: 26
      Gerrit-Owner: Vovo Yang <vo...@chromium.org>
      Gerrit-Reviewer: Joe Mason <joenot...@google.com>
      Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
      Gerrit-Attention: Vovo Yang <vo...@chromium.org>
      Gerrit-Comment-Date: Tue, 25 Nov 2025 21:48:02 +0000
      Gerrit-HasComments: Yes
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Vovo Yang (Gerrit)

      unread,
      Nov 25, 2025, 9:40:29 PMNov 25
      to Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org

      Vovo Yang voted Commit-Queue+2

      Commit-Queue+2
      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
      Gerrit-Change-Number: 7129640
      Gerrit-PatchSet: 28
      Gerrit-Owner: Vovo Yang <vo...@chromium.org>
      Gerrit-Reviewer: Joe Mason <joenot...@google.com>
      Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
      Gerrit-Comment-Date: Wed, 26 Nov 2025 02:39:54 +0000
      Gerrit-HasComments: No
      Gerrit-Has-Labels: Yes
      satisfied_requirement
      open
      diffy

      Chromium LUCI CQ (Gerrit)

      unread,
      Nov 25, 2025, 9:42:49 PMNov 25
      to Vovo Yang, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org

      Chromium LUCI CQ submitted the change with unreviewed changes

      Unreviewed changes

      26 is the latest approved patch-set.
      The change was submitted with unreviewed changes in the following files:

      ```
      The name of the file: chrome/browser/resource_coordinator/tab_manager_browsertest.cc
      Insertions: 50, Deletions: 0.

      The diff is too large to show. Please review the diff.
      ```

      Change information

      Commit message:
      [resource coordinator] TabManager discards via PageDiscardingHelper

      The TabManager and TabLifecycleUnit code to select the page to discard
      should be replaced by PageDiscardingHelper::DiscardAPage.

      Modified some browser tests because of the difference between
      TabLifecycleUnit::CanDiscard and DiscardEligibilityPolicy::CanDiscard.
      Some DiscardEligibilityPolicy::CanDiscard differences:
      1. It always returns eligible for external discards. So a few tests are
      modified to use urgent discard instead of external discard.
      2. ScopedSetClocksForTesting doesn't work. Passing
      minimum_time_in_background_to_discard = 0 instead.
      3. Discarding a tab with file:// url is not eligible.

      Some subtests of TabLifecycleUnitTest are removed:

      DiscardEligibilityPolicyTest::TestCannotDiscardVisiblePage replaces
      SetFocused and SetFocusedSplit in TabLifecycleUnitTest. In
      DiscardEligibilityPolicy, all visible pages are protected instead of
      only the focused page.

      DiscardEligibilityPolicyTest::TestCannotDiscardPageWithoutMainFrame
      replaces TabLifecycleUnitTest::CannotDiscardCrashed.
      DiscardEligibilityPolicy::CanDiscard returns kDisallowed for tab without
      a main frame, which includes the crashed tab case.

      DiscardEligibilityPolicyTest::TestCannotDiscardVisiblePage replaces
      TabLifecycleUnitTest::CannotDiscardActive. In DiscardEligibilityPolicy,
      all visible pages are protected.

      TabLifecycleUnit::CanDiscard returns false when the discard count is not
      zero. It's replaced by the DiscardAttemptMarker mechanism in
      DiscardEligibilityPolicy. So TabLifecycleUnitTest::UrgentDiscardProtections
      is replaced by
      DiscardEligibilityPolicyTest::TestCannotDiscardPageWithDiscardAttemptMarker.

      DiscardEligibilityPolicyTest::TestCannotDiscardPageCapturingVideo
      replaces TabLifecycleUnitTest::CannotDiscardVideoCapture.

      DiscardEligibilityPolicyTest::TestCannotDiscardPageWithFormInteractions
      replaces TabLifecycleUnitTest::CannotDiscardHasFormInteractions.

      DiscardEligibilityPolicyTest::TestCannotDiscardPageCapturingDisplay
      replaces TabLifecycleUnitTest::CannotDiscardDesktopCapture.

      DiscardEligibilityPolicyTest::TestCannotDiscardRecentlyAudiblePage
      replaces TabLifecycleUnitTest::CannotDiscardRecentlyAudible.

      DiscardEligibilityPolicyTest::TestCanDiscardNeverAudiblePage replaces
      TabLifecycleUnitTest::CanDiscardNeverAudibleTab.

      DiscardEligibilityPolicyTest::TestCannotDiscardPdf replaces
      TabLifecycleUnitTest::CannotDiscardPDF.

      DiscardEligibilityPolicyBrowserTest::CannotDiscardVisibleInSplit
      replaces TabLifecycleUnitTest::SetFocusedSplit.
      Bug: 394889323
      Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
      Commit-Queue: Vovo Yang <vo...@chromium.org>
      Reviewed-by: Joe Mason <joenot...@google.com>
      Cr-Commit-Position: refs/heads/main@{#1550197}
      Files:
      • M chrome/browser/BUILD.gn
      • M chrome/browser/performance_manager/policies/cannot_discard_reason.cc
      • M chrome/browser/performance_manager/policies/cannot_discard_reason.h
      • M chrome/browser/performance_manager/policies/discard_eligibility_policy.cc
      • A chrome/browser/performance_manager/policies/discard_eligibility_policy_browsertest.cc
      • M chrome/browser/performance_manager/policies/discard_eligibility_policy_unittest.cc
      • M chrome/browser/performance_manager/policies/page_discarding_helper.cc
      • M chrome/browser/performance_manager/policies/page_discarding_helper.h
      • M chrome/browser/performance_manager/policies/page_discarding_helper_browsertest.cc
      • M chrome/browser/performance_manager/policies/page_discarding_helper_unittest.cc
      • M chrome/browser/performance_manager/test_support/page_discarding_utils.cc
      • M chrome/browser/performance_manager/test_support/page_discarding_utils.h
      • M chrome/browser/resource_coordinator/BUILD.gn
      • D chrome/browser/resource_coordinator/decision_details.cc
      • D chrome/browser/resource_coordinator/decision_details.h
      • D chrome/browser/resource_coordinator/decision_details_unittest.cc
      • M chrome/browser/resource_coordinator/lifecycle_unit.h
      • M chrome/browser/resource_coordinator/tab_lifecycle_unit.cc
      • M chrome/browser/resource_coordinator/tab_lifecycle_unit.h
      • M chrome/browser/resource_coordinator/tab_lifecycle_unit_source_unittest.cc
      • M chrome/browser/resource_coordinator/tab_lifecycle_unit_unittest.cc
      • M chrome/browser/resource_coordinator/tab_manager.cc
      • M chrome/browser/resource_coordinator/tab_manager.h
      • M chrome/browser/resource_coordinator/tab_manager_browsertest.cc
      • M chrome/browser/resource_coordinator/tab_manager_unittest.cc
      • M chrome/browser/resource_coordinator/test_lifecycle_unit.cc
      • M chrome/browser/resource_coordinator/test_lifecycle_unit.h
      • M chrome/test/BUILD.gn
      Change size: XL
      Delta: 28 files changed, 767 insertions(+), 1991 deletions(-)
      Branch: refs/heads/main
      Submit Requirements:
      • requirement satisfiedCode-Review: +1 by Joe Mason
      Open in Gerrit
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: merged
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
      Gerrit-Change-Number: 7129640
      Gerrit-PatchSet: 29
      Gerrit-Owner: Vovo Yang <vo...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Joe Mason <joenot...@google.com>
      Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
      open
      diffy
      satisfied_requirement

      Vovo Yang (Gerrit)

      unread,
      Nov 25, 2025, 10:18:13 PMNov 25
      to Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org

      Vovo Yang added 1 comment

      Patchset-level comments
      Joe Mason . resolved

      Thanks for all the hard work on this!

      Vovo Yang

      Thanks for your review and catching the missing logic in DiscardEligibilityPolicy::CanDiscard().

      Open in Gerrit

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: comment
      Gerrit-Project: chromium/src
      Gerrit-Branch: main
      Gerrit-Change-Id: Ie433615347033d4f0563d7e44fc53a67a29e7c14
      Gerrit-Change-Number: 7129640
      Gerrit-PatchSet: 29
      Gerrit-Owner: Vovo Yang <vo...@chromium.org>
      Gerrit-Reviewer: Chromium LUCI CQ <chromiu...@luci-project-accounts.iam.gserviceaccount.com>
      Gerrit-Reviewer: Joe Mason <joenot...@google.com>
      Gerrit-Reviewer: Vovo Yang <vo...@chromium.org>
      Gerrit-Comment-Date: Wed, 26 Nov 2025 03:17:49 +0000
      satisfied_requirement
      open
      diffy

      Lingqi Chi (Gerrit)

      unread,
      Nov 26, 2025, 12:19:51 AMNov 26
      to Vovo Yang, Chromium LUCI CQ, chromium...@chromium.org, chrome-gr...@chromium.org, performance-m...@chromium.org

      Lingqi Chi has created a revert of this change

      Related details

      Attention set is empty
      Submit Requirements:
      • requirement satisfiedCode-Coverage
      • requirement satisfiedCode-Owners
      • requirement satisfiedCode-Review
      • requirement satisfiedReview-Enforcement
      Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
      Gerrit-MessageType: revert
      satisfied_requirement
      open
      diffy
      Reply all
      Reply to author
      Forward
      0 new messages