-
Notifications
You must be signed in to change notification settings - Fork 4
Batch compact-stacked wrapping detection to reduce forced reflows #359
Copy link
Copy link
Closed
Labels
Feature requestRequest for new feature or improvementRequest for new feature or improvement🏠 BasesAffects Obsidian Bases viewsAffects Obsidian Bases views🔍 DatacoreAffects Datacore query viewsAffects Datacore query views🟢 Low priorityWould be nice but not importantWould be nice but not important
Description
Problem
hasWrappedPairs() performs forced reflows inside ResizeObserver callbacks. The detection flow per card:
- Remove
compact-stackedclass - Force reflow (
void cardEl.offsetHeight) - Call
getBoundingClientRect()on every.pair-leftand.pair-right
With 50 visible compact cards each having 3-4 pairs, a pane resize triggers ~400 synchronous layout reads. The compactWidthCache WeakMap bounds this to once per unique width per card, but the first-time cost per width change remains O(pairs × cards).
Proposed solution
Batch the wrapping detection into a single read-then-write pass across all compact cards, matching the pattern syncResponsiveClasses already uses:
- Write phase: Remove
compact-stackedfrom all compact cards with cache misses - Single forced reflow
- Read phase: Run
hasWrappedPairs()on all cards, collect results - Write phase: Apply
compact-stackedwhere needed, update caches
This collapses N forced reflows into 1.
Affected code
src/bases/shared-renderer.ts— Bases per-card RO callbacksrc/shared/card-renderer.tsx— Datacore per-card RO callbacksrc/shared/property-helpers.ts—hasWrappedPairs()
Context
Session c3322c8e-cf10-459c-bc94-2060a0ef89ec — triaged as 5.2 (cache-bounded burst, marginal gain vs restructuring cost).
🤖 Generated with Claude Code
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Feature requestRequest for new feature or improvementRequest for new feature or improvement🏠 BasesAffects Obsidian Bases viewsAffects Obsidian Bases views🔍 DatacoreAffects Datacore query viewsAffects Datacore query views🟢 Low priorityWould be nice but not importantWould be nice but not important