espresso3389 / pdfrx

pdfrx is yet another PDF viewer implementation that built on the top of pdfium. The plugin currently supports Android, iOS, Windows, macOS, Linux, and Web.
MIT License
60 stars 36 forks source link

Provide an optional function to clear the cache #123

Closed zengchanghuan closed 2 weeks ago

zengchanghuan commented 1 month ago

In high-configuration apps, I can choose not to clear the cache, but in low-configuration apps, I can actively clear the cache.

yhyh0 commented 1 month ago

In high-configuration apps, I can choose not to clear the cache, but in low-configuration apps, I can actively clear the cache.

Not sure what you mean by high/low-configuration apps, but we probably shouldn't expose a function to "clear" the cache. I think it's a bit more about the language/framework environment we are in --- if it's C, then why not? But it's dart/Flutter, it might be better to stick with something like cacheExtent.

But wait.. are we only talking about FPDF_RenderPageBitmap here? If so, we definitely do not want to expose Pdfium's caching logic..

zengchanghuan commented 1 month ago

For example, on older Android and iPad devices (possibly manufactured around 10 years ago), which have very limited operating space, when running on older iOS devices, the iOS system detects memory usage. If there isn't enough memory, the system will automatically clear the cache, which makes it appear as if the app has crashed.

I totally agree not to expose Pdfium's caching logic.

espresso3389 commented 4 weeks ago

1.0.55 introduces certain memory consumption optimization. And there are several parameters that directly affects the memory consumption;

I think that clearing the cache explicitly degrades the viewer performance and you had better think the parameters explained above to control the cache behavior indirectly.