What problem does it solve?
This Skill prevents Compose performance issues caused by reading fast-changing frame-rate state (like scroll offsets or animation values) in the composition phase, which triggers excessive recomposition and cascaded invalidations.
Core Features & Use Cases
- Defer state reads to layout/draw: Keep animated/scroll/gesture values as
State and read .value inside value-form modifier blocks such as Modifier.offset { ... } or inside draw blocks like drawBehind.
- Avoid back-writing across phases: Stop observable state from being written in layout/draw and then read in composition (or written in composition and read earlier in the same pass), which can create extra invalidation cycles.
- Use provider lambdas across composable boundaries: Pass
() -> T providers instead of snapshot values when values change every frame and are consumed by modifiers deep in the UI tree.
- Handle measurement dependencies correctly: When one row’s measured size affects another row, apply the measured constraint during measure/layout rather than reading the measurement state in composition.
Quick Start
Use the compose-state-deferred-reads Skill when you notice recomposition counters climb during scrolling or animation even when your underlying data is stable.