Windowscommunitytoolkit: ImageEx Placeholder caching

Created on 4 Oct 2016  路  12Comments  路  Source: windows-toolkit/WindowsCommunityToolkit

When using a placeholder with ImageEx, we should aim to cache the placeholder since by the very definition, these do not change very often.

Once this is in place, the consumers would then be able to call PreCacheAsync and load this in memory rathan having to read from disc each time.

feature improvements open discussion

Most helpful comment

Or you can instruct devs to simply do something like this: https://gist.github.com/jurepurgar/91154c213bf907508438db09bf67e598, since usually there are just a few different placeholders.

All 12 comments

having looked at the source again, we only cache images if they have http source, placeholders are likely to be relative Uri.. maybe this needs a discussion rather

Aren't most placeholder images those that are stored in the appx anyway? Do they need caching?

I was thinking about the in-memory storage to prevent read from disc

Is that really that much of an issue?

I'd say that's subjective depending upon the number of images being loaded with placeholders..

Fair point.

Or you can instruct devs to simply do something like this: https://gist.github.com/jurepurgar/91154c213bf907508438db09bf67e598, since usually there are just a few different placeholders.

that is probably simpler by a long margin

Maybe we can add this to the sample app, to show how is it best to deal with placeholders for performance reasons.

good idea

Most users are probably already getting a basic form of in-memory placeholder caching supplied by the platform. If you straight bind a Uri to an ImageSource on a Image, or use BitmapImage.UriSource, the XAML platform automatically handles in-memory caching for you - so this should already be good as PlaceholderImage is a straight ImageSource binding.

(Ref: https://msdn.microsoft.com/en-gb/windows/uwp/debug-test-perf/optimize-animations-and-media#caching-optimizations )

Agree (This is the official @JohnnyWestlake 's day :))
I think we should not over engineer this .

Was this page helpful?
0 / 5 - 0 ratings