CloudServices/FirefoxMobileServices
Overview
Mozilla Cloud Services (MCS) requires client-side portions for Firefox OS, and Firefox on Android (Fennec) that will need to be delivered on a separate release schedule from the product itself. Firefox Mobile Services (FMS) are a set of API's that will allow new client-side components of MCS to run in Firefox OS as a special component that runs independently of FxOS's parent loop but supplies a Preferences panels.
This project proposal is to provide a way for Mozilla Cloud Services to have an established way to push new services out (without bogging down FxOS releases) to increase the service-based capabilities of FxOS for app developers. It could be considered similar in spirit to Google Mobile Services on Android (except everything including the server-side service components are completely open-sourced).
The initial focus will be on creating the FMS API's for FxOS which can integrate with the Preferences panel, and the Service Workers that run each client-side service. At a later point a similar component with inter-process communication for Android should be created to expose similar functionality to web applications installed on Android devices.
Background
Currently the only way to integrate client-side code to handle communication with MCS requires landing code in large code-bases that are typically focused on other platform capabilities and bugs. MCS does not have B2G device developers under it, therefore landing code in B2G or Fennec is difficult and done in an ad-hoc manner for each task as it arises.
The two first projects at Cloud Services that added such code on the Firefox OS platform are SimplePush and Firefox Account
We're expecting that more projects will do the same in the future, and this wiki page describes the biggest problems that were encountered and how we can make this integration work faster & easier for every one.
Use Cases
Simple Push
XXX Existing implementation in xpcoms within gecko
see https://bugzilla.mozilla.org/show_bug.cgi?id=822712
Firefox Account Service
XXX ?
Presence Service
XXX
Talkilla
XXX
Firefox OS Integration
Adding features in Firefox OS can be done at several levels:
- by creating an open web app at one of the 3 permission level: normal, privileged and certified
- by extending Firefox OS at a lower level : Gecko, Gaia
The first solution offers a lot of advantages:
- updates are very easy
- applications can interact with most of the system using Web API
- we're coding in pure HTML5/Javascript
There are some pitfalls however:
- limited control when the application is in the background, which is the case for headless features
- security restrictions. For example we can't load another app's UI
- some restrictions in what can be done in sandboxed child processes (XXX elaborate)
The other option --extending the system at lower level-- has a few advantages:
- there are no restrictions whatsoever in what can be done
- the code is part of the B2G process, and is not treated like web apps. For example, it can be running in the background without fearing oomkiller
But the pitfalls are quite important:
- the feature becomes part of B2G and must follow its release lifecycle, and fast iterations become impossible: once it's part of the system it's there forever. What if we need to push a security patch asap for Firefox Account ?
- developing in the core is very hard for people outside the FFOS team because it's a moving target. It involves a lot of boiler plate code and knowledge, and is not about coding the web anymore (xpcom anyone? JSM?)
Proposal: Service Workers
We propose to add a new kind of worker in Firefox OS: Service Workers.
Service Workers are Web Workers that run in their own scope but with full chrome privileges -- like allow IDB, XHR etc
Services Workers can be defined in any web application, and are managed by a specialized component in Gecko: the Services Manager.
The Services Manager is responsible for the registration and lifecycle of Services Workers
XXX
Detailed Description
ServiceManager
XXX
ServiceWorker
XXX
References
Dump of useful links