Skip to content

fix: Reimplement setLayoutSize to only notify once - #3796

Merged
spydon merged 3 commits into
flame-engine:mainfrom
livtanong:fix-set-layout-size
Jan 6, 2026
Merged

fix: Reimplement setLayoutSize to only notify once#3796
spydon merged 3 commits into
flame-engine:mainfrom
livtanong:fix-set-layout-size

Conversation

@livtanong

Copy link
Copy Markdown
Contributor

Description

In some cases, like when a PaddingComponent with inflateChild = true wraps a ColumnComponent, we get a stack overflow.
This is because setLayoutSize was implemented as setLayoutAxisLength on both axes. At first glance, this seems equivalent, but the first invocation would trip all size listeners before the second invocation completes. This meant that the guard statement of SingleChildLayoutComponent.syncChildSize would never execute in the case of a PaddingComponent with inflateChild set to true wrapping the LayoutComponent. Thus, infinite loop.

This PR fixes the implementation of both setLayoutSize and resetSize.

Checklist

  • I have followed the Contributor Guide when preparing my PR.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples or docs.

Breaking Change?

  • Yes, this PR is a breaking change.
  • No, this PR is not a breaking change.

Related Issues

@livtanong livtanong changed the title fix: setLayoutSize should only notify once fix: Reimplement setLayoutSize to only notify once Jan 6, 2026

@spydon spydon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Lgtm, except the commented out code
Thanks for your fix!

Comment thread packages/flame/test/experimental/linear_layout_component_test.dart Outdated
@spydon

spydon commented Jan 6, 2026

Copy link
Copy Markdown
Member

Fixed the failing pipeline step in #3797

@spydon
spydon enabled auto-merge (squash) January 6, 2026 15:01
@spydon
spydon merged commit 97f8beb into flame-engine:main Jan 6, 2026
68 checks passed
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