Tim Southard February 2016

Including thousands of images in Xamarin Forms application

I have a xamarin forms project for the company I work for. I have 6000+ images used in two ways : a thumbnail page and a full size page. I have both the thumbnail image and the full size image. The thumbnail page shows 12 products at a time, but it lives in a carousel page so it could have up to 18 content pages within the carousel.

I've tried three ways of saving/accessing the images:

  1. Including them as bundle/android resources. This works the best but takes forever to build the project and on android will mean I have to use expansion files.
  2. Included the binary image from the database when downloading the product listing. Causes the app to crash randomly on download.
  3. Downloading all of the files from the web. This works, but on both Android and iOS, the thumbnail screen slows to a crawl and half of the time crashes on Android.

Has anyone had to do something similar and if so, what way did you decide to go? Unfortunately, this app does have to be usable offline so I need the images local. I'm kind of in a time crunch so any help would be appreciated!!

Answers


Daniel Luberda February 2016

I had similar issues someday back and understood that it won't be successful with standard Image class with such a large amount of images (no memory caching, no task queueing, etc). Then I made CachedImage. It's basically an API compatible replacement for Image with advanced caching capabilities (and some other features). You could try that.

Just remember to use:

  • Downsampling feature : that way image would be resized to view size to save memory
  • Caching feature (it's enabled by default not including StreamImageSource for which you have to provide custom cache key factory)
  • Use FileImageSource (app dir) or StreamImageSource (eg. from image database) with custom cache keys https://github.com/molinch/FFImageLoading (See WIKI for docs)

Post Status

Asked in February 2016
Viewed 3,198 times
Voted 11
Answered 1 times

Search




Leave an answer