Skip to content

Cherry pick PR #8050 to main: Reland "feat(cc): Disable resource pool reuse to reduce memory #7853"#11520

Open
niranjanyardi wants to merge 2 commits into
youtube:mainfrom
niranjanyardi:cp-8050-to-main
Open

Cherry pick PR #8050 to main: Reland "feat(cc): Disable resource pool reuse to reduce memory #7853"#11520
niranjanyardi wants to merge 2 commits into
youtube:mainfrom
niranjanyardi:cp-8050-to-main

Conversation

@niranjanyardi

@niranjanyardi niranjanyardi commented Jul 23, 2026

Copy link
Copy Markdown
Member

This cherry-picks PR #8050 (and related test updates) to main, resolving merge conflicts in cc/resources/resource_pool.cc.


Original PR #8050 Description

This relands PR# 7853, which was reverted due to breaking PartialRasterTileManagerTest.PartialRasterSuccessfullyEnabled and PartialRasterTileManagerTest.PartialTileImageDecode on Cobalt.

This reland re-introduces the test refactoring but disables the failing tests specifically for Cobalt builds using #if BUILDFLAG(IS_COBALT) GTEST_SKIP(). This allows the valuable test improvements to be landed without affecting the Cobalt build.

Original PR description---------------------------------------

By marking resources with 'avoid_reuse', they are freed immediately after use instead of being kept in the resource pool. This ensures tiles are rastered on-demand.

This change significantly reduces the tile_memory usage, ~20M when navigating fast through videos, with no obvious negative performance impact.

Original PR: #7853

Bug: b/424591313

@github-actions

Copy link
Copy Markdown
Contributor

🤖 Gemini Suggested Commit Message


cobalt: Skip unsupported cc resource tests

Cobalt does not support resource reuse or partial tile rasterization
within its compositor implementation. This divergence from standard
Chromium behavior causes several unit tests in the cc module to fail.

Skip these test cases when building for Cobalt to ensure the test suite
accurately reflects Cobalt's compositor architecture and maintains CI
stability.

Bug: 8050

💡 Pro Tips for a Better Commit Message:

  1. Influence the Result: Want to change the output? You can write custom prompts or instructions directly in the Pull Request description. The model uses that text to generate the message.
  2. Re-run the Generator: Post a comment with: /generate-commit-message

@niranjanyardi niranjanyardi changed the title Cp 8050 to main Cherry pick PR #8050 to main: Reland "feat(cc): Disable resource pool reuse to reduce memory #7853" Jul 23, 2026
@niranjanyardi
niranjanyardi marked this pull request as ready for review July 23, 2026 21:48
sherryzy added 2 commits July 23, 2026 14:48
…e#7853" (youtube#8050)

This relands PR# 7853, which was reverted due to breaking
`PartialRasterTileManagerTest.PartialRasterSuccessfullyEnabled` and
`PartialRasterTileManagerTest.PartialTileImageDecode` on Cobalt.

This reland re-introduces the test refactoring but disables the failing
tests specifically for Cobalt builds using
`#if BUILDFLAG(IS_COBALT) GTEST_SKIP()`. This allows the valuable
test improvements to be landed without affecting the Cobalt build.

Original PR description---------------------------------------

By marking resources with 'avoid_reuse', they are freed immediately
after use instead of being kept in the resource pool. This ensures tiles
are rastered on-demand.

This change significantly reduces the tile_memory usage, ~20M when
navigating fast through videos, with no obvious negative performance
impact.

Original PR: youtube#7853

Bug: 424591313
(cherry picked from commit 8ec6d83)

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request disables several unit tests in resource_pool_unittest.cc, tile_manager_unittest.cc, and layer_tree_host_impl_unittest.cc when building for Cobalt by using GTEST_SKIP(). The reviewer recommended simplifying the preprocessor directives by only wrapping the GTEST_SKIP() call within the #if block, rather than enclosing the entire remaining test body in an #else block, which reduces unnecessary boilerplate and aligns with clean coding standards.

Comment on lines +92 to +94
#if BUILDFLAG(IS_COBALT)
GTEST_SKIP() << "Cobalt doesn't support resource reuse.";
#else

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Since GTEST_SKIP() internally behaves like a return statement, any code following it in the same test function will not be executed. Therefore, wrapping the entire test body in #else and #endif is unnecessary and adds preprocessor boilerplate.

You can simplify this pattern across all modified tests in this PR (including those in cc/resources/resource_pool_unittest.cc, cc/tiles/tile_manager_unittest.cc, and cc/trees/layer_tree_host_impl_unittest.cc) by only wrapping the GTEST_SKIP() call in the #if block, leaving the rest of the test body unwrapped.

For example:

TEST_F(ResourcePoolTest, EventuallyEvictAndFlush) {
#if BUILDFLAG(IS_COBALT)
  GTEST_SKIP() << "Cobalt doesn't support resource reuse.";
#endif
  gfx::Size size(100, 100);
  viz::SharedImageFormat format = viz::SinglePlaneFormat::kRGBA_8888;
  gfx::ColorSpace color_space = gfx::ColorSpace::CreateSRGB();
  ...
}

This significantly improves readability and maintainability by avoiding nested preprocessor blocks and reducing the diff size.

References
  1. Adhere to upstream Chromium style guides which favor clean, readable code with minimal preprocessor noise. Avoid wrapping entire function bodies in preprocessor conditionals when early returns or macros like GTEST_SKIP() can be used directly. (link)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants