LearnNewsExamplesServices
Frontmatter
id9315
titleMain Thread: Hardware-Sync ResizeObserver with requestAnimationFrame
stateClosed
labels
enhancementai
assigneestobiu
createdAtFeb 26, 2026, 9:59 PM
updatedAtFeb 26, 2026, 10:00 PM
githubUrlhttps://github.com/neomjs/neo/issues/9315
authortobiu
commentsCount1
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
blockedBy[]
blocking[]
closedAtFeb 26, 2026, 10:00 PM

Main Thread: Hardware-Sync ResizeObserver with requestAnimationFrame

Closed v12.0.0 enhancementai
tobiu
tobiu commented on Feb 26, 2026, 9:59 PM

The main.addon.ResizeObserver currently fires a postMessage to the App Worker every single time the native browser ResizeObserver triggers. During continuous layout thrashing (e.g., resizing the browser window), this can fire multiple times per frame, flooding the worker bridge with redundant intermediate layout data.

While the App Worker can defend against this (e.g., using delayable or manual locks), it is structurally better to throttle at the source.

This ticket tracks the implementation of a Map + requestAnimationFrame (rAF) buffer inside main.addon.ResizeObserver.

  • The Map ensures that if multiple elements resize, or an element resizes multiple times before a paint, we only retain the final state for each unique node.
  • The rAF lock ensures we only dispatch the accumulated postMessage payload exactly once per physical display frame (vsync), establishing a global protective dam for the App Worker.
tobiu added the enhancement label on Feb 26, 2026, 9:59 PM
tobiu added the ai label on Feb 26, 2026, 9:59 PM
tobiu referenced in commit 36a91ef - "Main Thread: Hardware-Sync ResizeObserver with requestAnimationFrame (#9315) on Feb 26, 2026, 9:59 PM
tobiu
tobiu Feb 26, 2026, 9:59 PM

Input from Gemini 3.1 Pro:

✦ I have pushed the architectural enhancement to dev.

The Map + rAF throttle is now active on the Main Thread ResizeObserver, acting as a hardware-synced dam that protects the App Worker from layout thrashing while guaranteeing zero dropped targets.

I also added the requested Knowledge Base Enhancement Strategy JSDoc to document the "why" behind this pattern.

I will close this ticket.

tobiu assigned to @tobiu on Feb 26, 2026, 9:59 PM
tobiu closed this issue on Feb 26, 2026, 10:00 PM