Move the effects and synthetic events dispatching to after the draw phase in the render loop. #1260
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
While investigating this, we've discovered that
LazyColumn
moves its elements synchronously when scrolled (only if the scrolling causes new items to become visible).Additionally, we currently run coroutines launched in a composition's
rememberCoroutineScope
between the layout and draw phases (due to #1034 and our desire to send the synthetic events before the draw phase, to avoid a one-frame delay when scrolling a list that highlights the item under the mouse).Together these two create a problem (visible in the video linked above) because when the
LazyColumn
is scrolled from a launched coroutine, it moves its element to the position where they would normally appear only on the next frame, which causes a visible "jump".Proposed Changes
After much consideration (with @igordmn) we decided to strictly adhere to the ordering of the phases as they are done on Android:
render
completes).render
completes.render
) scheduled composition effects.render
) scheduled synthetic events.Testing
Test: Tested the "jumpy" lazy column manually, and added unit tests to verify the order of the render phases.
The manual test:
This PR should be verified by QA.
Issues Fixed
Possibly fixes JetBrains/compose-multiplatform#4438