Browser crashes when modifying browser action popup with javascript


I am working on my first extension and I’m running into this strange problem.

The crash seems to be somewhat reliably triggered by me 1. clicking the toolbar icon, bringing the popup up, and then 2. hovering over the toolbar icon to bring up the little tooltip. The entire browser locks up and I have to ctrl-c web-ext and then start it again. It doesn’t happen every time I do this.

The popup dom consists of just a few lines of text and a button. I don’t have any action listeners yet.

In addition to the popup I have a content-script that adds a sort of pop-up div to the main website area dom, and makes some changes to the CSS. I don’t have any stability issues with this aspect of the extension.

When the freeze happens there is no extra output in the browser console nor the regular console.

I am completely stumped and any help would be greatly appreciated.

Edit: I should specify that the browser I am writing the extension for is Firefox, and also that I have not been able to trigger the crash after commenting out all javascript code that makes changes to the dom.

Please upload your extension somewhere, so that we can take a look at it.

Thanks for the prompt reply. Here is a link to the extension, hosted by a Nextcloud instance at my university:

I can’t reproduce the problem with:

  • Manjaro Linux
  • Firefox 103.0 (64-Bit)
  • running your extension with either “web-ext run” or “about:debugging > This Firefox > Load temporary add-on”

FWIW, I had a similar problem until a few days ago.
FF kept freezing randomly, so I disabled most extensions, and now it’s stable.

Oh, I really should have tested it on another Firefox install on another machine. I just tested on my laptop and it doesn’t seem to freeze there.

My understanding was that web-ext ran a ‘clean’ version of Firefox (no add-ons), and since I saw the freezing issue with and without add-ons that the problem was something bigger.

On the machine where I see the problem I run gentoo and a locally-compiled version of Firefox with some use flags enabled and some not. I suspect this might be the problem.

Anyway I really appreciate your help, and sorry for the bother.

Just a friendly reminder after seeing your code, the innerHTML is forbidden API in the addons:

Also, since popups are incredibly difficult to debug / work with, in Firefox, it’s better to open the popup HTML in a new tab during the development. It makes things much easier and less buggy.

You can place this to the background script for automatic opening after reload:

browser.tabs.create({url: 'popup/popup.html'});

Thank you, noted and much appreciated!

I also wanted to add that I too was not able to reproduce the problem on my laptop. However I do get the same issue on my desktop running the binary version of Firefox (I normally use a locally compiled version), so this means its not my use flags or anything.

I tried refreshing Firefox as well which had no effect.

I tried enabling safe mode and I no longer seem to experience the issue. According to --help safe mode “Disables extensions and themes”. My understanding is that web-ext does not run with extensions enabled anyway, so I am a little confused as to how it sidesteps the issue.

Anyway, just wanted to share on the off chance it is useful to someone.

Thanks again.