piroor / treestyletab

Tree Style Tab, Show tabs like a tree.
http://piro.sakura.ne.jp/xul/treestyletab/
Other
3.41k stars 276 forks source link

[Bug] 4.0.15 hangs on ESR #3557

Open DarthGandalf opened 1 month ago

DarthGandalf commented 1 month ago

Abstract

Since today TST is unusable on FF ESR 115.10.0 on Linux 64bit. It uses 400% CPU, and is either very slow, or just never successfully loads anymore, instead keeping blinking between showing progress bar and not showing. I tried to restart firefox several times, that's how having different results.

I see this in browser console

Key ext-key-id-treestyletab_piro_sakura_ne_jp-sidebar-action of menuitem Tree Style Tab could not be found menu.js:289:19
    accelText chrome://global/content/elements/menu.js:289
    _computeAccelTextFromKeyIfNeeded chrome://global/content/elements/menu.js:296
    render chrome://global/content/elements/menu.js:323
    <anonymous> chrome://global/content/elements/menu.js:170
AbortError: Actor 'Conduits' destroyed before query 'RunListener' was resolved
sendRemoveListener on closed conduit treestyletab@piro.sakura.ne.jp.5772436050333 ConduitsChild.sys.mjs:108
    _send resource://gre/modules/ConduitsChild.sys.mjs:108
    removeListener resource://gre/modules/ExtensionChild.sys.mjs:675
    removeListener resource://gre/modules/ExtensionChild.sys.mjs:940
    register chrome://extensions/content/child/ext-storage.js:175
    removeListener resource://gre/modules/ExtensionCommon.sys.mjs:2869
    revoke resource://gre/modules/ExtensionCommon.sys.mjs:2891
    close resource://gre/modules/ExtensionCommon.sys.mjs:2896
    unload resource://gre/modules/ExtensionCommon.sys.mjs:979
    unload resource://gre/modules/ExtensionPageChild.sys.mjs:282
    unload resource://gre/modules/ExtensionPageChild.sys.mjs:319
    destroyExtensionContext resource://gre/modules/ExtensionPageChild.sys.mjs:479
    observe resource://gre/modules/ExtensionPageChild.sys.mjs:388

I downgraded to 4.0.14 for now, and it works fine.

Steps to reproduce

  1. Have >1000 tabs
  2. Do nothing
  3. Let TST extension automatically update to 4.0.15

Expected result

Actual result

Environment

piroor commented 1 month ago

I've tried TST 4.0.15 + Firefox ESR 115.11.0 on Ubuntu 22.04 (on VirtualBox) but couldn't reproduce such a hanging. Could you collect a performance profile? https://github.com/piroor/treestyletab/wiki/How-to-inspect-tree-of-tabs#how-to-collect-a-performance-profile

DarthGandalf commented 1 month ago

Not sure what has changed since yesterday, but it managed to load at all today, though slow. It's still 4.0.15

Firefox 2024-05-23 12.13 profile.json.gz

piroor commented 1 month ago

Thanks, I've realized that a change introduced to follow Firefox's change https://bugzilla.mozilla.org/show_bug.cgi?id=1897595 triggers the problem.

emilio commented 1 month ago

The issue is that you're synchronously determining the overflow state on connectedCallback(), the right thing to do is to just let the ResizeObserver callback be invoked once (it will be), or use requestAnimationFrame to batch the initial observations.

piroor commented 1 month ago

@emilio Hmm, the initial "overflow" state is required to know when the state is actually changed, so the synchronous operation https://github.com/piroor/treestyletab/blob/9022cb07889cc5d5bcdd1341d01b32ad5027790d/webextensions/common/common.js#L994 looks still required... and of course I already throttled detecting "overflow" state on every observations. https://github.com/piroor/treestyletab/blob/9022cb07889cc5d5bcdd1341d01b32ad5027790d/webextensions/common/common.js#L1002

I can give up to determine the initial state but it looks to mean the initial resizing will be detected as "overflow" or "underflow" here https://github.com/piroor/treestyletab/blob/bf09c9827836ac36c078f2a207fa1ac287961079/webextensions/common/common.js#L1007 regardless the element's overflow state is actually changed or not.

piroor commented 1 month ago

Anyway this throttling may be effective to reduce needless style computations for tab elements inserted to the DOM tree and immediately removed by quick scrolling. https://github.com/piroor/treestyletab/commit/12359f7eb868b789fbe11181b52f84dbb027af64 @DarthGandalf Could you try the latest development build? https://github.com/piroor/treestyletab?tab=readme-ov-file#development-builds

DarthGandalf commented 1 month ago

I didn't really measure time, so can't compare whether it's faster than before. It at least finished loading, unlike yesterday :)

Firefox 2024-05-23 16.01 profile.json.gz

gotyaoi commented 1 month ago

I had noticed a performance degradation (specifically when scrolling up in the list of tabs) on 4.0.15 (firefox 126, windows 11). The development build makes it much better, though perhaps slightly slower than before 4.0.15.

piroor commented 1 month ago

With the commit 07bed44 now TST uses overflow/underflow events instead of ResizeObserver again if those events are available. Performance regression reported at here will go away until Firefox 128, but it is not a fundamental solution.

jayywolff commented 1 month ago

ive been able to reproduce this issue as well with only 70 tabs

on Arch Linux x86_64 Firefox 126.0.1 TST 4.0.15

edit, i bookmarked my tabs, closed all of them, even cleared all site cookies/data. and now even with just a single tab open here on github, TST just hangs and doesnt load at all. Just showing a loading bar (that appears to be about 20% complete) and flickers every 10-15 seconds.

edit 2: found a workaround after struggling with this for a few days:

@piroor looks like you added backward compatibility as a workaround already, when can we expect a TST update including https://github.com/piroor/treestyletab/commit/07bed443317e7a7a6c998f5b6aef19c03e9dd9c2