Skip to content

Change default cache extent - #195722

Open
LouiseHsu wants to merge 6 commits into
flutter:masterfrom
LouiseHsu:cache-extent-182905
Open

LouiseHsu wants to merge 6 commits into
flutter:masterfrom
LouiseHsu:cache-extent-182905

Conversation

@LouiseHsu

@LouiseHsu LouiseHsu commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

This is the replacement PR for #182905

This needs to land before #193540, which needs to land before this fix for a P1 customer bug #193384

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant in-code documentation (doc comments with ///).
  • If this PR introduces a new feature or capability, I created and linked a website documentation issue or PR in [flutter/website] (or verified none is needed).
  • I added new tests to check the change I am making, or this PR is [test-exempt].
  • I followed the [breaking change policy] and added [Data Driven Fixes] where supported.
  • All existing and new tests are passing.

Co-authored-by: Chun-Heng Tai <[email protected]>
@github-actions

Copy link
Copy Markdown

This pull request contains changes to Material or Cupertino, which are currently frozen in this repository.

Changes should be made in material_ui and/or cupertino_ui in the flutter/packages repository.

Please refer to #188444 for instructions.

@LouiseHsu LouiseHsu added the CICD Run CI/CD label Oct 30, 2026
@github-actions github-actions Bot added framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) f: scrolling Viewports, list views, slivers, etc. and removed CICD Run CI/CD labels Oct 30, 2026

@chunhtai chunhtai 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.

LGTM, though we may need to fix the test in material_ui first

'This feature was deprecated after v3.41.0-0.0.pre.',
)
CacheExtentStyle cacheExtentStyle = CacheExtentStyle.pixel,
CacheExtentStyle? cacheExtentStyle,

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.

nonblocking, but let me see if I can remove this deprecated api now

@LouiseHsu
LouiseHsu marked this pull request as ready for review November 10, 2026 03:00

@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 transitions the default cache extent for viewports from a fixed pixel value (250.0) to a viewport-based fraction (0.8), updating RenderSemanticsGestureHandler, RenderViewportBase, and RenderTwoDimensionalViewport along with associated tests. The review feedback identifies two key issues: first, the new constructor assertions are overly restrictive and will cause regressions when cacheExtentStyle is set to pixel while cacheExtent is null; second, the _hasSetCacheExtentStyle flag is not updated when scrollCacheExtent is set directly, which can lead to incorrect style resolution if the deprecated cacheExtent is subsequently modified.

this._clipBehavior = Clip.hardEdge,
}) : assert(axisDirectionToAxis(axisDirection) != axisDirectionToAxis(crossAxisDirection)),
assert(cacheExtent != null || cacheExtentStyle == CacheExtentStyle.pixel),
assert(cacheExtent != null || cacheExtentStyle == null),

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.

high

This assertion is too restrictive and will cause a regression. If a developer explicitly sets cacheExtentStyle to CacheExtentStyle.pixel but leaves cacheExtent as null (relying on the default pixel cache extent), this assertion will fail. Instead, we should only assert that cacheExtent is non-null when cacheExtentStyle is CacheExtentStyle.viewport.

       assert(cacheExtent != null || cacheExtentStyle != CacheExtentStyle.viewport),

horizontalAxisDirection == AxisDirection.right,
'TwoDimensionalViewport.horizontalAxisDirection is not Axis.horizontal.',
),
assert(cacheExtentStyle == null || cacheExtent != null),

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.

high

This assertion is too restrictive and will cause a regression. If a developer explicitly sets cacheExtentStyle to CacheExtentStyle.pixel but leaves cacheExtent as null, this assertion will fail, whereas previously it would silently fall back to the default cache extent. Instead, we should only assert that cacheExtent is non-null when cacheExtentStyle is CacheExtentStyle.viewport.

       assert(cacheExtentStyle != CacheExtentStyle.viewport || cacheExtent != null),

Comment on lines 629 to 634
set scrollCacheExtent(ScrollCacheExtent? value) {
final ScrollCacheExtent effectiveValue =
value ?? const ScrollCacheExtent.pixels(RenderAbstractViewport.defaultCacheExtent);
value ?? RenderAbstractViewport.kDefaultScrollCacheExtent;
if (effectiveValue == _scrollCacheExtent) {
return;
}

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

When scrollCacheExtent is explicitly set, we should update _hasSetCacheExtentStyle to reflect whether a custom style has been configured. This ensures that if the developer later sets the deprecated cacheExtent property, the correct style is preserved or resolved.

  set scrollCacheExtent(ScrollCacheExtent? value) {
    final ScrollCacheExtent effectiveValue =
        value ?? RenderAbstractViewport.kDefaultScrollCacheExtent;
    if (effectiveValue == _scrollCacheExtent) {
      return;
    }
    _hasSetCacheExtentStyle = value != null;

Comment on lines 772 to 778
return;
}
if (value == null) {
_scrollCacheExtent = const ScrollCacheExtent.pixels(
RenderAbstractViewport.defaultCacheExtent,
);
_scrollCacheExtent = RenderAbstractViewport.kDefaultScrollCacheExtent;
} else {
_scrollCacheExtent = value;
}

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

When scrollCacheExtent is explicitly set, we should update _hasSetCacheExtentStyle to reflect whether a custom style has been configured. This ensures that if the developer later sets the deprecated cacheExtent property, the correct style is preserved or resolved.

      return;
    }
    _hasSetCacheExtentStyle = value != null;
    if (value == null) {
      _scrollCacheExtent = RenderAbstractViewport.kDefaultScrollCacheExtent;
    } else {
      _scrollCacheExtent = value;
    }

LouiseHsu added a commit to LouiseHsu/packages that referenced this pull request Nov 20, 2026
flutter/flutter#195722 changes the default viewport cache extent from 250
pixels to 0.8 x the viewport extent. A few material_ui tests depend on
exactly which off-screen children are built under the old default. Make
them independent of the default (pinning scrollCacheExtent where the test
checks exact semantics/children, and lengthening the list in the InkWell
keep-alive test) so they pass on both stable and master, before and after
that change lands.

Test-only change.
LouiseHsu added a commit to LouiseHsu/packages that referenced this pull request Nov 20, 2026
Per review: give the affected tests the new default
(ScrollCacheExtent.viewport(0.8)) and update their expectations to match
flutter/flutter#195722, with a TODO to remove the pin once the minimum
Flutter SDK includes the new default.
auto-submit Bot pushed a commit to flutter/packages that referenced this pull request Nov 21, 2026
…nt (#13715)

flutter/flutter#195722 changes the default viewport cache extent from 250 pixels to 0.8 x the viewport extent. A few material_ui tests depend on exactly which off-screen children are built under the old default. Make them independent of the default (pinning scrollCacheExtent where the test checks exact semantics/children, and lengthening the list in the InkWell keep-alive test) so they pass on both stable and master, before and after that change lands.

This is test only change.

## Pre-Review Checklist
auto-submit Bot pushed a commit to flutter/tests that referenced this pull request Nov 24, 2026
Picks up flutter/packages#13715, which updates material_ui tests for the new default scroll cache extent in flutter/flutter#195722.

Next up - I shall bump dev/customer_testing/tests.version in flutter/flutter. flutter/flutter#197266

<!--
Thanks for filing a pull request!
Reviewers are typically assigned within a week of filing a request.
To learn more about code review, see our documentation on Tree Hygiene: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md
-->

> [!IMPORTANT]
> This repository is a testing suite that contains references to tests (in the `registry` directory) that are run with every commit to Flutter
> to verify that no breaking changes have been introduced (in the "customer_testing" shards). Your merged PR is _not_ automatically run in the
> Flutter CI tree.
>
> After merging this PR, you must send another PR to flutter/flutter updating `dev/customer_testing/tests.version` in that repo with the latest git commit SHA of the flutter/test repo.
>
> See <flutter/flutter#162048> for details.
LouiseHsu added a commit to LouiseHsu/flutter that referenced this pull request Nov 24, 2026
Picks up flutter/tests#513, which bumps flutter/packages to include
flutter/packages#13715 (material_ui tests updated for the new default
scroll cache extent in flutter#195722).
tyotyo pushed a commit to tyotyo/flutter that referenced this pull request Nov 25, 2026
…lutter#197266)

Picks up flutter/tests change that bumps flutter/packages to include
flutter/packages#13715 (material_ui tests updated for the new default
scroll cache extent in flutter#195722).

Should land after flutter/tests#513
## Pre-launch Checklist

- [x] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [x] I read the [AI contribution guidelines] and understand my
responsibilities, or I am not using AI tools.
- [x] I read the [Tree Hygiene] wiki page, which explains my
responsibilities.
- [x] I read and followed the [Flutter Style Guide], including [Features
we expect every widget to implement].
- [x] I signed the [CLA].
- [x] I listed at least one issue that this PR fixes in the description
above.
- [x] I updated/added relevant in-code documentation (doc comments with
`///`).
- [x] If this PR introduces a new feature or capability, I created and
linked a website documentation issue or PR in [flutter/website] (or
verified none is needed).
- [x] I added new tests to check the change I am making, or this PR is
[test-exempt].
- [x] I followed the [breaking change policy] and added [Data Driven
Fixes] where supported.
- [x] All existing and new tests are passing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: accessibility Accessibility, e.g. VoiceOver or TalkBack. (aka a11y) CICD Run CI/CD f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels. p: material_ui material_ui package in flutter/packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants