WebExtensions/chrome.storage.sync

From MozillaWiki
Jump to: navigation, search

Planning for implementing chrome.storage.sync for WebExtensions.

There are two components to this API: the API in Firefox and the backend storage servers. Prototype is done.

tl;dr an add-on developer can save some data related to the add-on and it is accessible to the same add-on for that user on different profiles and devices. See the Chrome docs for more.

Status

As of Jan 2017, chrome.storage.sync is now enabled by default.

Running a storage server imposes a long term financial and people burden on Mozilla. We intend to regularly review the storage server and see if it should be maintained. If it is shouldn't, an appropriate deprecation period and plan will be made.

We don't provide:

  • any guarantees about uptime
  • any guarantees about performance
  • any guarantees about data retention

The main use case of chrome.storage.sync is to store preferences about your add-on and allow the user to sync those to different profiles. That's why there is a low limit of the amount of data. Any usage beyond that is not encouraged and might cause problems in review.

There will likely be no further updates to this Wiki, for more information please see the MDN documentation.

Old information

As of Nov 2016, the first set of patches landed in Firefox 52 from 1220494, with a few caveats.

  • its behind a flag that you need to turn on in about:config (see testing below)
  • the production database server is not up and running yet, its using a test server and when we switch to the production server all test data will be lost

Testing

As of Nov 2016, there are a few settings you need to configure. Because this means going to about:config and changing settings, including your sync and Firefox Accounts, we strongly recommend doing this in a new Firefox profile.

  1. Go to about:config and modify webextensions.storage.sync.enabled and set it to true.
  2. Go to about:config and create a new string setting identity.fxaccounts.autoconfig.uri and set it to https://stable.dev.lcip.org
  3. Restart Firefox.
  4. Go to about:preferences and sign into sync.

You should now be up and running. We've got two unsigned extensions for testing this out:

  • Example one: Favourite Colour which adds an options UI page in and lets you alter an option in about:addons.
  • Example two: Augmented search which tracks your clicks on duckduckgo.com and presents a UI when you return to it later.

To force a sync you can click on the arrows in the hamburger menu.

Example test:

  • launch Firefox with a clean profile
  • set up the configuration as above and log into sync
  • using about:addons install favourite colour
  • in about:addons set a favourite colour
  • force a sync
  • close Firefox
  • launch Firefox with a new clean profile
  • set up the configuration as above and log into sync
  • using about:addons install favourite colour
  • force a sync
  • go to about:addons and the favourite colour should be set to the value set earlier

Noted that in early tests it can take a while for the forcing of the sync to get through to the addon.

Planning meetings

What Chrome does

You can test this by getting two Chrome browsers (e.g. stable and canary) and logging into them with the same or different accounts. A simple addon is favourite-colour from webextensions-examples, just replace chrome.storage.local with chrome.storage.sync.

These are some of the questions that came up in talking about chrome.storage.sync recently. Thought I'd give Chrome a try and see what happens.

  • What happens when you are offline?
    • The data is saved locally.
    • At some time when you go back on line it is synced up to the server.
  • What happens in conflict?
    • There is no conflict management on the keys as far as I can tell, it just writes over.
  • If you've changed something locally and there's a different value on the server, which one wins?
    • The one on the server.
  • What happens if you have no account?
    • The data is stored locally.
    • Nothing else as far as I can tell, no error, warning, nothing.
  • What happens if you have an account but are not logged in?
    • See above.
  • What happens when you change accounts?
    • If you've got some data locally and change accounts, the change comes down from the server and wipes yours out.

Chrome does not encrypt the data so scenarios around the encryption or changing of passwords and consequences that might have are not covered.

Questions

Outstanding

  • How long do we retain data?
    • undefined (product question)
  • When a user changes their password, will they lose access to all their encrypted data?
    • are we cool with that? (product question)
  • What's the SLA
    • undefined (product question)

Answered

  • Is people running their own storage server a priority?
    • (andym) No, but it would be nice if they could.
    • (tarek) There are 2 paths
  • Why Kinto over Sync?
    • Just because chrome.storage.sync has the word sync in it, please don't be confused, it has nothing to do with syncing the data in the same way that (for example) bookmarks or history does. It's just a key value store on the server that does no attempt to merge the data (please see above notes on how it works in Chrome).
    • The Kinto server stores the data in postgres RDS instead of Sync's ad-hoc Mysql deployment. RDS comes with data replication, meaning that we have less chances to lose data for users.
    • The internal Firefox Sync APIs aren't documented or stable, and are pretty hostile. There is no well-supported way for add-ons to integrate with Firefox Sync beyond just whitelisting prefs to be automatically synced.
  • Is there a way to clear out data?
    • (tarek) yes, that's a API call away with the proper permissions (version 2)
  • As a user can I see what data is stored by each add-on?
    • That possible, but currently no API is planned for that (version 2)
  • Edge cases
    • What happens when a user isn't logged in?
      • (tarek) we store stuff locally and don't sync them
    • What happens when the client goes offline?
      • (tarek) the client should gracefully wait for the next chance to sync with the server. The Kinto client has built-in offline first features.
    • How does it resolve when there's a conflict?
      • (andym) it doesn't, it just overwrites
  • Please see the notes about Chrome for some understanding of how Chrome does this. Let's be clear, it's pretty basic.

Code and Bugs

Bugs for porting this over can hang off 1220494:

Full Query
ID Priority Status Resolution Summary
1311510 P3 NEW chrome.storage.sync: performance test of production stack for chrome.storage.sync

1 Total; 1 Open (100%); 0 Resolved (0%); 0 Verified (0%);


Github tracking bug?

https://github.com/Kinto/kinto/issues/173 is one of them.

Storage servers

...Tarek to fill in.

The bugs for tracking the roll out are:

Timelines

  • Currently aiming for Firefox 51 for first milestone of something that works.
  • Stand up the client code, behind a feature flag, so that users have to flip it on in about:config
  • Stand up the servers.
  • Find some add-ons to be beta-testers.