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

Privacy Badger failed to initialize #2966

Closed
varuld opened this issue May 31, 2024 · 41 comments
Closed

Privacy Badger failed to initialize #2966

varuld opened this issue May 31, 2024 · 41 comments

Comments

@varuld
Copy link

varuld commented May 31, 2024

What is your browser and browser version?

Firefox_v126.0

What is broken and where?

All sites I visit e.g. 'eff.org', 'fsf.org' etc.

@ghostwords
Copy link
Member

ghostwords commented May 31, 2024

Hello and thank you for opening an issue!

When Privacy Badger says that it failed to initialize, could you take a screenshot of Privacy Badger's background page?

To open Privacy Badger's background page in Firefox:

  1. Navigate to about:debugging
  2. Click on "This Firefox"
  3. Scroll down to find the entry for Privacy Badger and click "Inspect"
  4. Select the Console tab

Let me know if you have any questions.

@varuld

This comment was marked as resolved.

@ghostwords

This comment was marked as resolved.

@ghostwords
Copy link
Member

Screenshot from 2024-05-31 09-25-45

@varuld
Copy link
Author

varuld commented May 31, 2024

This should be it
privacy_bagder_background_2

@ghostwords

This comment was marked as resolved.

@ghostwords

This comment was marked as resolved.

@varuld

This comment was marked as resolved.

@ghostwords
Copy link
Member

The screenshot only shows output from running the debugging command, which we don't need to do now. What I am looking for is the error that breaks Privacy Badger when Privacy Badger first starts up.

Could you visit about:addons and toggle Privacy Badger off and then back on?

And then could you take and post another screenshot of Privacy Badger's background page? No need to put in any debugging code. I just want to see the errors that come up by themselves.

@varuld
Copy link
Author

varuld commented May 31, 2024

This is the result
privacy_bagder_background_3

@ghostwords
Copy link
Member

It looks like your Firefox extension storage is failing to return an expected object. I am not sure why we don't see the complete error information ("stack trace"), or why we don't see the storage error. But that's what I think it is.

The good news, sort of, is that this kind of problem was happening before I added the logic to show the "failed to initialize" error message. It's just that before we didn't know that your Privacy Badger was broken, and now we do. So now that we know, we'll try to fix or work around this problem.

@ghostwords
Copy link
Member

This is related to #2954.

@varuld
Copy link
Author

varuld commented May 31, 2024

It looks like your Firefox extension storage is failing to return an expected object. I am not sure why we don't see the complete error information ("stack trace"), or why we don't see the storage error. But that's what I think it is.

The good news, sort of, is that this kind of problem was happening before I added the logic to show the "failed to initialize" error message. It's just that before we didn't know that your Privacy Badger was broken, and now we do. So now that we know, we'll try to fix or work around this problem.

Ping me if you need testing/triage on possible solutions.

@ghostwords ghostwords pinned this issue May 31, 2024
@ghostwords
Copy link
Member

If you use any other extensions, have you noticed anything strange about them? For example, your extension settings get reset to defaults after restarting the browser.

@ppseprus
Copy link

Having the "same" issue on Chrome, version 125.0.6422.142 (Official Build) (arm64)

But my background,js log is empty, and contradictorily, it says its ready... 🤔
Screenshot 2024-05-31 at 22 02 06

I've just refreshed my browser and before that I hade no issues at all.

No other extension is affected.

@ppseprus
Copy link

Actually, I tried restarting my browser for the nth time, and now I get this:

Unchecked runtime.lastError: No tab with id: 1509629437.
Screenshot 2024-05-31 at 22 06 24

@ghostwords

This comment was marked as outdated.

@ghostwords
Copy link
Member

ghostwords commented May 31, 2024

@ppseprus That looks like a screenshot of the dev tools console for Privacy Badger's popup. Could you try opening the dev tools console for Privacy Badger's background process, next time the red exclamation comes up?

To reach the background process in Chrome, visit chrome://extensions/, enable developer mode (in the upper right), and click on the "service worker" link inside Privacy Badger's listing.

@ppseprus
Copy link

ppseprus commented May 31, 2024

@ghostwords , it opens the same thing. I tried both ways (from extensions, clicking the service worker label AND the popup option in the dropdown.

Screenshot 2024-05-31 at 22 52 17

next time the red exclamation comes up?

Since I updated the browser about an hour ago, PB stopped working on every single tab. No matter which one I open up. I completely stopped working.

@ghostwords
Copy link
Member

What do you mean by "stopped working"? Is the popup blank?

Does restarting Privacy Badger help? To restart, visit chrome://extensions/ and toggle Privacy Badger off and then back on.

@ppseprus
Copy link

ppseprus commented May 31, 2024

This is what I have on every single tab:
Screenshot 2024-05-31 at 23 12 07

Does restarting Privacy Badger help?

Ahh... okay. I was restarting the browser. Restarting the extension works. Sorry. 😅

@ghostwords
Copy link
Member

ghostwords commented May 31, 2024

OK thank you!

I'll upload a workaround update shortly. I'll let you know when it goes live so that we can look if things got better. Might happen by tomorrow, but maybe Monday.

@ghostwords
Copy link
Member

Huh, I wonder if restarting the browser can somehow lead to this error. Like, something about extension storage not being ready even though extensions are already running and expect chrome.storage.local.get() to return an object, not undefined.

@varuld
Copy link
Author

varuld commented Jun 1, 2024

If you use any other extensions, have you noticed anything strange about them? For example, your extension settings get reset to defaults after restarting the browser.

I have not.
It may happen that there happening something of that sort, but I haven't noticed anything.

@ghostwords
Copy link
Member

ghostwords commented Jun 1, 2024

My latest theory is that there are two separate issues that people run into:

  • (1) Privacy Badger can take longer than ten seconds to finish initializing. This seems to happen on browser startup. We show the "failed to initialize" message on all pages, but we do in fact finish initializing successfully and everything is operational, except for the error badge and the error message in the popup.

  • (2) Privacy Badger sometimes fails to read from extension storage during its initialization. We show the "failed to initialize" message on all pages, and Privacy Badger is completely broken at this point. This is probably the more uncommon scenario. This was previously reported in Privacy Badger on Chrome on Linux consuming high CPU #2954.

As a workaround, users can restart Privacy Badger by visiting their browser's extensions management page, and toggling Privacy Badger off and then back on. I am not sure this workaround helps for (2) though, when PB fails to read from extension storage.

We're about to release a partial fix for (2), when PB fails to read from extension storage. Rather than failing completely, Privacy Badger will initialize as if freshly installed, with all settings at defaults. We won't show the new user welcome page though.

We are going to follow this up with a fix for (1) where we deactivate the "failed to initialize" error when PB does in fact finish initializing successfully.

Also for (1), I am going to look into if we can do anything about Privacy Badger taking longer than ten seconds to initialize.

Also for (2), I am going to look into retrying reading from extension storage, rather than giving up after the first attempt fails.

@whatinthenameofgod
Copy link

I am getting this exact issue now on Chrome.

@ghostwords
Copy link
Member

I am getting this exact issue now on Chrome.

Try restarting Privacy Badger by going to chrome://extensions and toggling Privacy Badger off and then back on.

@sunwolf01
Copy link

Same Problem with:
Firefox_v126.0.1
OS: Windows 10
probably 2nd theory (TypeError: can't convert undefined to object)
restarting of Privacy Badger is not solving the problem, nor restarting firefox - as well not working

@ghostwords
Copy link
Member

ghostwords commented Jun 1, 2024

probably 2nd theory (TypeError: can't convert undefined to object)

Yes, I think so. Then the following earlier posts apply to your problem:

The good news, sort of, is that this kind of problem was happening before I added the logic to show the "failed to initialize" error message. It's just that before we didn't know that your Privacy Badger was broken, and now we do. So now that we know, we'll try to fix or work around this problem.

#2966 (comment)

We're about to release a partial fix for (2), when PB fails to read from extension storage. Rather than failing completely, Privacy Badger will initialize as if freshly installed, with all settings at defaults. We won't show the new user welcome page though.

#2966 (comment)

We are waiting on approval from Mozilla, and that unfortunately always seems to take a few days these days.

@AndyPT
Copy link

AndyPT commented Jun 2, 2024

For reference, this has also been happening in Edge since last week.
Microsoft Edge 125.0.2535.67 (Official build) (64-bit)
Chromium version 125.0.6422.112
Windows 11 (non insider build)

@willaaa
Copy link

willaaa commented Jun 2, 2024

I am getting this exact issue now on Chrome.

Try restarting Privacy Badger by going to chrome://extensions and toggling Privacy Badger off and then back on.

This worked for me

@g-rodigy
Copy link

g-rodigy commented Jun 3, 2024

Try restarting Privacy Badger by going to chrome://extensions and toggling Privacy Badger off and then back on.

It worked, but sometimes not the first restart

@g-rodigy

This comment was marked as off-topic.

@ghostwords

This comment was marked as resolved.

@ghostwords
Copy link
Member

We're about to release a partial fix for (2), when PB fails to read from extension storage. Rather than failing completely, Privacy Badger will initialize as if freshly installed, with all settings at defaults. We won't show the new user welcome page though.

We are going to follow this up with a fix for (1) where we deactivate the "failed to initialize" error when PB does in fact finish initializing successfully.

These fixes are live as of Privacy Badger version 2024.6.3.

Thanks everybody for your help and patience!

@ghostwords
Copy link
Member

ghostwords commented Jun 6, 2024

I'm still looking into followup improvements.

Also for (1), I am going to look into if we can do anything about Privacy Badger taking longer than ten seconds to initialize.

The initialization delays seem to come from trying to read from "managed" extension storage.

The chrome.storage.managed.get() call can take a wildly long time to come back when done during browser startup, like ten seconds or longer. I can reproduce this behavior in MV2, but it might have gotten worse in MV3.

We may be able to work around this browser bug by not waiting to read from managed storage. Unfortunately, this means that users' policy-set preferences will not get applied until some time after websites and Privacy Badger both got going. But if it's between Privacy Badger not being ready to do its job for 10+ seconds on browser startup for all users, and Privacy Badger failing to apply admin policy-set preferences until 10+ seconds on browser setup for admin policy users, I think the latter is the less-bad option.

Also for (2), I am going to look into retrying reading from extension storage, rather than giving up after the first attempt fails.

Apparently, regular extension storage can silently fail and return undefined instead of the expected object when calling chrome.storage.local.get() during browser startup. We worked around this by having PB use default settings, which is better than failing completely. We will add limited retrying to reading from extension storage so that if your PB fails to read from storage on startup, it may take a second or two longer to initialize but with your actual local settings read and applied.

@AndyPT
Copy link

AndyPT commented Jun 6, 2024

Things seem to be working for Edge also (at least no error message shown).
Thank you!

@ghostwords ghostwords unpinned this issue Jun 8, 2024
@Aenimus
Copy link

Aenimus commented Jun 11, 2024

I am getting the same issue no matter how many times I restart privacy badger or my browser.

Chrome: Version 125.0.6422.142 (Official Build) (arm64)
Privacy Badger: 2024.6.3

@ghostwords
Copy link
Member

Hi @Aenimus, could you open a new issue please? We are going to want to debug what's going on, but I don't want to reuse this thread, as the "failed to initialize" problem seems to be fixed for most users.

@Aenimus
Copy link

Aenimus commented Jun 11, 2024

Understood and my apologies @ghostwords.
#2979 for reference.

@ghostwords
Copy link
Member

ghostwords commented Jun 19, 2024

The followup improvements described in #2966 (comment) are live as of Privacy Badger version 2024.6.14.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants