leon
05/05/2024, 12:26 PMRecomposer.runRecomposeAndApplyChanges()
function, we're running a while statement to keep the recomposition running.
2. And in the body of that while statement, we're only recomposing if there are changes to invalidate.
3. After each recomposition, the LayoutNode tree is updated.
4. And the while statement above works on the main thread.
5. Apart from the above behavior, when ViewGroup.dispatchDraw(Canvas)
is called in the Android view system, it passes the canvas to the LayoutNode tree created as a result of the recomposition above so that the view is actually updated on the screen.
6. Since no.5 is also running on the main thread, it will not run at the same time as no.2 and no.3, but will run sequentially with no.2, 3, and 5.
7. So it is guaranteed that the recomposition will end unconditionally, and then draw to the screen (it will never happen that the screen will be drawn an intermediate result while the recomposition is not finished).
8. However, there is no guarantee that every time the LayoutNode tree is updated after recomposition finishes, it will be immediately synchronized to the screen. (<- Am I right?)