Optimize SharedTransitionScope active transition tracking
Avoid iterating over the full sharedElements map whenever entries are added or removed (in RememberObserver callbacks) or during state read observations. Instead, track active transition status per entry on SharedElementEntry with a custom setter, and maintain a counter (activeTransitionsCount) on SharedTransitionScopeImpl for isTransitionActive. Furthermore, decouple state observations so each SharedBoundsNode only observes its own entry's mutable properties (target, isEnabled, isRunning, and deferred mutation state), completely eliminating cross-node snapshot dependencies, and convert _allEntries/_enabledEntries to plain lists. Benchmark results (Pixel 6a, JIT disabled): - Screen Instantiation (count=10): -19.7% to -29.2% faster (-179 us to -217 us per initial composition), directly eliminating O(N^2) entry loop overhead during onEntryAdded/onEntryRemoved. - Screen Instantiation (count=1): -5.6% to -20.8% faster (-15 us to -71 us per initial composition). - Memory Allocations: 10% to 21% reduction in allocations across composition and recomposition. - Recomposition Toggle: -1.2% to -9.6% faster across single and multi-element scenarios (-5 us to -16 us per toggle). - Draw passes: -1.1% to -5.1% consistent improvements. - Layout passes: Unchanged / within normal run-to-run noise (+/-0.1 us to 5.0 us). Test: new tests added Fixes: 546240408 Change-Id: I97d72a9c89712d6c4d284f950a24913aa726da3b
D
Doris Liu committed
c50778815b894fe56deb376596d3ef04fff29b3a
Parent: 376128c