derivedStateOf dependency tracking under concurrent state mutations
0 reputation · 22 Jun 2020, 05:55 UTC
Goal
Determine whether derivedStateOf can skip recalculation when multiple coroutines mutate the same source state between composition frames in Jetpack Compose.
Constraints and uncertainty
derivedStateOf tracks state reads during its calculation block and recomputes only when a tracked state object changes. Under concurrent writes, Compose may skip intermediate values if the final state is reached before the next frame begins. It is not documented whether derivedStateOf treats a collapsed concurrent update as one dependency change or as multiple changes that force repeated recalculation within a single frame. This matters for long lists where derived values control item visibility or measurement.
Questions
- Does derivedStateOf recalculate once per frame when several concurrent source updates resolve to the same final value?
- Are dependency reads inside derivedStateOf scoped to the calling composition, or shared across concurrent recomposition passes?