Ji Sungbin
05/21/2022, 8:01 PMinvalidateStack
, and if this stack is not empty, it is popped from this stack and returned from endRestartGroup()
. Recomposition is performed through the returned RecomposeScope
. Right? However, if there is no invalidation during the composition process, null is returned, and if invalidation is requested later, how does endRestartGroup()
detect this and recompose again?
If look at the implementation of endRestartGroup()
, there is no code to track invalidations. Only request pop once.
val scope = if (invalidateStack.isNotEmpty()) invalidateStack.pop() else null // RecomposeScopeImpl?
EDIT: I found some clues. Suspend until invalidation is added through awaitWorkAvailable()
in Recomposer.runRecomposeAndApplyChanges()
. If there is a waiting task(hasSchedulingWork
), it immediately resumes Continuation
and proceeds to recompose. Otherwise, it maintains the suspend state. The maintained suspend(CancellableCoroutine
) is resumed when the operation is completed through the effectJob
, but as I traced the places where the effectJob
is used, there are only rememberCoroutineScope()
and LaunchedEffect
. Where will this suspend resume? I think it’s time to record invalidation, but it wasn’t. They are recorded regardless of Job
.Alexandre Elias [G]
05/24/2022, 8:15 PMComposer.kt
, but it's only responsible for a portion of the invalidation logic. invalidate calls flow up to the Recomposer.kt
, which is the parent of the root CompositionContext.Recomposer
and Choreographer
might clarify things for youJi Sungbin
05/25/2022, 12:16 AM