Hi! Recently, I've been studying how recomposition...
# compose
l
Hi! Recently, I've been studying how recomposition and view drawing are synchronized, and I had the following question. 1. When a recomposition happens once, is the result immediately synchronized to the screen? 2. Or can it happen that after 2 recompositions, only the last result is synchronized to the screen, like in the Android View System where frame skipping occurs? Below is my current understanding, Could you please let me know if I am misunderstanding? 1. Inside the
Recomposer.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?)