Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InvalidStateError: A mutation operation was attempted on a database that did not allow mutations. #141

Closed
8 tasks done
daspri opened this issue Jul 22, 2018 · 58 comments
Closed
8 tasks done
Labels
bug Something isn't working Firefox specific to Firefox fixed issue has been addressed

Comments

@daspri
Copy link

daspri commented Jul 22, 2018

Prerequisites

  • I verified that this is not a filter issue
  • This is not a support issue or a question
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue
    • Your issue may already be reported.
  • I tried to reproduce the issue when...
    • uBlock Origin is the only extension
    • uBlock Origin with default lists/settings
    • using a new, unmodified browser profile
  • I am running the latest version of uBlock Origin
  • I checked the documentation to understand that the issue I report is not a normal behavior

Description

Fails to update filters

A specific URL where the issue occurs

moz-extension://d879bf29-1bac-4212-8cbb-be53485d7ab0/dashboard.html

Steps to Reproduce

Open Firefox's "Browser Console" to see the error

  1. Go to Filter Lists
  2. Click 'Update Now'

Expected behavior:

Filters should update.

Actual behavior:

Filters do not update.

XHRGET https://raw.githubusercontent.com/gorhill/uBlock/master/assets/assets.json?_=212819
XHRGET https://publicsuffix.org/list/public_suffix_list.dat?_=212819
XHRGET https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/filters.txt?_=212819
XHRGET https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/badware.txt?_=212819
XHRGET https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/privacy.txt?_=212819
XHRGET https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/resource-abuse.txt?_=212819
XHRGET https://raw.githubusercontent.com/uBlockOrigin/uAssets/master/filters/unbreak.txt?_=212819
XHRGET https://easylist.to/easylist/easylist.txt?_=212819
15:53:46.412 [uBlock0CacheStorage] <unavailable>
vapi-cachestorage.js:94:9
genericErrorHandler
moz-extension://d879bf29-1bac-4212-8cbb-be53485d7ab0/js/vapi-cachestorage.js:94:9
XHRGET https://easylist.to/easylist/easyprivacy.txt?_=212819
[HTTP/2.0 200 OK 16ms]
15:53:46.993  InvalidStateError: A mutation operation was attempted on a database that did not allow mutations. vapi-cachestorage.js:230
putToDb/<
moz-extension://d879bf29-1bac-4212-8cbb-be53485d7ab0/js/vapi-cachestorage.js:230:17
getDb
moz-extension://d879bf29-1bac-4212-8cbb-be53485d7ab0/js/vapi-cachestorage.js:115:20
putToDb
moz-extension://d879bf29-1bac-4212-8cbb-be53485d7ab0/js/vapi-cachestorage.js:219:9
set
moz-extension://d879bf29-1bac-4212-8cbb-be53485d7ab0/js/vapi-cachestorage.js:77:9
onReady
moz-extension://d879bf29-1bac-4212-8cbb-be53485d7ab0/js/assets.js:533:9
getAssetCacheRegistry
moz-extension://d879bf29-1bac-4212-8cbb-be53485d7ab0/js/assets.js:426:9
assetCacheWrite
moz-extension://d879bf29-1bac-4212-8cbb-be53485d7ab0/js/assets.js:536:5
onRemoteContentLoaded
moz-extension://d879bf29-1bac-4212-8cbb-be53485d7ab0/js/assets.js:791:9
onLocalLoadSuccess
moz-extension://d879bf29-1bac-4212-8cbb-be53485d7ab0/js/assets.js:217:9
onLoadEvent
moz-extension://d879bf29-1bac-4212-8cbb-be53485d7ab0/js/assets.js:128:9

Your environment

  • uBlock Origin version:
  • Browser Name and version:
  • Operating System and version:

uBlock Origin v1.16.14
Firefox 61.0.1
Windows 7 x64

@gwarser
Copy link

gwarser commented Jul 23, 2018

gorhill/uBlock#2985

How much free disk space you have?

@daspri
Copy link
Author

daspri commented Jul 23, 2018

118,292,480 bytes free on that firefox drive

(browser.cache.disk.parent_directory is on a different drive with much more free space)

@gorhill
Copy link
Member

gorhill commented Jul 23, 2018

Not much I will be able to do, apparently Firefox errors when uBO tries to write to the indexedDB.

If you search for firefox "A mutation operation was attempted on a database that did not allow mutations", you will find plenty of results. You may want to look into this. For example, did you set dom.indexedDB.enabled to false in about:config?

@daspri
Copy link
Author

daspri commented Jul 23, 2018

No, that setting is still set "true".

If I disable EasyList and restart firefox and Update Now, the update completes.

If I then Purge Cache and Update Now, it fails with the same error but after a different list (unbreak).

Briefly searching for this error mentions the dom.indexedDB.enabled setting (which I have set "true"), but results also suggest it can be caused by not waiting for an objectstore to be created before using it (async operations).

@uBlock-user uBlock-user added unable to reproduce cannot reproduce the issue Firefox specific to Firefox labels Jul 23, 2018
@uBlock-user
Copy link
Contributor

uBlock-user commented Jul 23, 2018

Can't reproduce. Filters updating as expected. Reset Firefox settings to default(including the ones you set in about:config) and try again.

@gwarser
Copy link

gwarser commented Jul 23, 2018

118,292,480 bytes free

~120 megabytes? I have problems with filters update on my Android when free space is below ~350MB

@gorhill
Copy link
Member

gorhill commented Jul 23, 2018

According to Browser storage limits and eviction criteria, the global limit is 50% of free disk space, so ~60 MB in the current case.

From this, there is a group limit, which if I understand correctly is that at most 20% of the global limit can by assigned to uBO, so 12 MB in the current case. So yes, it does seem like an issue with low disk space.

@gwarser
Copy link

gwarser commented Jul 23, 2018

@gorhill it is possible to detect this case and show some dialog?

@gorhill
Copy link
Member

gorhill commented Jul 23, 2018

It's kind of a catastrophic error, the documentation said:

The group limit is also called the "hard limit": it doesn't trigger origin eviction

When this occurs, there is no fallback possible. This occurs deep in the code, when using Firefox API, and there might be no uBO UI available, aside the icon in the toolbar (assuming it has not been hidden by the user).

At this point, if I am going to throw lot of coding work at this, I rather work on the feasibility of compressing the data so as to reduce the storage footprint -- well it would be nice if Firefox's implementation of indexedDB did this for everybody.

At this point however, those suffering that sort of issue will have to free disk space. In the current case, ~120 MB is atypically low, regardless of uBO.

@gwarser
Copy link

gwarser commented Jul 23, 2018

When this happens filter lists are shown as outdated and when I click on "Update now" animation is spinning indefinitely - a way to fix only this case?

@gorhill
Copy link
Member

gorhill commented Jul 23, 2018

when I click on "Update now" animation is spinning indefinitely - a way to fix only this case?

From what I see in the call stack above, this fails at the database level, not at the transaction level. There are error handlers at the transaction level. But it's a bit more complicated at the database level because the handlers at that level do not know about which callers need to be notified. It just means it's possible but not trivial to fix this. If I instead work on compressing (assuming feasability), this would possibly prevent uBO from failing (except in even more extreme cases of low disk space).

@gwarser
Copy link

gwarser commented Jul 23, 2018

I can reproduce after filling my disk by dd if=/dev/zero of=zero bs=1M and then updating filters:

Browser console log
14:14:22.938 [uBlock0CacheStorage] 
abort
​
bubbles: true
​
cancelBubble: false
​
cancelable: false
​
composed: false
​
currentTarget: null
​
defaultPrevented: false
​
eventPhase: 0
​
explicitOriginalTarget: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
isTrusted: true
​
originalTarget: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
srcElement: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
target: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
timeStamp: 1038957
​
type: "abort"
​
<prototype>: EventPrototype { composedPath: composedPath(), stopPropagation: stopPropagation(), stopImmediatePropagation: stopImmediatePropagation(), … }
vapi-cachestorage.js:94:9
genericErrorHandler
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:94:9
(Async: EventHandlerNonNull) getDb/req.onsuccess
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:152:13
(Async: EventHandlerNonNull) getDb
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:149:9
vAPI.cacheStorage<
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:55:5
<anonymous>
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:41:22
14:14:23.104 [uBlock0CacheStorage] 
abort
​
bubbles: true
​
cancelBubble: false
​
cancelable: false
​
composed: false
​
currentTarget: null
​
defaultPrevented: false
​
eventPhase: 0
​
explicitOriginalTarget: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
isTrusted: true
​
originalTarget: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
srcElement: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
target: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
timeStamp: 1039123
​
type: "abort"
​
<prototype>: EventPrototype { composedPath: composedPath(), stopPropagation: stopPropagation(), stopImmediatePropagation: stopImmediatePropagation(), … }
vapi-cachestorage.js:94:9
genericErrorHandler
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:94:9
(Async: EventHandlerNonNull) getDb/req.onsuccess
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:152:13
(Async: EventHandlerNonNull) getDb
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:149:9
vAPI.cacheStorage<
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:55:5
<anonymous>
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:41:22
14:14:34.596 [uBlock0CacheStorage] 
abort
​
bubbles: true
​
cancelBubble: false
​
cancelable: false
​
composed: false
​
currentTarget: null
​
defaultPrevented: false
​
eventPhase: 0
​
explicitOriginalTarget: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
isTrusted: true
​
originalTarget: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
srcElement: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
target: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
timeStamp: 1050616
​
type: "abort"
​
<prototype>: EventPrototype { composedPath: composedPath(), stopPropagation: stopPropagation(), stopImmediatePropagation: stopImmediatePropagation(), … }
vapi-cachestorage.js:94:9
genericErrorHandler
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:94:9
(Async: EventHandlerNonNull) getDb/req.onsuccess
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:152:13
(Async: EventHandlerNonNull) getDb
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:149:9
vAPI.cacheStorage<
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:55:5
<anonymous>
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:41:22
14:14:34.628 [uBlock0CacheStorage] 
abort
​
bubbles: true
​
cancelBubble: false
​
cancelable: false
​
composed: false
​
currentTarget: null
​
defaultPrevented: false
​
eventPhase: 0
​
explicitOriginalTarget: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
isTrusted: true
​
originalTarget: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
srcElement: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
target: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
timeStamp: 1050646
​
type: "abort"
​
<prototype>: EventPrototype { composedPath: composedPath(), stopPropagation: stopPropagation(), stopImmediatePropagation: stopImmediatePropagation(), … }
vapi-cachestorage.js:94:9
genericErrorHandler
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:94:9
(Async: EventHandlerNonNull) getDb/req.onsuccess
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:152:13
(Async: EventHandlerNonNull) getDb
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:149:9
vAPI.cacheStorage<
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:55:5
<anonymous>
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:41:22
14:14:34.910 [uBlock0CacheStorage] 
abort
​
bubbles: true
​
cancelBubble: false
​
cancelable: false
​
composed: false
​
currentTarget: null
​
defaultPrevented: false
​
eventPhase: 0
​
explicitOriginalTarget: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
isTrusted: true
​
originalTarget: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
srcElement: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
target: IDBTransaction { mode: "readwrite", db: IDBDatabase, error: DOMException, … }
​
timeStamp: 1050928
​
type: "abort"
​
<prototype>: EventPrototype { composedPath: composedPath(), stopPropagation: stopPropagation(), stopImmediatePropagation: stopImmediatePropagation(), … }
vapi-cachestorage.js:94:9
genericErrorHandler
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:94:9
(Async: EventHandlerNonNull) getDb/req.onsuccess
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:152:13
(Async: EventHandlerNonNull) getDb
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:149:9
vAPI.cacheStorage<
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:55:5
<anonymous>
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:41:22
14:14:35.038 [Show/hide message details.] InvalidStateError: A mutation operation was attempted on a database that did not allow mutations. vapi-cachestorage.js:230
putToDb/<
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:230:17
getDb
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:115:20
putToDb
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:219:9
set
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/vapi-cachestorage.js:77:9
onReady
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/assets.js:533:9
getAssetCacheRegistry
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/assets.js:426:9
assetCacheWrite
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/assets.js:536:5
onRemoteContentLoaded
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/assets.js:791:9
onLocalLoadSuccess
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/assets.js:217:9
onLoadEvent
moz-extension://a41ed17e-8cfa-48fa-8853-8be569753609/js/assets.js:128:9

@gwarser gwarser removed the unable to reproduce cannot reproduce the issue label Jul 23, 2018
@gorhill
Copy link
Member

gorhill commented Jul 23, 2018

I can reproduce after filling my disk

Isn't a scary thing to try? I fear the desktop/OS is going to start to fail badly before I can even get to try to repro.

@uBlock-user
Copy link
Contributor

How is it a bug if you have to fill your hard disk just to reproduce it ? If your hard disk is at its limit, any software is expected to malfunction.

@gorhill
Copy link
Member

gorhill commented Jul 23, 2018

Well the point is maybe uBO should at least stop spinning endlessly in its UI, though the core issue though would still be there: an essentially defect uBO because of low disk space.

@gwarser
Copy link

gwarser commented Jul 23, 2018

Isn't a scary thing to try?

:)
@gorhill I have all Firefox test browsers as portable in home (partition) subfolder.
And even for / there should be still space reserved for root user.

@uBlock-user this happens to me frequently on Android when my free disk space fall bellow ~350MB This is 2014 phone with only 4GB of disk space total and bellow 1GB for user. Updating apps may cause this and you will not even know when this happens until ads starts appearing. And you will not know why because there is no message, no browser console, just animation spinning. One time I left my phone with uBO Dashboard enabled for the night to check if something change.

@gorhill
Copy link
Member

gorhill commented Jul 23, 2018

Ok I will come up with something. Since there is not always a UI available (ex. when auto-update kicks in, or selfie is taken, etc.), I am thinking of showing a red warning on the Settings page (where the "Storage used" area) for when the "mutation operation was attempted" error occurs -- which could be caused by other reasons than just low-disk space I suppose. That warning would be cleared whenever a write operation succeed.

@daspri
Copy link
Author

daspri commented Jul 23, 2018

My Firefox profile is on a virtual encrypted disk (vera/true) & portable, therefore not as large as the full drive. (cache is not on the same drive)

@gorhill
Copy link
Member

gorhill commented Jul 23, 2018

when I click on "Update now" animation is spinning indefinitely - a way to fix only this case?

Looking at the code, I am not seeing why this would be. When uBO writes to the storage, it does so without minding the result. Are you sure about "indefinitely"? Can I see a screenshot of the console, I want to see if there is an unhandled exception, so far what I see is all handled by uBO.

@gorhill
Copy link
Member

gorhill commented Jul 23, 2018

I can reproduce now. Found an old 1GB stick, created a new Firefox profile on it, and filled the stick with a 800MB file, there is around ~60 MB left. I get the errors now in the console, so now I have something to work with.

@gwarser
Copy link

gwarser commented Jul 23, 2018

One solution may be to go back to extension storage (should not have limits) - Mozilla will move backend to IndexedDB soon https://bugzilla.mozilla.org/show_bug.cgi?id=1474562
User will see low disk space before uBO starts to have problems.

Are you sure about "indefinitely"?

Yes, I even once leave phone for the night with it spinning.

@gwarser
Copy link

gwarser commented Jul 23, 2018

Screenshots

30 minutes later and still spinning.

@uBlock-user uBlock-user added the bug Something isn't working label Jul 23, 2018
@gorhill
Copy link
Member

gorhill commented Jul 23, 2018

One solution may be to go back to extension storage

Using storage.local instead of indexedDB is irrelevant. If I want more disk space given to uBO, I need to add the unlimitedStorage permission.

So far I have resisted adding this permission because of how this was received by some users when Privacy Badger added it to their manifest .

In any case, now that I can reproduce I found out that there is an exception thrown, and this is trivially handled. uBO should still work fine without being able to use its cache (up to a point), this will just cause it to launch less efficiently since it might have to re-compile all filter lists every time.

The errors will still be written at the console, but there should no longer be unhandled exceptions.

gorhill added a commit to gorhill/uBlock that referenced this issue Jul 23, 2018
@gorhill
Copy link
Member

gorhill commented Aug 5, 2018

I read the data through a XMLHttpRequest in the demo/benchmark page, and feed an ArrayBuffer to the WebAssembly engine. In the extension code I use WebAssembly.instantiateStreaming.

I actually did not try XMLHttpRequest in the extension code, I figure this would not be allowed because one could XMLHttpRequest to anywhere and use the bytes from the response to execute code from any origin -- so I stuck with the spirit of executing-code-only-from-the-package, anything else which would happen to work would quite certainly be an issue to fix in Firefox.

@grenzor
Copy link

grenzor commented Aug 5, 2018

Really interesting results!

Just out of curiosity, did node-lz4 have slower compression/decompression speeds than lz4-wasm? Also are the benchmarks using LZ4-HC equivalent settings or default/other?

@gorhill
Copy link
Member

gorhill commented Aug 5, 2018

node-lz4 is included in the benchmark page.

lz4-wasm is the generic implementation of LZ4 block format, with hard-coded default, no HC there.

I simplified a bit the compressor implementation by not putting in code for detecting incompressible data, but even without this it's faster than node-lz4, and beside I wrote that code specifically for the purpose here and I do not expect that incompressible data is going to be an occurrence.

@gwarser
Copy link

gwarser commented Aug 6, 2018

My findings:

Looks like Firefox stores lots of nulls in database:

Size of *.sqlite file (only) on my standard Nightly profile with latest uBO rc was ~40MB.
After switch to lz4 branch (reset to default + restore backup) size decreased to 150kB - turned out most data is stored inside *.files subfolder - only ~11MB! (with selfie)

I thought something is broken, but filter lists are recent and all seems to work fine.

I switched back to rc - *.sqlite 41MB, *.files 7MB.

Side note: storage.local is stored in second folder, with ^userContextId=* appended - ~70kB.

And I just confirmed this in fresh profile - lz4 branch uses ~11MB of disk space, latest rc 41MB of *.sqlite and 7MB in *.files without selfie, 12MB with selfie.

selectedFilterLists
  "selectedFilterLists": [
    "https://raw.githubusercontent.com/MajkiIT/polish-ads-filter/master/adblock_social_filters/adblock_social_list.txt",
    "https://raw.githubusercontent.com/MajkiIT/polish-ads-filter/master/cookies_filters/adblock_cookies.txt",
    "https://raw.githubusercontent.com/olegwukr/polish-privacy-filters/master/adblock.txt",
    "https://gist.githubusercontent.com/gorhill/ef1b62d606473c68d524/raw/f8181faac18cb5172c7c9bca8e5a3b22f0c925d0/gistfile1.txt",
    "POL-0",
    "plowe-0",
    "fanboy-social",
    "fanboy-thirdparty_social",
    "fanboy-annoyance",
    "adguard-annoyance",
    "malware-1",
    "malware-0",
    "fanboy-enhanced",
    "easyprivacy",
    "adguard-spyware",
    "easylist",
    "adguard-generic",
    "ublock-unbreak",
    "ublock-abuse",
    "ublock-privacy",
    "ublock-experimental",
    "ublock-badware",
    "ublock-annoyances",
    "ublock-filters",
    "user-filters"
  ]

gorhill added a commit to gorhill/uBlock that referenced this issue Aug 6, 2018
…-issues#141)

Squashed commit of the following:

commit 6a84738
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Mon Aug 6 10:56:44 2018 -0400

    remove remnant of snappyjs and spurious instruction

commit 9a4b709
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Mon Aug 6 09:48:58 2018 -0400

    make cache storage compression optionally available on all platforms

    New advanced setting: `cacheStorageCompression`. Default is `false`.

commit 22ee654
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Sun Aug 5 19:16:26 2018 -0400

    remove Chromium from lz4 experiment

commit ee3e201
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Sun Aug 5 18:52:43 2018 -0400

    import lz4-block-codec.wasm library

commit 883a311
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Sun Aug 5 18:50:46 2018 -0400

    implement storage compression through lz4-wasm [draft]

commit 48d1cca
Merge: 8ae77e6 b34c897
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Sat Aug 4 08:56:51 2018 -0400

    Merge branch 'master' of github.com:gorhill/uBlock into lz4

commit 8ae77e6
Author: Raymond Hill <rhill@raymondhill.net>
Date:   Wed Jul 25 18:17:45 2018 -0400

    experiment with compression
@jspenguin2017
Copy link

WOW, you actually coded the compression library in assembly?!

@uBlock-user
Copy link
Contributor

uBlock-user commented Aug 11, 2018

Updated to the latest dev build, set cacheStorageCompression to true, purged all cache and redownloaded all my lists, storage size on Chromium was 27 megs(assuming this as the point of reference for comparison because FF doesn't support getBytesInUse API yet and now with the workaround in place) and now on Firefox it's 9.9 megs!! Impressive!

@yourduskquibbles
Copy link

I am showing a 3X size reduction as well, storage size was 15megs and is now 5megs with cacheStorageCompression set to true. Great work!

@gwarser
Copy link

gwarser commented Aug 11, 2018

Correction (update) to my comment about database size - my Nightly finally decided to put something inside *.sqlite file. Now it's *.sqlite: 16MB, *.files: 12MB
uBO reports: Storage used: 16,277,060 bytes

No idea why this happened - I cannot reproduce in fresh profile...

@gorhill
Copy link
Member

gorhill commented Aug 11, 2018

Sounds like the load selfie to me. Note that when you enable cacheStorageCompression, uBO will compress opportunistically from there on, it will not go through the storage to compress existing entries, just when something is written to it. If you want to find out the difference after toggling the setting, purge all caches and force an update. Also, eventually the selfie will be also written to the storage after all filter lists are updated,

@ghost
Copy link

ghost commented Aug 12, 2018

Changed setting "cacheStorageCompression" to true, then went to purge and finally added my lists, before 11 megs and now 4 megs (close to 3x size reduction!), using Firefox 62 Beta on Android, works!

@gorhill
Copy link
Member

gorhill commented Aug 12, 2018

I used the Gecko profiler to find out how compression affects load time of uBO. I measured with a selfie available (which I consider the most likely scenario for majority of users). Tested using a desktop computer with an SSD drive.

I repeated the disabling/enabling of uBO three times in the profiler, with enough time in between to ensure clearly separate instances in the profiler. I filtered out the profiler output using moz-, uBO was the only extension installed.

As a result there were three clear regions of CPU usage, corresponding to uBO being launched and doing its work to load everything in memory. I then focused the profiler timeline to match exactly the start and end of each of those regions, using the magnifier to increase the granularity until the timeline was matching exactly the start/end of uBO doing its launch work. This allowed me to find out the length in time of the focused region.

This is the results:

  • Without compression:

    • 317 ms
    • 322 ms
    • 306 ms
  • With compression:

    • 300 ms
    • 307 ms
    • 294 ms

Those figures indicates that despite the added overhead of having to lz4-decode the loaded data, uBO loaded faster. In the Gecko profiler results, I could definitely see an area of idleness in the middle which has been shrunk when using compression, enough to gain faster load despite the lz4-decoding overhead. Below are comparative screenshots, you can see the area of idleness in the middle being reduced when compression is used (bottom graph):

a

@gwarser
Copy link

gwarser commented Aug 12, 2018

there were three clear regions of CPU usage

Not sure if you know this, these blue "hills" in the graph are not cpu usage. This is stack size. Even low "height" may use lot of cpu.

https://perf-html.io/docs/#/./guide-ui-tour?id=timeline39s-thread-stack-graph

@uBlock-user
Copy link
Contributor

There's a performance-wise gain too when force updating filterlists, previously it would take a second or two for it to complete, now it downloads and updates the lists instantaneously and snappier even on Chromium.

@gorhill
Copy link
Member

gorhill commented Aug 14, 2018

The original issue has been addressed, the compression won't ever guarantee that running low on disk space will never affect uBO, so at this point I consider the issue fixed.

@gorhill gorhill closed this as completed Aug 14, 2018
@gwarser gwarser added the fixed issue has been addressed label Aug 14, 2018
@shellye5
Copy link

@gorhill sometimes filters take long to download with compression on any ideas on how to debug it?
Are you enabling it soon?
will this come to legacy too?

@Vangelis66
Copy link

... Apologies if this isn't the proper place to post about my predicament, but I was directed to this issue via the Release Notes of the latest dev build...

OS: Windows Vista SP2 32-bit
Browser: Mozilla Firefox ESR 52.9.0 32-bit
uBlockOrigin version: dev channel, v1.16.21b0 (WE)

I was updated to the latest dev build from a previous dev build (from memory, must've been 1.16.17.7) which is now removed from the GitHub repo.

I opened the dashboard and tried to manually update 3rd-party filters; the "clocks" at the far right of each list all started spinning but after a few (3-4) seconds all turned simultaneously into an orange triangle (with a white exclamation mark inside), then, after another 2-3 seconds, all went back into the "clock" state...

This behaviour I had never witnessed previously, after some checks it looked as though my lists hadn't updated 😭 E.g., the "I don't care about cookies" list remained at v2.8.8, while I checked and v2.8.9 is already on line at its site...

From looking closer at the release notes of 1.16.21b0, I saw

A new advanced setting: cacheStorageCompression, default to true.
When true, uBO will lz4-compress data before storing it in its cache storage in supported platforms.
Currently, the only supported platform is Firefox/Firefox for Android.

By launching Firefox Browser Console (CTRL+SHIFT+J), clearing everything inside it and starting a manual 3rd-party filter list update, the console is populated with many Error: LZ4BlockWASM: not initialized instances:

brconsole

I do hope they're meaningful to someone of you wonderful people...

For now, my options to successfully update 3rd-party filter lists on my setup are tested to be:

  1. Access "advanced user" settings, toggle the new pref cacheStorageCompression to false, apply changes and then the update of lists will work...
  2. Downgrade to the latest version (1.16.20=1.16.18) of the stable channel, where cacheStorageCompression is either absent/not enabled by default.
  3. Downgrade to the latest legacy (XUL) version, 1.16.4.4, installable on 52.9.0 - sadly, it isn't backwards compatible with the WE versions, hence I'd have to reconfigure it from scratch...

I understand that I don't have things on my side, as Vista has been EOL'd by MS and Fx 52.9.0 will be EOL'd by Mozilla in over a week's time... However, any insight as to what's the cause of this new issue will be highly appreciated...

Many thanks in advance....

@gwarser
Copy link

gwarser commented Aug 29, 2018

Downgrade to the latest legacy (XUL) version, 1.16.4.4, installable on 52.9.0 - sadly, it isn't backwards compatible with the WE versions, hence I'd have to reconfigure it from scratch...

This is recommended.
You can export your settings to file and import in new installation.

@gwarser
Copy link

gwarser commented Aug 29, 2018

I only get this in console in 64bit Firefox:

ReferenceError: WebAssembly is not defined[Learn More] lz4-block-codec-wasm.js:126:1

Filters are not updated, something may be wrong with fallback js code.

You may experience this #150

MDN says:

WebAssembly.Instance
Disabled in the Firefox 52 Extended Support Release (ESR).

After switching on javascript.options.wasm I get now:

Error: LZ4BlockWASM: not initialized lz4-block-codec-wasm.js:166:19

BTW, this issue is resolved, you should create new one.

gorhill added a commit to gorhill/uBlock that referenced this issue Aug 29, 2018
@Vangelis66
Copy link

@gwarser

Huge thanks for taking the time looking into my reported issue 👍

Filters are not updated, something may be wrong with fallback js code.

You may experience this #150

I read all the discussion there, but I got the sense - I could be wrong, I know nothing about javascript language - that it did not pertain directly to my problem, despite being a FxESR 52.9.0 issue (but on Linux...); thanks all the same for the reference!

WebAssembly.Instance
Disabled in the Firefox 52 Extended Support Release (ESR).

After switching on javascript.options.wasm

For some obscure reason, I had already

javascript.options.wasm;true
javascript.options.wasm_baselinejit;true

inside about:config; I don't recall me toggling those specific prefs (but I may have simply forgotten, as the ESR cycle is many months old...), so perhaps this is possibly the work of an extension?

BTW, this issue is resolved, you should create new one.

... Because of my marginal setup (EOL'd Windows OS, soon-to-be EOL'd Fx version, 32-bitness of OS (hence browser)), I wasn't really sure, to begin with, whether the new "compressing" code was meant to be compatible with my setup (or even tested in a non-Quantum Fx flavour and/or in a 32-bit browser build), so I opted to first post here, apologising in advance if inappropriate 😉 ...
Once confirmed here this was a genuine new bug the devs were interested looking into, I'd have gladly created a new (separate) issue for it... But I was preempted by events:

gorhill/uBlock@3c187c6

@gorhill

I just updated to the newest dev build, v1.16.21b1 and can confirm that filter lists update now works as it should with cacheStorageCompression=true; attaching Browser Console excerpt as proof:
17_01_38.847 GET.txt

A sterling job indeed, hugely valued! 👍 🥇

@Vangelis66
Copy link

@gwarser

You can export your settings to file and import in new installation.

Thanks for this tip, I'm sure I knew it already, but (originally) posting late at night and under some frustration doesn't help much in my growing age...

Just to confirm, do the filter-list storage files the WE version saves inside ./profile/storage/default/* get somehow translated to the format of files the XUL version stores inside ./profile/extension-data/* when one downgrades from WE -> XUL and imports settings, as per your suggestion?

@gwarser
Copy link

gwarser commented Aug 29, 2018

Settings exported by clicking in uBO Settings tab on "Back up to file" button will be saved in special portable text format (json) and will contain all uBO settings and addresses of filter lists you are subscribed to. One thing missing will be your statistics (request blocked since install).

@resistor4u
Copy link

I'm on 1.16.20 on Firefox 61.0.2 on Mac OS 10.11.6, and I'm unable to set cacheStorageCompression true in the Advanced settings - when I add and apply the settings, cacheStorageCompression disappears. Anyone else getting this?

@gwarser
Copy link

gwarser commented Sep 4, 2018

This feature is in beta tested now. You can install uBO development builds for Firefox from here https://github.com/gorhill/ublock/releases

@resistor4u
Copy link

@gwarser if so, then perhaps the wiki documentation (https://github.com/gorhill/uBlock/wiki/Advanced-settings) should be changed? There, it says the feature is for "uBO 1.16.17b and above."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Firefox specific to Firefox fixed issue has been addressed
Projects
None yet
Development

No branches or pull requests

10 participants