You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I noticed that using WrappingHStack in longer lists is quite CPU intensive (not sure if #4 already addresses my point - if so, feel free to close this issue).
Here is an example:
var body: some View {
ScrollView {
ForEach(1..<300) { index in
WrappingHStack {
Text("This")
Text("is")
Text("a")
Text("test")
Text("!1!!")
}
}
}
}
I checked what is causing the high CPU usage and found that the InternalWrappingHStack.init method is being called hundreds of times. Launching the app without further interaction already results in 597 calls. I made a small video that shows how a very small interaction skyrockets the number of calls:
initCalls.mp4
I have no clue what's going on. I believe that GeometryReader in WrappingHStack.swift triggers these calls. However, as the video shows, the width does not change at all. Is there a possibility to react only to relevant changes to reduce the number of InternalWrappingHStack.init calls significantly?
(I had some success by moving the GeometryReader out of WrappingHStack.swift into the view that uses WrappingHStack and passing the width to WrappingHStack, but my knowledge of SwiftUI is too limited to understand what's going on with the height in WrappingHStack.swift)
Hi Daniel!
First of all: Thanks for your awesome work! :)
I noticed that using WrappingHStack in longer lists is quite CPU intensive (not sure if #4 already addresses my point - if so, feel free to close this issue).
Here is an example:
I checked what is causing the high CPU usage and found that the InternalWrappingHStack.init method is being called hundreds of times. Launching the app without further interaction already results in 597 calls. I made a small video that shows how a very small interaction skyrockets the number of calls:
initCalls.mp4
I have no clue what's going on. I believe that GeometryReader in WrappingHStack.swift triggers these calls. However, as the video shows, the width does not change at all. Is there a possibility to react only to relevant changes to reduce the number of InternalWrappingHStack.init calls significantly?
(I had some success by moving the GeometryReader out of WrappingHStack.swift into the view that uses WrappingHStack and passing the width to WrappingHStack, but my knowledge of SwiftUI is too limited to understand what's going on with the height in WrappingHStack.swift)
Again, thanks a lot! :)