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

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

Merged
merged 6 commits into from
Sep 9, 2024

Conversation

smalluban
Copy link
Collaborator

@smalluban smalluban commented Sep 6, 2024

Relates to #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 smalluban requested review from chrmod, philipp-classen and GRadziejewski and removed request for GRadziejewski September 6, 2024 12:20
@smalluban
Copy link
Collaborator Author

@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
Copy link
Collaborator Author

@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).

@GRadziejewski GRadziejewski added the package CI: create extension packages label Sep 9, 2024
@GRadziejewski
Copy link
Contributor

Smoke tests Iteration no 1:

Tests of: #1865 (comment)


Checked features:

  • Enable/Disable Ad-blocking
  • Enable/Disable Anti-tracking
  • Enable/Disable Never Consent
  • Pause Ghostery
  • Regional filters
  • Check YT
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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package CI: create extension packages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants