Closed rico-crescenzio-distilled closed 3 years ago
Hey, thank you for reporting and sample code. I'm a bit busy, but I will address this issue when I get time.
on tvOS when I use image inside NavigationLink that is inside a LazyVStack I get a crash with this error
Attempted to read an unowned reference but the object was already deallocated
I am using 2.0.0alpha.1
@dmytro-anokhin I am also encountering @rico-crescenzio-distilled's issue. LazyVStack performance is pretty sluggish...
Hey,
I reread your report. If you suspect that loading cause performance degradation you can add a small delay:
URLImage(url, delay: 0.25)
This way download won't start immediately and will be gracefully cancelled when the view disappears.
Alternatively, you can try using List
since it's reusing views.
I'm currently working on version_2 (#86). You can already try using it. I will definitely look at performance with lazy stacks.
Hey @dmytro-anokhin,
Unfortunately, I did not see any performance improvements after adding a .25 delay.
Originally, I was using a List
, but due to do limitations in iOS14 we're unable to remove the cell separators like in iOS13, that being said we're required to use LazyVStacks
in order to prevent excessive memory usage with traditional VStacks
. I think this is going to be a pretty big issue for a lot of people once iOS14 and SwiftUI2 gain more traction.
Please update to v2.0. My test app shows performance improvement with lazy views.
I assume this is fixed if no reply
Sorry, I actually didn't have chance to test it
Summary and/or background When using a
LazyVStack
contained inScrollView
to render lazily views (for example when working with large amount of data) and these views contain anURLImage
, scrolling is very choppy.OS and what device you are using
Version of URLImage library 0.9.19
What you expected would happen The scroll should be smooth.
What actually happens
LazyVStack
load a view when it needs to be displayed; this means that during scrolling a lot of views are created and thereforeURLImage
are created too (so they'll load the image). I'm not sure how Apple implementedLazyVStack
, so I don't know if a view is reused (like inUICollectionView
) or every time a view is created.If I change the code to use a simple
VStack
, everything works good (I assume because all views are loaded just once).Sample code
Body of the main scene
Body of
PlayerRowView
Additional information: Video to compare
VStack
vsLazyVStack
usages. Videos.zip