Skip to content

Conversation

@manu-sncf
Copy link
Contributor

Fix #175759

The fix involves using the same logic for cache calculation on RenderViewport.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • 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 documentation (doc comments with ///).
  • 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.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Sep 22, 2025
Copy link
Contributor

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

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 fixes an issue with SliverMainAxisGroup.cacheOrigin by adopting the same cache calculation logic used in RenderViewport. The changes in sliver_group.dart appear to correctly implement this more robust logic for handling cache origin and extent for child slivers. The new test case in sliver_main_axis_group_test.dart effectively validates this fix. I've added a couple of suggestions to improve floating-point precision handling for consistency within the class.

constraints.remainingCacheExtent -
calculateCacheOffset(constraints, from: 0.0, to: scrollOffset),
),
remainingCacheExtent: math.max(0.0, remainingCacheExtent + cacheExtentCorrection),
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

For consistency with other calculations in this file that deal with extents, consider wrapping the remainingCacheExtent calculation with _fixPrecisionError to avoid potential floating-point inaccuracies near zero. This would align it with how overlap and remainingPaintExtent are handled.

          remainingCacheExtent: math.max(0.0, _fixPrecisionError(remainingCacheExtent + cacheExtentCorrection)),

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

maxScrollObstructionExtent += childLayoutGeometry.maxScrollObstructionExtent;
paintOffset = math.max(childPaintOffset + childLayoutGeometry.paintExtent, paintOffset);
if (childLayoutGeometry.cacheExtent != 0.0) {
remainingCacheExtent -= childLayoutGeometry.cacheExtent - cacheExtentCorrection;
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

To prevent potential floating-point precision issues, which can be tricky with extent calculations, consider wrapping this calculation in _fixPrecisionError. This would be consistent with how other extent subtractions are handled in this class.

        remainingCacheExtent = _fixPrecisionError(remainingCacheExtent - (childLayoutGeometry.cacheExtent - cacheExtentCorrection));

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@manu-sncf manu-sncf force-pushed the fix_cache_origin branch 2 times, most recently from 834b687 to 2169642 Compare September 23, 2025 16:51
@manu-sncf
Copy link
Contributor Author

Hi @Renzo-Olivares, just bumping this PR for your review. Happy to help if anything is unclear.

@Renzo-Olivares
Copy link
Contributor

@manu-sncf, thank you for bumping this and I appreciate your patience. I'll take a look this week.

Copy link
Contributor

@Renzo-Olivares Renzo-Olivares left a comment

Choose a reason for hiding this comment

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

LGTM, thank you for the fix!

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

I think this looks fine, just some question

);

final double childScrollOffset = math.max(0.0, constraints.scrollOffset - scrollOffset);
final double correctedCacheOrigin = math.max(cacheOrigin, -childScrollOffset);
Copy link
Contributor

Choose a reason for hiding this comment

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

is there a case this will be bounded to -childScrollOffset ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think so. This case only handles a double-precision issue to prevent childScrollOffset from being less than cacheOrigin.

Copy link
Contributor

@chunhtai chunhtai left a comment

Choose a reason for hiding this comment

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

LGTM

@chunhtai chunhtai added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 21, 2025
@auto-submit auto-submit bot added this pull request to the merge queue Oct 21, 2025
Merged via the queue into flutter:master with commit 2e861f3 Oct 21, 2025
76 checks passed
@flutter-dashboard flutter-dashboard bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 21, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 21, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 22, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 22, 2025
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Oct 22, 2025
auto-submit bot pushed a commit to flutter/packages that referenced this pull request Oct 22, 2025
Roll Flutter from 2d3416713fe8 to 75004a639ae4 (39 revisions)

flutter/flutter@2d34167...75004a6

2025-10-22 [email protected] [Impeller] Add the paint color to the key of the text shadow cache (flutter/flutter#177140)
2025-10-22 [email protected] Roll Skia from 96e75ca8e24b to 928b5cf727c1 (2 revisions) (flutter/flutter#177387)
2025-10-22 [email protected] Roll reclient to version 185 (flutter/flutter#177293)
2025-10-22 [email protected] Roll Skia from b157f6b95f95 to 96e75ca8e24b (4 revisions) (flutter/flutter#177366)
2025-10-22 [email protected] Fix InputDatePickerFormField does not inherit local InputDecorationTheme (flutter/flutter#177090)
2025-10-22 [email protected] Roll Skia from 2c6162c977db to b157f6b95f95 (2 revisions) (flutter/flutter#177362)
2025-10-22 [email protected] Roll Skia from cadf8e7e6fca to 2c6162c977db (4 revisions) (flutter/flutter#177359)
2025-10-22 [email protected] Cleanup after -news_toolkit, +google_fonts, and some leftover `team-go_router` (flutter/flutter#176841)
2025-10-21 [email protected] don't break sheet's snap from physics (flutter/flutter#171157)
2025-10-21 [email protected] Roll Dart SDK from 913c2ae1b367 to c23010c4f9e6 (8 revisions) (flutter/flutter#177348)
2025-10-21 [email protected] Fix typo in comment about screen availibility  (flutter/flutter#177168)
2025-10-21 [email protected] Fix(AnimatedScrollView): exclude outgoing items in removeAllItems (flutter/flutter#176452)
2025-10-21 [email protected] Enable deprecated_member_use_from_same_package for all packages containing tests of Dart fixes defined within the package (flutter/flutter#177341)
2025-10-21 [email protected] Roll Skia from 19bff385f7e8 to cadf8e7e6fca (3 revisions) (flutter/flutter#177331)
2025-10-21 [email protected] Revert "[Android 16] Update `android_engine_vulkan_tests` to Test Against SDK 36 Emulator" (flutter/flutter#177292)
2025-10-21 [email protected] Fix SliverMainAxisGroup.cacheOrigin (flutter/flutter#175760)
2025-10-21 [email protected] Roll Skia from 75c756e029c9 to 19bff385f7e8 (3 revisions) (flutter/flutter#177316)
2025-10-21 [email protected] Fix typo in overlay.dart documentation comment (flutter/flutter#176612)
2025-10-21 [email protected] [ Tool ] Output DTD URI for Flutter web applications (flutter/flutter#177310)
2025-10-21 [email protected] Roll Skia from 982988b472a4 to 75c756e029c9 (1 revision) (flutter/flutter#177305)
2025-10-21 [email protected] Roll Skia from 42ff13a91c80 to 982988b472a4 (8 revisions) (flutter/flutter#177300)
2025-10-21 [email protected] Fix DateRangePickerDialog does not inherit local InputDecorationTheme (flutter/flutter#177086)
2025-10-21 [email protected] Remove references to dart:_js_annotations (flutter/flutter#176698)
2025-10-20 [email protected] Make `FlutterSceneLifeCycleProvider.sceneLifeCycleDelegate` readonly (flutter/flutter#177240)
2025-10-20 [email protected] Make sure that a CupertinoDesktopTextSelectionToolbar doesn't crash i… (flutter/flutter#173964)
2025-10-20 [email protected] Make sure that a BottomSheet doesn't crash in 0x0 environment (flutter/flutter#172229)
2025-10-20 [email protected] Move the Fuchsia SDK to //third_party/fuchsia-sdk (flutter/flutter#177118)
2025-10-20 [email protected] Roll Skia from 641994569415 to 42ff13a91c80 (8 revisions) (flutter/flutter#177283)
2025-10-20 [email protected] Make sure that a NavigationDrawer doesn't crash in 0x0 environment (flutter/flutter#176951)
2025-10-20 [email protected] Fix ink features painting in TabBar. (flutter/flutter#177155)
2025-10-20 [email protected] Make sure that SimpleDialog and SimpleDialogOption do not crash in 0x0 environment (flutter/flutter#174229)
2025-10-20 [email protected] Fix ink features painting in YearPicker. (flutter/flutter#177014)
2025-10-20 [email protected] Update `image.error_builder.0.dart` to replace the emoji with some text  (flutter/flutter#176886)
2025-10-20 [email protected] Roll Skia from ed4294faecde to 641994569415 (4 revisions) (flutter/flutter#177264)
2025-10-20 [email protected] Remove redundant name field form `TargetPlatform` and `XCDeviceEventInterface` enums (flutter/flutter#176890)
2025-10-20 [email protected] Added support to pass in texture type while creating textures. (flutter/flutter#175376)
2025-10-20 [email protected] Roll Packages from 3747006 to d113bbc (6 revisions) (flutter/flutter#177270)
2025-10-20 [email protected] Roll Dart SDK from 2cd2106f2cef to 913c2ae1b367 (2 revisions) (flutter/flutter#177258)
2025-10-20 [email protected] Added link to ClipRect from ImageFilter in the docstring (flutter/flutter#177196)

If this roll has caused a breakage, revert this CL and stop the roller
using the controls here:
https://autoroll.skia.org/r/flutter-packages
Please CC [email protected],[email protected] on the revert to ensure that a human
is aware of the problem.

...
@manu-sncf manu-sncf deleted the fix_cache_origin branch November 19, 2025 17:32
reidbaker pushed a commit to AbdeMohlbi/flutter that referenced this pull request Dec 10, 2025
Fix flutter#175759 

The fix involves using the same logic for cache calculation on
RenderViewport.

## Pre-launch Checklist

- [X] I read the [Contributor Guide] and followed the process outlined
there for submitting PRs.
- [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 documentation (doc comments with `///`).
- [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

f: scrolling Viewports, list views, slivers, etc. framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The SliverMainAxisGroup.cacheOrigin is not consistent with CustomScrollView

3 participants