On 12/04/2012 05:00, JOSE MANUEL CANTERA FONSECA wrote:
> El 12/04/12 12:43, "Vivien" <
2...@vingtetun.org> escribió:
>
>> The way it is prototyped in Gaia right now (in a coming pull request) is:
>> - manifest can contains a 'background_page' field that points to an url
>> - when the homescreen starts it reads the manifest and launch all the
>> background_pages urls into an invisible iframe.
>> - the code in the iframe can do whatever it wants without any
>> WebWorkers limitations, like using all the navigator APIs, etc. The
>> permission for the 'service' is the same as the permissions given for
>> the 'main' application.
>> - the service can open the main application by using
>> navigator.mozApps.mgtm.getSelf().launch(). (maybe we need a way to
>> specify parameters to the launch function)
>>
>> So as far as I understand this is similar to what you propose.
> This mechanism seems to be a hack but not a solution for a final product.
IMHO, As long as it is possible to resolve a problem without having
additional APIs that seems reasonable to me. If something can't be
solved by the existing APIs, I agree that a new one should be created.
This prototype is a web based solution that does not require any
additional APIs and allow Gaia to experiment and see what is missing
until there is a proper solution. But this prototype seems to cover 1.,
2. and 3.
The main question is: What are the limitations of this solution and what
can be provided by background service API that will not be provided by
this solution?
The service can be launched when the application is first installed even
without running the application.
The service can be started when the front-end start and restart with it.
It is possible to kill the service if there is a memory pressure event
at some point (I'm not aware of such event btw) by simply removing the
frame from the dom.
The service runs in the same thread as the homescreen and can spawn
workers if it needs to do any intensive computing tasks.
The background page runs into its own scope and have access to all the
dom/js APIs and share the same origin/permissions than the application
it comes from. So both the service and the application can share data
(via indexedDB for example).
The service can no touch the scope of any other apps/services.
> In addition it seems you want to continue increasing the intelligence of
> the Homescreen and I think that's not the way to go.
This is a very different discussion but about the intelligence of the
homescreen, I will be happy to split its brain into more modular pieces
and services are something that goes into this direction.
For now the homescreen has always be the entry point of Gaia but it is
possible to imagine starting on $GAIA/index.html and let this start page
manages all the windows (iframes) and services itself. It can start the
homescreen (ideally via an intent) that will end up beeing a simple
application to launch other applications using mozApps.launch(). It can
also starts other system services to manage the brightness for example.
That will make the homescreen application much easier to replace without
touching the functionalities of the system itself.