Comments (18)
iOS 16 and before: The content under "Cache" folder is not calculated.
iOS 17: Now the "Cache" folder is counted as a part of the "Documents & Data" value.
After careful investigation, we have finally pinpointed the root cause of the problem: iOS 17 the cache as both documents and data, which, as it turns out, was the source of my confusion.
This discovery clarifies the issue significantly. I also want to extend my heartfelt thanks for the valuable tips and corrections you generously provided throughout our communication.
I am eager to apply your suggestions to improve the situation. I consider this particular issue now resolved.
Once again, thank you for your time, expertise, and patience. Your support has been instrumental in reaching this conclusion.
from kingfisher.
I checked the details and as I can say now, iOS 17's Settings.app changed its calculation for "Documents & Data" section.
iOS 16 and before: The content under "Cache" folder is not calculated.
iOS 17: Now the "Cache" folder is counted as a part of the "Documents & Data" value.
Kingfisher put its disk cache under the "Cache" folder, so the number displayed here is different. However, the actual behavior seems to be identical.
To compare the actual disk cache size of Kingfisher is taking, I suggest use the code snippet below for a better control:
KingfisherManager.shared.cache.calculateDiskStorageSize { v in
do {
let bytes = try v.get()
let mb = Double(bytes) / 1024 / 1024
print("Disk Size: \(mb) MB")
} catch {
print("Failing.")
}
}
from kingfisher.
@edolorenza Thanks. So according to your tests, it seems that on iOS 17 physical device, there are some reasons preventing the cache system working. Kingfisher cannot hit any cache there so it keeps downloading and caching the resources repeatedly. However, on earlier OSs and iOS 17 simulator, the cache seems to be working, since there are .memory
or .disk
.
I am upgrading one of my iPad to iPadOS 17 and hopefully I can also reproduce this behavior there. Then I can dig deeper into the issue and see what's going on.
from kingfisher.
I'm having the same problem
from kingfisher.
Same issue here. Noticing it when building on Xcode 15, this issue is causing our app's memory usage to consistently increase until it crashes.
from kingfisher.
Thanks for the reporting. I am checking it now and will let you know the result.
from kingfisher.
@edolorenza After some basic tests with Xcode 15 and iOS 17 Simulator, it seems all works fine.
Does this issue only happen on physical device, or can you also reproduce it on the iOS 17 simulator?
And I also wonder if you can identify which file/files/folder takes those disk space?
According to your description, I wonder if it is keeping downloading the resource and caching them without hitting the cache. Can you try to modify your code a bit as below (adding a print of cache status), repeat your operation, and let me know the result?
KFImage(URL(string: item.image))
.placeholder {
Image.imgDefault
.centerCropped()
.frame(height: (UIScreen.screenWidth/2.4)-28, alignment: .center)
}
.onSuccess { print($0.cacheType) } // <- Add this
.centerCropped()
.frame(height: (UIScreen.screenWidth/2.4)-28, alignment: .center)
Ideally, for each item, except for the first downloading's .none
(which means there is no cache hit), the print statement should give out either .memory
or .disk
.
from kingfisher.
And also here is a snippet to check the exact disk space which Kingfisher's cache is taking. It would be great if you can also check whether this value is expected.
KingfisherManager.shared.cache.calculateDiskStorageSize { v in
do {
let bytes = try v.get()
let mb = Double(bytes) / 1024 / 1024
print("Disk Size: \(mb) MB")
} catch {
print("Failing.")
}
}
from kingfisher.
@onevcat here is the result of scrolling for 15 seconds, I tested on a physical device with ios 17.0.1
![Screenshot 2023-09-26 at 09 20 19](https://private-user-images.githubusercontent.com/48113050/270517425-f5804638-f435-401b-92e1-bd5cee6d606d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDEzMDg3OTIsIm5iZiI6MTcwMTMwODQ5MiwicGF0aCI6Ii80ODExMzA1MC8yNzA1MTc0MjUtZjU4MDQ2MzgtZjQzNS00MDFiLTkyZTEtYmQ1Y2VlNmQ2MDZkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFJV05KWUFYNENTVkVINTNBJTJGMjAyMzExMzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjMxMTMwVDAxNDEzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPThkZDY2MmZmNDY3YmMyNmYxMjI5YjIwZWY2ZTQwNjA3Y2I5MTM4MWZhNjg5NTUwZDI5ZjQ0N2JmN2ZkNDQ2YjAmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.K1CJ3u1MI3y42x7Hqh0c3-IO8X8X-Wn8FWUsuZnTrSY)
and this is if using a physical device with iOS version 14.3
![Screenshot 2023-09-26 at 09 23 07](https://private-user-images.githubusercontent.com/48113050/270517894-8a2c7724-390f-4843-98ad-1dd2f5aa6633.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDEzMDg3OTIsIm5iZiI6MTcwMTMwODQ5MiwicGF0aCI6Ii80ODExMzA1MC8yNzA1MTc4OTQtOGEyYzc3MjQtMzkwZi00ODQzLTk4YWQtMWRkMmY1YWE2NjMzLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFJV05KWUFYNENTVkVINTNBJTJGMjAyMzExMzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjMxMTMwVDAxNDEzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTRhNDc5YWM1MmI2Nzk0YWFjM2IzNWMzYzRjODYzNmNlZjkwNDkzNjQzZTQ5MTUyMTE2NDY2MzQ1MjJlZTE0ZGUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.gFcWMwV7Y53jt6PNtzVg_87mxk968nb261nbGvSpn-8)
from kingfisher.
OK. So that means none of the cache hits. It makes sense why the disk storage keeps going up.
Does the same thing happen on a Simulator? (Unfortunately I did not have a physical iOS 17 device by my hand now...)
from kingfisher.
I can find a compatible device with iPadOS 17. I will try to upgrade it now and let you know if I can find anything useful!
from kingfisher.
@onevcat These are the test results in the simulator with iOS 17.0
![Screenshot 2023-09-26 at 09 29 06](https://private-user-images.githubusercontent.com/48113050/270519098-4d9bc905-b0fe-46f5-9648-06877410f9ed.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDEzMDg3OTIsIm5iZiI6MTcwMTMwODQ5MiwicGF0aCI6Ii80ODExMzA1MC8yNzA1MTkwOTgtNGQ5YmM5MDUtYjBmZS00NmY1LTk2NDgtMDY4Nzc0MTBmOWVkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFJV05KWUFYNENTVkVINTNBJTJGMjAyMzExMzAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjMxMTMwVDAxNDEzMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTNmZTNkOWY1YjYzMjZkYmYxODdjY2MzYjQzNjQzMWFlODQyZmY5MDUwOWZjNzY4NjIzYjY4YTM5NmYyMWNhNGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.tOAxCLLg3-5lLf_TchUF3hEIn8d8ORDwsHC3Ejm9fhE)
from kingfisher.
@edolorenza Ummm, unfortunately, I cannot reproduce this in the demo app on my iPadOS 17. As the result shows:
The cache seems working fine and the disk storage usage is normal.
I guess I have to try to find an iOS 17 device to see. Meanwhile, may I ask if you did anything else or are you having something special in your item.image
URL string? If you are still willing to help, can you please try to clone the master branch of this repo and run the demo app to see how it is working on your device?
git clone https://github.com/onevcat/Kingfisher.git
- Open the Kingfisher.xcworkspace
- Switch to the Kingfisher-Demo target and choose an available cert/provision file
- Run the demo app and navigate to "SwiftUI -> Stack", where there is a lazy stack to load lots of image files. There you can try to scroll up and down, and see the Xcode console to check where the images are coming from.
from kingfisher.
There's nothing special about the image I use, my string image comes from an Amazon S3, with a size of around 200KB, but if I use the application for just 3 hours, it already takes up the remaining 3GB of space on my disk memory, so my iPhone's memory is full.. You can check the iOS 17 screenshot that I included, the difference in document size & data looks clearly different even though you use more or less the same for 1 minute.
I also noticed something different on iOS below version 17, when I opened the Documents & Data storage, for example 10MB, when I reloaded it again, the documents & data used would change to just a few KB. The same thing doesn't happen with iOS 17, it keeps increasing until your iPhone memory is full
from kingfisher.
@onevcat
This is a photo I took while using my application for less than an hour, the difference in memory usage between the two iOS versions 14.3 vs 17.0.1 is clearly visible.
I can also send you a private message containing the app store link of my application if you don't mind trying it.
from kingfisher.
Ummm, that is really weird. By the way, any chance to try a reboot of the device?
I can also send you a private message containing the app store link of my application if you don't mind trying it.
Sure, please reach me at [email protected]
I have to wait for a day before I can get a iOS 17 device (instead of iPadOS, where I cannot reproduce it). I will continue to check this issue as soon as I can get a device.
from kingfisher.
Ummm, that is really weird. By the way, any chance to try a reboot of the device?
rebooting the device did not solve the problem, I have sent you an email, hopefully we can find the cause of this problem soon.
from kingfisher.
I am closing this since we have already known the reason behind it.
from kingfisher.
Related Issues (20)
- Does this alter images after they're downloaded? HOT 1
- How to load gif file from Assets HOT 1
- Couldn't Generate Swift Representation Error (from SourceKit): "Could not load module: Kingfisher" HOT 3
- 如何获取ImageURL HOT 1
- 强制过渡动画,但是不想每次刷新都会执行动画 HOT 1
- Xcode15 beta8 Carthage HOT 1
- Can not load gif image from url with backgroundDecode. HOT 2
- KFAnimatedImage Shows Blank While Trying To Take A Screenshot
- XCode升级到15运行,ImageResource文件名与系统库文件方法名冲突 HOT 2
- How to use KFAnimatedImage on MacOS? HOT 2
- Can't see this image url HOT 1
- URL for cached image HOT 1
- kingfisher
- KFImage goes out of bounds and does not respect frame(widht, height) HOT 2
- Deprecation warnings iOS15+ HOT 1
- How to set cache key while downloading image using kingfisher? HOT 1
- startLoadingBeforeViewAppear is causing infinite error requests HOT 1
- Decryption for network image HOT 2
- firebase Crash on KingfisherWrapper----Crash on iPhone X during TestFlight Release 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 kingfisher.