Constant CPU usage, increasing memory usage, killing the browser

I have made same test. Without extension 4-8GB RAM (10-100 opened tabs).
With extension after while crash after 46GB RAM consumed.

@luckyrat Using Firefox builtin debugger I dumped console.
There are some errors, cant these be somehow related to memory leak?

@luckyrat any update? it is really annoying bug
other people confirmed this eg. Drive4ik at https://github.com/kee-org/browser-addon/issues/252

Another proof: Just disabled addon in running Firefox, 2 seconds later 10GB RAM saved

As short term workaround there could be in settings ā€œReload extension every x minā€ with editable x. And set timer to call https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/reload or chrome.extension.getBackgroundPage().window.location.reload(); as stated at https://stackoverflow.com/questions/13104360/how-to-restart-a-chrome-extension-automatically

We can set it to eg 30min to free memory until bug will be found.
Its not clean solution, but still far better than crashing browser :confused:

Thanks for your research @mnaiman

I prefer the approach suggested in the answer to that stack overflow question. A standalone extension that forces Kee to reload would be easier to maintain (delete) in the long run. Might be worth considering if the action should be user-initiated from the addonā€™s browser-action button? An automatic reload at the wrong time could potentially cause all sorts of bugs or even lead to to data loss (e.g. if an entry save operation is underway at the time). I think there is now an ā€œidleā€ API in WebExtensions so perhaps looking for a lack of user activity is another way to approach it. If someone wants to develop that under the kee-org GitHub repo, let me know and I can set up a repo for hosting the code.

As for whether I can provide an update, the situation is still the same as it has been for many months. Thereā€™s no indication that the cause of this problem is the Kee code and I canā€™t see any way to reproduce it in any environment I have access to. Last time I looked on my Windows 10 machine, I saw no memory growth for many days. Now, itā€™s tough to keep that machine on for more than a few hours but I will attempt a further test next week just in case something has changed, but given the extreme values being mentioned by a few people, I wouldnā€™t expect this to be something that is reproducible outside of a very specific environment which I do not have (or know).

While I still donā€™t rule out that there could be something Kee is doing which is exacerbating another bug in an extension, plugin, browser, application or operating system, I have no way to investigate this. As I said earlier, without more information about the system environment and websites that trigger this problem, I will not be able to investigate any further. Of course, for those of you who do see the issue, I am happy to provide assistance if you can narrow down the issue to some specific code path using something like Firefox Profiler (I understand this tool is much improved in the past year or two so perhaps it is now useful for this sort of diagnosis work, although I have very limited experience with it myself).

I tried to make Kee Reload Extension but Firefox Webextension API doesnt allow for security reason from one extension to enable/disable other, with exception to themes https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/management/setEnabled (The function allows enabling/disabling of theme addons, but will return an error if used to enable or disable other types of web extension.).

One viable option could be this API https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/runtime/sendMessage
In Kee there will be listener for message ā€œreloadā€ or ā€œenableā€/ā€œdisableā€ and Kee will perform this action. Second extension will in configurable schedule sending message to Kee.
Kee can handle all your concerns like data integrity, that user is not in the middle of creating new entry etc.

User action is bad step. I can take user action even now with enable/disable button. But who wants to this this every hour to prevent browser crash?

Im going to help you to find true source of bug by trying to find reproducible way to simulate memory leak. It will take huge amount time given fact that it takes time to let memory grow.

First observation.
I took 3 days of running before RAM starting to rise on environment with 50+ tabs.
I happened on 3 clean virtual machines with Firefox and Kee except for last where there is Firefox running without Kee. So far delta is 2GB (from 8 to 10GB).
It starts with no interaction, just running.

Some thoughts to help narrow down the contributing factors for some future VMs in the coming weeks:

  1. Does it behave differently when Kee is connected to:
    • KeePass
    • Kee Vault (you can use the free demo)
    • both
    • neither?
  2. Does the Firefox instance without Kee also have other extensions installed?
  3. Does it behave the same even with zero tabs open (just the new tab page)?

User action is bad step. I can take user action even now with enable/disable button.

Good point. Scrap that idea.

One viable option could be this API runtime.sendMessage() - Mozilla | MDN

This might be a feasible workaround if we can ensure that only this one specific extension is able to trigger the action. I couldnā€™t quickly see how to do that but it may become clear how to do this during implementation I suppose.

  1. First observation. No difference between KeePass and KeeVault.
    So it doesnt make sense to try both.
    Going to try neither.

  2. Firefox instance without Kee is ok. No other extensions installed.

  3. Going to try, my guess is it will be ok.

A few days ago I stumbled upon a website that caused Firefox to occupy 1 CPU core and consume all the memory within a minute or so as soon as I started using Kee. This behaviour was triggered by starting KeePass and loading a database after the website had been loaded in Firefox.

Here is a way to reproduce the CPU usage and memory consumption in a clean Firefox profile:

(Windows 10 version 1809 x64, German with Firefox 80.0.1 x64, German)

  • KeePass is not running/not installed.
  • Create new Firefox Profile with default settings by running ā€œC:\Program Files\Mozilla Firefox\firefox.exeā€ -p
  • Run Firefox with this new profile.
  • Install the Kee Add-on and keep its default settings.
  • Open https://www.1und1.de und wait until the site has loaded. You donā€™t have to
    store the cookie preferences.
  • Click on the Kee-Button in the Toolbar to open the drop-down window.

This occupies 1 CPU core completely und uses up all the RAM. I reproduced the same behaviour in a virtual machine.

Can anyone reproduce this behaviour?

https://bugzilla.mozilla.org/show_bug.cgi?id=1652925 may be relevant to those people that suffer from memory leaks when using browser extensions like Kee.

That fix should make it into Firefox 84. Combined with some speed improvements in Kee 3.6 Iā€™m hopeful that fewer people will notice degraded performance by the end of the year.