Repository navigation
Change default cache extent - #195722
Change default cache extent#195722LouiseHsu wants to merge 6 commits into
Conversation
Co-authored-by: Chun-Heng Tai <[email protected]>
|
This pull request contains changes to Material or Cupertino, which are currently frozen in this repository. Changes should be made in Please refer to #188444 for instructions. |
chunhtai
left a comment
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
nonblocking, but let me see if I can remove this deprecated api now
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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),| set scrollCacheExtent(ScrollCacheExtent? value) { | ||
| final ScrollCacheExtent effectiveValue = | ||
| value ?? const ScrollCacheExtent.pixels(RenderAbstractViewport.defaultCacheExtent); | ||
| value ?? RenderAbstractViewport.kDefaultScrollCacheExtent; | ||
| if (effectiveValue == _scrollCacheExtent) { | ||
| return; | ||
| } |
There was a problem hiding this comment.
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;| return; | ||
| } | ||
| if (value == null) { | ||
| _scrollCacheExtent = const ScrollCacheExtent.pixels( | ||
| RenderAbstractViewport.defaultCacheExtent, | ||
| ); | ||
| _scrollCacheExtent = RenderAbstractViewport.kDefaultScrollCacheExtent; | ||
| } else { | ||
| _scrollCacheExtent = value; | ||
| } |
There was a problem hiding this comment.
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;
}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.
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.
…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
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.
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).
…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.
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
///).