Giter Club home page Giter Club logo

Comments (18)

edolorenza avatar edolorenza commented on July 19, 2024 4

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.

onevcat avatar onevcat commented on July 19, 2024 2

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.

onevcat avatar onevcat commented on July 19, 2024 1

@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.

GiovanniLuigi avatar GiovanniLuigi commented on July 19, 2024

I'm having the same problem

from kingfisher.

seanperez29 avatar seanperez29 commented on July 19, 2024

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.

onevcat avatar onevcat commented on July 19, 2024

Thanks for the reporting. I am checking it now and will let you know the result.

from kingfisher.

onevcat avatar onevcat commented on July 19, 2024

@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.

onevcat avatar onevcat commented on July 19, 2024

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.

edolorenza avatar edolorenza commented on July 19, 2024

@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

and this is if using a physical device with iOS version 14.3

Screenshot 2023-09-26 at 09 23 07

from kingfisher.

onevcat avatar onevcat commented on July 19, 2024

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.

onevcat avatar onevcat commented on July 19, 2024

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.

edolorenza avatar edolorenza commented on July 19, 2024

@onevcat These are the test results in the simulator with iOS 17.0

Screenshot 2023-09-26 at 09 29 06

from kingfisher.

onevcat avatar onevcat commented on July 19, 2024

@edolorenza Ummm, unfortunately, I cannot reproduce this in the demo app on my iPadOS 17. As the result shows:

截屏2023-09-26 13 09 33

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?

  1. git clone https://github.com/onevcat/Kingfisher.git
  2. Open the Kingfisher.xcworkspace
  3. Switch to the Kingfisher-Demo target and choose an available cert/provision file
  4. 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.

edolorenza avatar edolorenza commented on July 19, 2024

@onevcat

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

Group 1

from kingfisher.

edolorenza avatar edolorenza commented on July 19, 2024

@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.

20230926_113835

from kingfisher.

onevcat avatar onevcat commented on July 19, 2024

@edolorenza

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.

edolorenza avatar edolorenza commented on July 19, 2024

@onevcat

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.

onevcat avatar onevcat commented on July 19, 2024

I am closing this since we have already known the reason behind it.

from kingfisher.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.