SkImages / Texture cache

179 views
Skip to first unread message

Christian Falch

unread,
Feb 24, 2023, 6:24:21 AM2/24/23
to skia-discuss
Hi!

We've had some issues with the texture cache in Skia for SkImages in React Native Skia and have some questions about this.

The problem arose when a user had a few too many jpeg images on screen at the same time, causing the cache to start invalidating before all images were rendered. When animating this caused the invalidation and re-uploading if textures to the GPU to happen on each frame - causing a bit of a performance issue. 

We solved this specific issue by reducing the size and number of unique images, but would like to understand how we can improve this experience a bit.

After experimenting with using makeTextureImage we found that it was easy to solve this since we could control texture creation and bypass the cache. This gave us a few other issues that made us think it would be best to keep the current lazy and automatic texture upload through the cache.

To understand this we'd like to know why the current limit of around 200mb is set (same on all platforms it seems?) and if there would be any issues changing this (or even letting our users change it) - we believe it would be dependant on the GPU texture memory size? Which might not be available?

Thanks again for all your nice work!

Christian

Brian Osman

unread,
Feb 24, 2023, 8:31:02 AM2/24/23
to skia-d...@googlegroups.com
The default is really just a default (and it's arbitrary). You can certainly adjust it -- various Skia clients have wildly different needs, so many other clients do tune that value (based on device, platform, or the general requirements of their application). Skia doesn't have any API for getting the total GPU memory size (there isn't really a standard way to do that in OpenGL, although other APIs may offer that information via device queries). Often, clients will infer things about the device based on other properties, for example here's code in chromium that sets the resource cache size, based on coarse device classification.

--
You received this message because you are subscribed to the Google Groups "skia-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to skia-discuss...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/skia-discuss/9462eb6d-1b98-4c92-84ca-5441048fe525n%40googlegroups.com.

Christian Falch

unread,
Feb 27, 2023, 5:51:18 AM2/27/23
to skia-discuss
Thanks for the explanation!
Reply all
Reply to author
Forward
0 new messages