Skip to content

Commit 4fd4699

Browse files
Code2Collapseclaude
andcommitted
OmniBar: kill startup re-render storm + stop getSettingValue deprecation spam
Two perf bugs that froze the browser tab ("Brave crashing"): - _getSetting passed a 2nd arg to getSettingValue, which recent ComfyUI deprecates and warns on EVERY call. Dropped the arg (fall back locally). - Every C2C setting's onChange called _applyPositionAndMode synchronously, and each call re-renders ALL sections (each reading many settings). ~50 settings registering at startup => hundreds of full re-renders in one tick. Now coalesced to one render per animation frame via rAF debounce. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> (cherry picked from commit 8cf65f5)
1 parent 5a11356 commit 4fd4699

1 file changed

Lines changed: 19 additions & 4 deletions

File tree

js/c2c_omnibar.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ function _reportFailure(where, err) {
107107
// ── Setting helpers ─────────────────────────────────────────────────────────
108108
function _getSetting(id, fallback) {
109109
try {
110-
const v = app?.ui?.settings?.getSettingValue?.(id, fallback);
110+
// NOTE: do NOT pass a 2nd arg — recent ComfyUI deprecates the
111+
// defaultValue parameter and logs a warning on EVERY call (this ran
112+
// hundreds of times at startup via the section re-render path).
113+
const v = app?.ui?.settings?.getSettingValue?.(id);
111114
return (v === undefined || v === null) ? fallback : v;
112115
} catch (err) {
113116
_reportFailure("getSetting:" + id, err);
@@ -902,11 +905,23 @@ function _clearInlineEdges(root) {
902905
}
903906

904907
// ── Mount / re-mount / apply position ──────────────────────────────────────
908+
let _applyRAF = 0;
905909
function _applyPositionAndMode() {
910+
// PERF: every C2C setting's onChange used to call this synchronously, and
911+
// each call re-renders ALL sections (each reading many settings). At startup
912+
// ~50 settings register back-to-back → hundreds of full re-renders in one
913+
// tick, which froze the tab (reported "Brave crashing"). Coalesce into one
914+
// render per animation frame.
915+
if (_applyRAF) return;
916+
_applyRAF = requestAnimationFrame(() => {
917+
_applyRAF = 0;
918+
try { _applyPositionAndModeNow(); }
919+
catch (err) { _reportFailure("_applyPositionAndModeNow", err); }
920+
});
921+
}
922+
function _applyPositionAndModeNow() {
906923
// New architecture: the OmniBar surface is (1) a single pill injected
907-
// into the Manager bar, and (2) an anchored dropdown panel. Position /
908-
// density settings no longer affect the bar layout (kept for backward
909-
// compat only). This function:
924+
// into the Manager bar, and (2) an anchored dropdown panel. This:
910925
// • ensures the pill is in the Manager bar (or removed if hidden)
911926
// • re-renders all sections so newly-registered slots appear
912927
// • if the panel is open, repositions it under the pill

0 commit comments

Comments
 (0)