Post

Replies

Boosts

Views

Activity

What are the downsides to using lazy stacks?
In Stacks, Grids, and Outlines in SwiftUI - https://developer.apple.com/videos/play/wwdc2020/10031, a recommendation is made to only use lazy stacks when you encounter performance bottlenecks. To quote the session, starting at 4:43: On the other hand, making the stacks within a given hero view lazy doesn't actually confer any benefits. The content is all visible at once, as soon as the view lands on screen. So everything has to be loaded at once, regardless of the container's default behavior. If you aren't sure which stack to use, use VStack or HStack. Adopt lazy stacks as a way to resolve performance bottlenecks that you find after profiling with Instruments. Are there negatives, performance or otherwise, to just always use lazy stacks? I'd like to understand why I shouldn't reach for LazyVStack and LazyHStack first. I understand from the example that using a lazy stack wouldn't confer any benefits, but would we incur any negatives?
3
0
7.8k
Jun ’20