Reading about @dimillian's issues with SwiftUI and scroll performance in his Ice Cubes app compared to UIKit, and if I were Apple I'd be flying him down to profile his app and see where SwiftUI could be optimized more/what's going on.

Such a great app and showcase of SwiftUI, and even though complex, media-rich timelines with lots of elements can be complex to get right in UIKit, I think instilling community/developer confidence that "Yeah, SwiftUI can do this too" is really important.

@christianselig @dimillian SO I'm also building an app in SwiftUI and scroll performance is definitely an issue. It seems to be related to loading images. I had to scale them all down =(
@wvabrinskas @christianselig we can brainstorm on it, let me know :). I’m at the part where I’m really at the bottom of the barrel. You feel like SwiftUI Image is the bottleneck?
@dimillian @christianselig I would also resize all images to be roughly the size of the view they will be contained in. Resizing images to a fit a view with `.resizable()` in SwiftUI seems to be not great. I use the accelerate framework to resize my images manually for their respective view.
@wvabrinskas @christianselig interesting about the resizing Cc @a_grebenyuk
@dimillian @wvabrinskas @christianselig yes, it's recommended to scale images in the background to exactly match the image view size and disable scaling. Otherwise, there is a bit of a penalty, especially noticeable when images are too small or large for the target view. I'm not sure how relevant it is with the modern GPUs though, but it definitely wouldn't hurt. I got some more info on performance here, but nothing SwiftUI-specific yet https://kean-docs.github.io/nuke/documentation/nuke/performance-guide
Documentation

@a_grebenyuk @dimillian @christianselig It seems to be very relevant even on my 14 pro max lol
@wvabrinskas @dimillian @christianselig went through the thread; I'm just wondering, when you referred to loading from Data, what did you mean? If you perform something like Image(uiImage: UIImage(data: data)) on the main thread, it'll be slow because of decompression (for compressed image formats), not scaling. But when you scale an image, it also triggers decompression. Nuke performs decompression in the background by default. It's table stakes in image frameworks, so shouldn't be an issue.
@a_grebenyuk @dimillian @christianselig Yeah I meant loading from Data like you mentioned. Im just speaking anecdotally. I did discover that performing the Data -> Image on the main thread is still an issue I'm just saying that the scaling might be the culprit for slow scroll performance.
@wvabrinskas @a_grebenyuk @dimillian @christianselig Just to add a bit more to this, is the image caching done on-the-fly as rows appear or in batches? If it’s the former another optimisation point would be to pre-load all the new images in bg, resize to fit the exact image rect in retina and cache them before even triggering any UI change. It’s a better UX to let user wait 0.5s than to face micro-stutters.
@tanmay @a_grebenyuk @dimillian @christianselig That's kind of what I'm doing yeah. As they appear they are rendered and cached in the background async. Then each image fades in when ready.
@wvabrinskas @a_grebenyuk @dimillian @christianselig The fade in part will eat up CPU cycles and add render passes. With each row doing it, it will add up. Maybe try a batched approach. Also some way to cancel the fade-in if row isn’t visible anymore (I think SwiftUI should automatically do this via cv cell re-use but just make sure).
@tanmay @a_grebenyuk @dimillian @christianselig the fade in happens only once. Since it already has an image from the cache. No need to wait for the async load.
@wvabrinskas @a_grebenyuk @dimillian @christianselig yeah what I’m suggesting is try to avoid having a fade-in at all. Every cell doing a fade-in animation adds up.
@tanmay @wvabrinskas @dimillian @christianselig great suggestion. I’d definitely remove all appearance animations. I prefer no animations; they are distracting in a feed. And it’s best to prefetch images. It’s delightful when you scroll, and all media is already there.