ghostery / ghostery-extension

Ghostery Browser Extension for Firefox, Chrome, Opera, Edge and Safari
Mozilla Public License 2.0
1.39k stars 142 forks source link

fix: fallback to storage.local when IndexedDB is corrupted #1865

Closed smalluban closed 2 months ago

smalluban commented 2 months ago

Relates to https://github.com/ghostery/ghostery-extension/issues/1837

Fixes the issue for engines with corrupted IndexedDB in Firefox when history is globally disabled or private browsing is turned on globally.

It adds a fallback for the eninges to be stored in chrome.storage.local. As Firefox supports saving UnitArrays, the implementation is stratgh forward.

I tried few different approaches, but I think only two may apply - hardcoded fallback for Firefox for all users, or use "in-time" detection for each engine.

The first solution makes Firefox again a different, which I would like to avoid - we should keep the code the same as much as possible. Also, only a small group of users are affected by the Firefox bug.

The detection outside of the function and using a flag is hazardous. As the IndexedDB error message comes in asynchronius way, we cannot avoid a race condition, so the loadFromStorage function might be called before we set the flag.

The last argument is about how the getDB() already works. It saves the opened session to the database in getDB.current - as this is done only once, for the each access to the database, after it's once rejected, it rejects immeditelly.

smalluban commented 2 months ago

@GRadziejewski Testing highlights after technical review:

Chromium-based browsers and Safari should not be affected by any of the changes - it should work exactly as before - you can check if engines are loaded correctly (cosmetics).

On Firefox it should be exactly the same as above for default browser settings. However, if user disables history or creates a global private mode, without the change engines are loaded from disk each time background process starts. We can test both cases, but testing the latter is very difficult - loading unpacked extension in "no-history" mode fails (it is some internal Firefox bug) - you must use Firefox Nightly, set xpinstall.signatures.required in about:config to false, then use .zip to install the extension.

smalluban commented 2 months ago

@GRadziejewski There is technical approval. If possible, please test out the PR. There is a tip on how to test it faster, the extension can be installed form source, but you must enable it in private windows to make it work (then restart the extension).

github-actions[bot] commented 2 months ago

Builds for commit d5f2edf6cb69d3c2878a85c0755a599b9e6e7817:

GRadziejewski commented 2 months ago

Smoke tests Iteration no 1:

Tests of: https://github.com/ghostery/ghostery-extension/pull/1865#issuecomment-2337690735


Checked features:

Browser: Chrome 128.0.6613.120
OS: Windows 10
GBE 10.4.4

Browser: Firefox 130.0
OS: Windows 10
GBE 10.4.4

Browser: Firefox Nightly 132.0a1
OS: Windows 10
GBE 10.4.4

Issues:

Fixed:

Cannot reproduce:

Will not be fixed: