mozilla-b2g/gaia — pull request #7008 by davidflanagan (2012-12-14 00:19:22+00:00)
Title: Bugs 819182 and 808470: MediaDB scanning and enumeration improvements

This pull request fixes two gallery bugs that are related to MediaDB. I've merged them into one pull request for ease of review and because as two separate PRs they would conflict with each other.

MediaDB gets new methods, in particular a getAll() method for much faster enumeration().

It also has some new behavior, but this new behavior only happens if you set options when you create the MediaDB object, so it should not affect existing clients of the library.

Bug 819182 was about startup performance. With hundreds of photos, gallery was unacceptably slow to start, and scanning didn't complete until after enumeration finished. With this patch, enumeration is now much faster. We don't even start the scan until enumeration is done, but we still end up finishing much sooner than we did before. I've tested with 750 photos and new photos from the camera are visible within 10 seconds of app startup time. This is something like a 5-fold improvement.

Bug 808470 was about the jumpiness of the scanning process. This patch fixes it by batching the changes. Instead of creating new thumbnails one at a time as the scan returns new files, it tweaks the MediaDB parameters so it gets new files in batches. There is a related change to prevent flicker in single-photo view while scanning is going on as well.

The patch includes a new spinner animation displayed while Gallery is enumerating files and creating thumbnails.

The patch also includes a minor change to visiblity_monitor.js. I ended up not using the new feature, but I've kept in in there because I expect it to be useful in the future or for other apps.

Finally, I've taken this opportunity to remove the old and now unused media_db.js version of MediaDB.