On Thu, Sep 12, 2013 at 6:50 PM, Vivien Nicolas <
vnic...@mozilla.com> wrote:
> One of the goal of Haida is to take advantages of our webbish nature and of
> the strenght of our implementation. Beside that there is also a new
> navigation model, a revamped UI, an omniscient urlbar, new various platform
> features, etc.
Thanks for sharing this. For those of us on the app development side,
I got the impression the move to sheets was coming more quickly,
particularly when I saw bugs like 922653 filed. That made me nervous,
as there is still a lot of uncertainty about the dev structure.
However, after re-reading this note's likely targets for each release
and talking to Josh at the Summit, the actual dev changes for sheets
seems to be a few trains in the future, particularly since more UX
work needs to go into how running sheets/apps are grouped for user
navigation.
Until there is more UX work to define some of those things, here are
some notes on some technology pieces that may worth investigating in
the meantime.
I do not expect that we should discuss these items further here on
this thread now, just want to plant some seeds for people doing the
technical investigation for Haida:
I would really like to see us do a deep dive into using Service
Workers[1], as I believe it will help improve a few things for us.
First, a quick summary of a Service Worker: think of it as a local
HTTP server/proxy server, but instead of using network connections, it
uses a JS event API to receive "requests" for resources. It is
currently specified as a shared worker too.
Possible uses for Service Workers in the context of Gaia:
1) For app startup, since the app gets a chance to run JS before any
HTML parsing is done (once the Service Worker is installed), it means
that we can blast in an optimized HTML that is specific to the startup
request. For email, this means we could serve HTML that already shows
the message list before any app wiring for user interaction is done.
This would be a nice, formal replacement for the cookie hack we use
now, and avoids browser content paints from getting in the way of app
startup.
2) Most of the examples for Service Workers are in the context of a
better AppCache, but it does specify that a "method" on the request is
supported. If we can be sure to get good POST method support in, this
could be a better way to support app startup triggers that pass data.
So, alert, notification and web activity startups of an app.
Right now in email, we need to check for
navigator.mozHasPendingMessage() to decide what startup path to take,
then wait for our listener on navigator.mozSetMessageHandler() to be
called to finish startup work.
If we knew from the data in the incoming request immediately what the
app trigger was, we could get optimized HTML returned much faster for
initial paint, and avoid some event loop passes that could contain
unhelpful paints.
If each of those app triggers came in a POST to the Service Worker, it
may mean that we do not need mozSetMessageHandler or
mozHasPendingMessage, and may affect how activities are done.
3) Make sure main thread JS can get a handle on the shared worker used
for the Service Worker. Then we could use the Service Worker for the
"model" cases that Vivien wanted shared workers to do.
While a Service Worker, and any shared worker, should expect to be as
stateless as possible, for email I can see us keeping a local
in-memory cache in the Service Worker for some things, like account
info, since we need it for startup cases anyway. Similar to memcached
uses in traditional web servers. So I would want to use the Service
Worker as the shared worker mentioned in previous Haida
communications.
4) Make sure the Service Worker has a postMessage channel to any
existing window that may be the target for the Service Worker request.
Also an indication if that window already has a page loaded. This
allows the worker the ability to just poke the existing window's HTML
to do a small DOM change instead of serve back a full HTML page.
In summary, go Service Workers!
Related to previous tech discussion about possibly using a separate
HTML page for each "sheet" or card in an app UI:
I expect that to be less feasible from a UX visualization perspective
(showing a long list of every sheet clouds inter-apps nav) and there
are many card navigations that are not strictly "forward" in a card
stack.
Additionally, it does not translate at all to other web platforms. So
the story for web app developers about developing for a common stack
is a much harder sell. Doing a page refresh in those other web
platforms degrades the experience there.
One selling point for the "one window/HTML page per card" was to
improve on memory cleanup. I would rather see work done on diagnostic
tools for those cases, as there are use cases like games, and how the
web containers on other platforms work, where identifying memory
problems for long running UI will be generally useful. The startup
cost for a new window object in the "page per card" approach seems
much more expensive that adding some HTML to an existing page too.
However, that technical exploration does bring out some important
characteristics that make sense to pursue generally, and speak to the
goal of keeping apps web-like:
1) Apps should support having a URL structure that allows addressing
any card in their flow. This is important for app triggers like
notifications, alerts, activities. By using the history API, it also
works well in traditional browser containers that could have the "back
button" in the browser chrome.
2) Be able to support an app UX flow that does not have an explicit
back button, but rather depends on on gestures for back/forward
navigation control.
3) Allow for multiple app windows, particularly for app startup
triggers like notifications, alerts, activities. Once the app window
starts up, it may use its own history API approach and HTML fragment
navigation in a given window (not a page refresh or new window per
card), but the app should not expect that there is only one app window
on the platform for its UI.
For some web platforms (like native iOS/Android wrappers), a single
app window may be the use case, but it may not be on others (Firefox
OS, traditional desktop web browsers). See Service Worker item 4 for
something useful for the app to determine what path to take across web
platforms.
So I would be interested to see some JS helper scripts around history
API and gesture-based transitions, as well as animation primitives for
card navigations, all that could be used in an app.
For apps that did want to explore a separate HTML page per card
though, Service Workers seem to help that case. I just expect it to be
harder dev approach to justify for people making web apps to deploy
across web platforms besides just Firefox OS.
The above pathways are the ones I want to investigate for the email
app, and subject to my team's existing Gaia priorities, I am willing
to do some branches of the email app if, for example, there are
platform people putting in Service Workers and they want a larger
sized app to take it for a test drive.
[1]
https://github.com/slightlyoff/ServiceWorker
but see this for an intro:
https://github.com/slightlyoff/ServiceWorker/blob/master/explainer.md
James