Preload large PNGs to reduce UI stutter?
Posted: 01 Sep 2021, 12:29
When I open a view containing large PNGs, the UI pauses (the animations stutter) while they are loaded and processed. These particular PNGs are not specified in the XAML; the ImageSource can change so it is a bound value.
I've managed to reduce the problem to it only happening the first time I use any particular PNGs by caching the Ptr<BitmapImage> used by filename. So for a particular PNG, like "test1.png", the same Ptr<BitmapImage> will be returned. I'm guessing Noesis recognises this and uses its internal cache to get the PNG data previously loaded..
There is a point in the code where I could preload these images without any ill effect. Is there any way I can get Noesis to preload and preprocess the BitmapImage in code without having to do some horrible hack like rending all the files invisibly in a parent view?
I currently do bitmapImage->Init() when I cache it, which I can see calls the TextureProvider to get info like width and height ... if only there was a similar call to load and process the whole thing... Or to shell that processes out to a thread..?
Thanks!
I've managed to reduce the problem to it only happening the first time I use any particular PNGs by caching the Ptr<BitmapImage> used by filename. So for a particular PNG, like "test1.png", the same Ptr<BitmapImage> will be returned. I'm guessing Noesis recognises this and uses its internal cache to get the PNG data previously loaded..
There is a point in the code where I could preload these images without any ill effect. Is there any way I can get Noesis to preload and preprocess the BitmapImage in code without having to do some horrible hack like rending all the files invisibly in a parent view?
I currently do bitmapImage->Init() when I cache it, which I can see calls the TextureProvider to get info like width and height ... if only there was a similar call to load and process the whole thing... Or to shell that processes out to a thread..?
Thanks!