-
Notifications
You must be signed in to change notification settings - Fork 90
fix: replace FlexFrame with Layout protocol to eliminate main-thread hang (LUM-944) #26053
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
ashleeradka
merged 5 commits into
main
from
devin/LUM-944-1776357508-fix-ancestor-flexframe-hang
Apr 16, 2026
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
50a943d
fix: replace FlexFrame with Layout protocol to eliminate 104.96s hang…
devin-ai-integration[bot] 60c7eef
fix: cap both width and height for portrait images in AnimatedImageView
devin-ai-integration[bot] b0f051f
fix: make BottomAlignedMinHeightLayout public for cross-module access
devin-ai-integration[bot] b8e2998
fix: use consistent proposal in placeSubviews to prevent layout oscil…
devin-ai-integration[bot] b572ae4
chore: clean up PR-iteration-specific comments
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
clients/shared/DesignSystem/Modifiers/BottomAlignedMinHeightLayout.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| import SwiftUI | ||
|
|
||
| /// Ensures content is at least `minHeight` tall, pinning the child to the | ||
| /// bottom edge when the child is shorter than the minimum. Drop-in replacement | ||
| /// for `.frame(minHeight:alignment: .bottom)` that avoids `_FlexFrameLayout` | ||
| /// and its O(n x depth) `explicitAlignment` cascade inside LazyVStack cells. | ||
| /// | ||
| /// `_FlexFrameLayout` resolves `.bottom` alignment by calling | ||
| /// `explicitAlignment(.bottom)` on every descendant, which propagates | ||
| /// recursively through the entire subtree. This Layout-protocol | ||
| /// implementation achieves the same visual result in O(1) by positioning | ||
| /// the child via `placeSubviews` — no alignment query cascade. | ||
| /// | ||
| /// Reference: [Layout.explicitAlignment](https://developer.apple.com/documentation/swiftui/layout/explicitalignment(of:in:proposal:subviews:cache:)-8ofeu) | ||
| public struct BottomAlignedMinHeightLayout: Layout { | ||
| public let minHeight: CGFloat | ||
|
|
||
| public init(minHeight: CGFloat) { | ||
| self.minHeight = minHeight | ||
| } | ||
|
|
||
| public func sizeThatFits(proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) -> CGSize { | ||
| guard let child = subviews.first else { | ||
| return CGSize(width: proposal.replacingUnspecifiedDimensions().width, height: minHeight) | ||
| } | ||
| let childSize = child.sizeThatFits(proposal) | ||
| return CGSize( | ||
| width: childSize.width, | ||
| height: max(childSize.height, minHeight) | ||
| ) | ||
| } | ||
|
|
||
| public func placeSubviews(in bounds: CGRect, proposal: ProposedViewSize, subviews: Subviews, cache: inout ()) { | ||
| guard let child = subviews.first else { return } | ||
| // Re-measure with the SAME proposal that sizeThatFits received. | ||
| // Using bounds.height would propose the expanded min-height to the | ||
| // child, which can return a different size than during measurement | ||
| // — causing SwiftUI to detect a layout inconsistency and | ||
| // re-evaluate the layout every frame. | ||
| let childSize = child.sizeThatFits(proposal) | ||
| // Pin child to bottom of bounds (same as alignment: .bottom). | ||
| let y = bounds.maxY - childSize.height | ||
| child.place( | ||
| at: CGPoint(x: bounds.origin.x, y: y), | ||
| anchor: .topLeading, | ||
| proposal: ProposedViewSize(width: childSize.width, height: childSize.height) | ||
| ) | ||
| } | ||
| } | ||
|
|
||
| extension View { | ||
| /// Applies a minimum height with bottom alignment without creating | ||
| /// `_FlexFrameLayout`. When `minHeight` is nil, no constraint is applied. | ||
| @ViewBuilder | ||
| public func bottomAlignedMinHeight(_ minHeight: CGFloat?) -> some View { | ||
| if let minHeight { | ||
| BottomAlignedMinHeightLayout(minHeight: minHeight) { self } | ||
| } else { | ||
| self | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚩 V-prefix naming convention not applied to new Design System Layout type
The new
BottomAlignedMinHeightLayoutstruct and.bottomAlignedMinHeight()modifier live inclients/shared/DesignSystem/Modifiers/but don't use theVprefix. Theclients/AGENTS.mdrule states: "All design system types — structs, enums, and view modifiers — must use the V prefix." However, the pre-existingWidthCapLayout(clients/shared/DesignSystem/Modifiers/WidthCapLayout.swift:9) and its.widthCap()modifier follow the exact same non-V-prefix pattern, as do other modifiers likePanelBackgroundModifier,CardModifier,ShimmerEffectModifier,PointerCursorModifier. The de facto convention for Layout-protocol implementations and modifier structs in this directory is to omit the V prefix on the struct itself (though some modifier methods like.vCard(),.vShimmer()do use it). The new code is consistent with the established codebase convention, though the team may want to align the AGENTS.md rule with the actual practice or migrate existing types.Was this helpful? React with 👍 or 👎 to provide feedback.