-
-
Notifications
You must be signed in to change notification settings - Fork 531
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
LazyImage(url:) does not load image when using ImageRenderer #760
Comments
Hey, @mergesort 👋
Can you please confirm if you see the same behavior when the image is available in the memory cache? If there is an issue even in that scenario, it might be related to the changes introduced in 12.1.3 that temporarily removed the memory cache lookup from the first
This part is a bit inefficient: .animation(ImagePipeline.shared.cache.containsData(for: ImageRequest(url: imageURL)) ? nil : .easeIn(duration: 0.1))
Not really, but |
Hi @kean @mergesort 👋 I'm experiencing the same issue. I can confirm that it persists even when the image is available in the memory cache. In my case, the images are loaded on the initial screen. Subsequently, in a child view, an I'm uncertain if it's a bug because Since these images are already loaded at the time |
I had some success with this by storing the rendered image in a @State private var renderedImage: Image?
var body: some View {
// ...
}
@MainActor
func updateRenderedImage() {
let renderer = ImageRenderer(content: body)
renderer.scale = displayScale
renderedImage = renderer.uiImage.flatMap(Image.init)
}
// usage
LazyImage(url: url) { state in
if let image = state.image {
image
.resizable()
.aspectRatio(contentMode: .fit)
} else {
Color.blue
}
}
.onCompletion { _ in
Task { @MainActor in
updateRenderedImage()
}
} |
Did you guys find any solution? |
Hey @kean, thank you so much for this library, it's been a true life-saver!
I noticed in this changelog entry you mention that
LazyImage
should render an image when using ImageRenderer, but when I try to use ImageRenderer I'm not seeing this work.In the screenshot below the [C] and the empty box on the bottom right are powered by LazyImage, code that looks approximately like this. (The boxed [C] is a static letter drawn when an image can't be loaded.)
The code I have for
ImageRenderer
is relatively simple but I've noticed I have the same issue in widgets, so perhaps I'm missing some sort of configuration that will load the image correctly.I have three questions, two of which pertain to this problem directly:
Just wanted to say thank you so much again, Nuke really has made my life a lot easier!
The text was updated successfully, but these errors were encountered: