Comments (10)
Hi,
Could you please provide a sample where I could reproduce it? I think it might have to do with the SwiftUI view lifecycle.
By default, Nuke uses HTTP cache. If it's not configured on the server side, it's not going to work. You can also switch to aggressive disk caching if you'd like. More info here : https://kean.blog/nuke/guides/caching
from nukeui.
I’ll have to pull together the data manually since I’m using CloudKit. To test with aggressive disk caching, can I simply pass this to the pipeline modifier of LazyImage?
ImagePipeline { $0.dataCache = try? DataCache(name: "com.myapp.datacache") }
would be great if you had a simple example.
from nukeui.
It's best to instantiate it this following way and you can also change a shared
pipeline if that's what you want:
ImagePipeline.shared = ImagePipeline(configuration: .withDataCache)
It completely disables HTTP cache.
from nukeui.
ImagesNotLoading.mp4
It's best to instantiate it this following way and you can also change a
shared
pipeline if that's what you want:ImagePipeline.shared = ImagePipeline(configuration: .withDataCache)It completely disables HTTP cache.
Hi @kean,
Thank you for the details. I've added ImagePipeline.shared = ImagePipeline(configuration: .withDataCache)
to the didFinishLaunchingWithOptions to configure it globally; however, the images are still not loading for all instances.
I'll have to try to whip up a sample app. Is there another way to setup the ImagePipeline rather than in the App delegate that might be better?
Thank you.
from nukeui.
Is there another way to setup the ImagePipeline rather than in the App delegate that might be better?
You can do it any way you'd like. The UI components support passing a custom pipeline. So if you want to create a local pipeline instead of using a shared one, you can do that. For example:
LazyImage(source: url)
.pipeline(yourCustomPipeline)
from nukeui.
Ok, I tried using the shared in the app delegate, and by adding it to the LazyImage(source: url) directly to no avail. I'm not really doing anything special. I have a list populated from an NSFetchRequest, using:
List {
ForEach(filteredListings, id:\.self) { listing in
LargeListItem(listing: listing, pipeline: pipeline)
.listRowSeparator(.hidden)
}
}
I'll see if I can reproduce this with a barebones project and images statically defined in a class. Have you tested with very large lists?
from nukeui.
Ok, I whipped up a minimal reproducible project to test with. I am also noticing in the sample project that the image overlap issue occurs more frequently. Please see attached.
ListImageIssue.zip
from nukeui.
Just an update on the issue on my end:
I added some trace statements and found that the images that fail to load do not have their corresponding onAppear method called in the LazyImage.swift definition. The images that do appear, naturally, have the order of (ImageRequest created)->(onAppear called)->(model.load called)->(ImageResponse etc.)
For the sake of testing with newer threading in Swift 5.5, I tried using task on the ZStack rather than onAppear(perform:, to no avail (it's literally exhibiting the same behavior as onAppear):
.task{
onAppear()
}
I've also tried removing the ZStack that wraps the content, which also doesn't seem to have any impact. It might be worth noting, I am seeing similar behavior with the same project I attached using AsyncImage, so I wonder if this is a bad bug in SwiftUI, which maybe you can help report with FeedbackAssistant. I also tested the task on the LazyImage(source:) in the code attached "ListImageIssue.zip", and the task does not get called for the List items that do not display the images.
So it seems this might be a bug in SwiftUI itself. I'm testing this same code with AsyncImage, and it looks like images are also struggling to load; however, the tasks do get called for the images that fail to appear. I am attaching the AsyncImage
ListImageIssueAsyncImage.zip
project here if you want to take a look. Interestingly, the images that fail to load with the AsyncImage type, are failing because they are canceled, so I am curious if there is a related issue.
from nukeui.
Have you tested with very large lists?
I tested it quite extensively in the Nuke Demo. This code is also used by at least a few apps and it seems to be working ok, at least in the common scenarios.
Thanks for sharing the sample. I looked into it and there seems to be something wrong with the layout – the frames of the views are overlapping. I think that might be causing the issue. I would suggest looking into the layout.
.frame(minHeight: mediaHeight, maxHeight: mediaHeight, alignment: .center)
This in particular doesn't seem right. I would suggest specifying hard frame sizes and trying a different alignment mode.
from nukeui.
Please try with the latest Nuke and NukeUI versions. There were a couple of related fixes.
I'm going close it because I believe it has to do with the layout issues pointed out earlier and the same issue applies to AsyncImage
.
from nukeui.
Related Issues (20)
- Question: How can we stop animations when image is displayed. HOT 2
- Can we add play and pause buttons to the video playback? HOT 3
- Add support for iOS 13 HOT 1
- Placeholder image always displayed before cached image on iOS 15 when using an animation modifier
- LazyImage and memory usage HOT 2
- LazyImage in List elements HOT 3
- Read Image Data
- Image goes black when using SwiftUI contextMenu HOT 2
- Nothing shows when using content closure & url points to a video HOT 1
- Issue loading gif HOT 1
- Crash IOS 14.4 HOT 2
- Randomly, image does not load HOT 12
- To not set const image height
- Failed to decode image HOT 1
- Unable to change default view/color while image is loading HOT 1
- NukeUI + Introspect issue HOT 5
- MP4 loop stops when app is put in background HOT 2
- [Question] Disk caching between sessions? HOT 2
- Dependency on Gifu HOT 1
- Unable to add package HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nukeui.