On 02/12/2013 12:07 AM, Lucas Adamski wrote:
> For example, email seems to take forever loading what seems like my entire inbox. What's the most common use-case for an email app? Probably open, scan the last 5-10 new emails, maybe reply to one, and close again. We should optimize for that via incremental loading with read-ahead.
>
> Read only the first two to five pages worth of data, and more as the user starts scrolling to keep ahead of the view. We don't need to keep loading if the user isn't scrolling. Even if the view sometimes has to catch up, its a better optimization than wasting battery, memory and the user's time loading a ton of data. 99% of which the user will not look at. These are patterns that other mobile platforms have already built in, and we are reinventing them from scratch unfortunately.
E-mail already does all this. If you open your Inbox that has already
been synced in the last hour, or while navigator.onLine returns false
(which gets broken if Marionette is enabled on your device, apparently),
the 15 most recent messages known to the device will be displayed and
then a refresh sync will be performed. Then incremental fetches will be
queued in the background immediately and as you scroll to maintain a
minimum padding of 2 screens worth of messages.
Unfortunately, most of the time the refresh mode of operation does not
fire. Early on, operating on my understanding of our UX goals and
consultation with UX, I implemented an additional sync heuristic that in
order to not jerk the user around by either showing them old messages
and having them need to scroll through a ton of messages to get to the
new ones, or showing them old messages and then instantaneously warping
them when the sync completes, we would first require some server sync to
complete first. The idea was that periodic background sync should help
avoid that heuristic needing to trigger all the time. (Unfortunately,
although initial implementation of periodic background sync happened, we
out-of-scoped it because the notifications and such were going to be
trouble.)
That clearly turns out to have been a bad call, so I've been correcting
the problem on bug
https://bugzilla.mozilla.org/show_bug.cgi?id=822882.
As a heads-up, when that lands, you are going to potentially need to
scroll through a boatload of messages to get to the newest ones unless
we add some additional UI affordances.
The other big problem of course is just e-mail's startup time because of
all the code we load. Thanks to the JS team's improvements to JS source
compression (we were taking 1.1 seconds to re-compress the extracted JS
source from the compressed app zip) and Gaia team work to minify things
so the JS engine has less work to do, e-mail app startup prior to when
the database becomes an issue is also being improved. And we have other
plans too, but new/re-prioritized features are getting thrown at us much
faster than engineering manpower is.
Andrew
PS: The e-mail app even goes so far as to consolidate headers and bodies
into blocks to leverage the fact that we are using Snappy compression on
a per-key/value basis and in recognition of the fact that our IndexedDB
is backed by SQLite which is page-centric with a 32k page-size as
configured.