Treestyletab: Memory leak restoring a root tab when its child tab is present

Created on 8 Aug 2019  ·  6Comments  ·  Source: piroor/treestyletab

Short description

Steps to reproduce

  1. Start Firefox with clean profile.
  2. Install TST.
  3. Open a dummy tab. (so Firefox does not get closed after closing other tabs.)
  4. Open https://www.reddit.com/ as a root.
  5. Middle click any post in Reddit and open it as a child tab.
    Dummy tab Reddit front page (A) \- random reddit post (B)
  6. Close tab A. Then close tab B.
  7. Ctrl-Shift-T to restore tab B.
  8. Ctrl-Shift-T again to restore tab A.

    Expected result

    Both tabs would have restored correctly with no memory leaks.

    Actual result

    Memory usage blows up. Please refer to the screencast:
    https://gfycat.com/browndisfigureddrongo
    TST sidebar is unresponsive. I can only stop the leaking by closing Firefox.

    Notes

    1. There is no memory leaks if I restore the root first. (I.E. close tab B>A; restore A>B)
    2. This does not occur on every URLs. I tested http://example.com but it does not have the leak. If you cannot reproduce the issue with Reddit, I will try to provide another URL.

    Environment

    • Platform (OS): Windows 10 1903
    • Version of Firefox: Nightly 2019-08-08 20190808093310, Firefox 68.0.1
    • Version (or revision) of Tree Style Tab: 3.1.6
maybe fixed

Most helpful comment

I cannot reproduce this issue in 3.1.7 anymore. Thanks.

All 6 comments

The first affected TST version is 3.1.3 but somehow I hadn't encountered it until now despite using TST every day...

Is this related to https://github.com/piroor/treestyletab/issues/2340#issuecomment-519464422 ? The last comment seems to suggest the same method to reproduce the memory leak: by closing tabs and reopening them

Possibly I've narrowed down which code triggers the problem. The section https://github.com/piroor/treestyletab/blob/39c8d3ccc3e865c633a750327421ee8e2f2c3036/webextensions/background/tree-structure.js#L275-L286 looks that. After commented out these lines the CPU and memory bloat disappears on my environment.

Finally I've understood why a cyclic reference is produced on such cases.

TST has a function to operate newly opened tabs, and it also has a mechanism to attach such tabs to the active tab based on some configs. But it was not expected to handle any restored ancestor tab, and TST tried to attach a restored ancestor tab to an existing child tab.

Why guard mechanisms for such cyclic references didn't work? Because two operations are triggered on this case asynchronously.

  • TST tries to attach an existing child tab to the restored parent tab, based on its session information.
  • TST also tries to attach a newly opened tab to the active tab, because it can be opened a new child tab opened from the location bar or somewhere.

So I've introduced some guards to make TST more safe for such cases. Could you try the latest development build? > all

I cannot reproduce this issue in 3.1.7 anymore. Thanks.

Was this page helpful?
0 / 5 - 0 ratings