Skip to content
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

Improve cache re-use on FillWidth composables with Precision.INEXACT #2766

Open
vitorpamplona opened this issue Dec 28, 2024 · 0 comments
Open

Comments

@vitorpamplona
Copy link

vitorpamplona commented Dec 28, 2024

Is your feature request related to a problem? Please describe.

I believe the Output image dimensions are now enforced to be less than 4096x4096 to guard against accidental OOMs feature added a side effect that is making the library miss memory caches and reloads from disk every time a composable with FillWidth and flexible height is used (say inside a LazyColumn). The log shows an error like: Memory cached image's size (1202, 2137) is smaller than the target size (1013, 4096). This cache should have been used because the image's width is appropriate for the target size and the height is flexible, so the height difference between 2137 and 4096 (which is the ad-hoc value) should not have been considered in the MemoryCacheService's isCacheValueValidForSize function.

In the current code, the cache is not valid simply because the Scale is FILL (because it was a FillWidth composable) but the height doesn't have what it needs to be able to FILL in both dimensions (width and height). Without the 4096 protections, this was addressed by having the target's height equals toInt.MAX_VALUE

Describe the solution you'd like

We should find a way to document that the 4096 is a max limit for composables and it should be treated like Int.MAX_VALUE for the sake of the cache qualification algorithm.

@vitorpamplona vitorpamplona added the enhancement New feature or request label Dec 28, 2024
@vitorpamplona vitorpamplona changed the title Improve cache re-use on FillWidth composables. Improve cache re-use on FillWidth composables with Precision.INEXACT Dec 28, 2024
@colinrtwhite colinrtwhite removed the enhancement New feature or request label Jan 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants