Skip to content

RenderViewport max layout cycles should depend on number of slivers #144104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 13, 2024

Conversation

knopp
Copy link
Member

@knopp knopp commented Feb 25, 2024

Fixes #144102

Pre-launch Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@github-actions github-actions bot added framework flutter/packages/flutter repository. See also f: labels. f: scrolling Viewports, list views, slivers, etc. labels Feb 25, 2024
@knopp knopp force-pushed the render_viewport_max_layout_cycles branch from 993f23f to ccab25b Compare February 25, 2024 17:32
@knopp knopp changed the title RenderViewport max layout cycles should depend on number of children RenderViewport max layout cycles should depend on number of slivers Feb 25, 2024
@knopp knopp requested a review from Piinks February 25, 2024 17:51
Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Hey @knopp! Thanks for the PR!

I don't recall why it is 10, and I tracked it all the way down to #7790, which did not give much insight either. :)
Maybe @Hixie knows.

@@ -1399,7 +1399,7 @@ class RenderViewport extends RenderViewportBase<SliverPhysicalContainerParentDat
return constraints.biggest;
}

static const int _maxLayoutCycles = 10;
static const int _maxLayoutCyclesPerChild = 10;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be a little lower now that it is per child? Before a viewport with 3 sliver children would allow 10 passes, now it would be 30.

Copy link
Member Author

@knopp knopp Feb 29, 2024

Choose a reason for hiding this comment

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

I don't think any reasonable sliver would need more than a handful of passes, the problem is that you can have nested slivers in MultiSliver or even SliverMainAxisGroup (but I don't think that one properly propagates scrollOffsetCorrection?) and we have no good way to count correction count per actual source sliver. For that we would probably need changes to SliverGeometry.

So lowering the mainLayoutCycles could potentially be breaking change for someone that has nested slivers.

More importantly I do think that the check is meant to detect pathological cases where the layout is stuck in a loop of corrections, and as such it does matter if it is 10 passes or 30? It will throw an exception anyway so it is not something that happens during regular layout process.

Copy link
Contributor

Choose a reason for hiding this comment

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

SGTM, thanks for explaining your thinking here. :)

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Flutter_LGTM

Is there an issue filed for SliverMainAxisGroup not handling the correction? We should follow up on that. :)

@knopp knopp force-pushed the render_viewport_max_layout_cycles branch from c87da01 to 7ad984f Compare March 9, 2024 09:11
@knopp
Copy link
Member Author

knopp commented Mar 9, 2024

@Piinks, seems like maybe you still need to approve the PR? :)

I'll create issue for SliverMainAxisGroup.

Copy link
Contributor

@Piinks Piinks left a comment

Choose a reason for hiding this comment

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

Oh sorry about that! I had that happen a couple times last week. 🙃

@Piinks Piinks added the autosubmit Merge PR when tree becomes green via auto submit App label Mar 13, 2024
@knopp knopp force-pushed the render_viewport_max_layout_cycles branch from 7ad984f to ec2cfad Compare March 13, 2024 19:17
@knopp knopp merged commit 1908744 into flutter:master Mar 13, 2024
@knopp knopp deleted the render_viewport_max_layout_cycles branch March 13, 2024 21:28
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 14, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 15, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 16, 2024
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request Mar 16, 2024
moffatman pushed a commit to moffatman/flutter that referenced this pull request Apr 1, 2024
…lutter#144104)

Fixes flutter#144102

## 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.

If you need help, consider asking for advice on the #hackers-new channel
on [Discord].

<!-- Links -->
[Contributor Guide]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#overview
[Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene
[test-exempt]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#tests
[Flutter Style Guide]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo
[Features we expect every widget to implement]:
https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement
[CLA]: https://cla.developers.google.com/
[flutter/tests]: https://github.com/flutter/tests
[breaking change policy]:
https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes
[Discord]: https://github.com/flutter/flutter/wiki/Chat
[Data Driven Fixes]:
https://github.com/flutter/flutter/wiki/Data-driven-Fixes
engine-flutter-autoroll added a commit to engine-flutter-autoroll/packages that referenced this pull request May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App 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.

RenderViewport maxLayoutCycles should depend on number of slivers in viewport
2 participants