1

Background

I'm working on a browser addon (webextension API), which is cross-browser (Firefox & Chromium/Chrome/Blink).

I need to use browser.storage.sync (chrome.storage.sync on Chrome) to storage so that data can be synced.

storage.sync limits storage size (128kB), so I've tried these JS compressing library:

(lzutf8 compression results a smaller size)

Using the compress library

Above two both support uint8Array output, but when I tried storing uint8Array into storage.sync they got about 10 times bigger, obviously not really stored in uint8 format.

Then I found compressing to string is the best way to store:

Y1 = LZUTF8.compress(input-data, {outputEncoding: "StorageBinaryString"});
Y2 = LZString.compressToUTF16(input-data)

( Both Y are UTF16 string )

Question

Storing the compressed data Y (string) into Firefox (78) and Chromium (90), the space it occupies in storage.sync different:

  • in Firefox: Bytes used = Y.length.
  • in Chromium: Bytes used = about 2-3 times larger than Y.length. WHY?

(The space used can be seen by storage.sync.getBytesInUse(). Both Firefox and Chromium have limitation of same quata: 128k bytes)

I need some explaination. I can't find any doc about how (and what object type) data is stored in storage.sync. Also, I'll appriciate if there is better compressing and storaging (sync supported) solution.

garywill
  • 21
  • 2

0 Answers0