min
03/27/2026, 10:34 AMStateObjectImpl.recordReadIn method?
internal fun recordReadIn(reader: ReaderKind) {
do {
val old = ReaderKind(readerKind.get())
if (old.isReadIn(reader)) return
val new = old.withReadIn(reader)
} while (!readerKind.compareAndSet(old.mask, new.mask))
}min
03/27/2026, 10:34 AMStateObjectImpl.isReadIn(reader: ReaderKind): Boolean returns true if called with the same ReaderKind argument, but what purpose does that serve?
if (value is StateObjectImpl) {
value.recordReadIn(ReaderKind.Composition)
}
I’ve located this if statement in (CompositionImpl as ControlledComposition).recordReadOf, but again, what’s the point of it? Compose seems to work fine with my own implementations of StateObject, and when they’re read inside a composition, they’re also passed to the aforementioned recordReadOf method. Since they only extend StateObject, the conditional is skipped, but everything still works the same way it does with subtypes of StateObjectImpl.Chuck Jazdzewski [G]
03/27/2026, 7:16 PMReaderKind is an internal optimization that allows the Recompose and the SnapshotStateObserver to quickly ignore objects that have where not read in composition or in a snapshot state observer. This, for example, allows the Recomposer 's apply observer to avoid waking the recomposer's coroutine when it received a change that was only read by layout or draw, for example (and vis versa). Waking the recompose unnecessarily was causing frames to jank in some cases.min
04/07/2026, 9:42 AM