Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After each ComposeScene.render phase, send apply notifications and perform the corresponding changes. #563

Merged

Conversation

m-sasha
Copy link

@m-sasha m-sasha commented May 13, 2023

Because we hold off on sending the apply notifications during ComposeScene.render, any snapshot state changes that are made in one phase (recomposition, layout, draw) are not visible in the next phase until the next time ComposeScene.render is called.

Some widgets, however, use snapshot state changes to signal from one phase to the next that some work needs to be done. For example TextState.layoutInvalidation and TextState.drawScopeInvalidation. Due to this, a change in the text parameter of Text would not be realized until 3 render iterations have occurred.

Proposed Changes

Call

Snapshot.sendApplyNotifications()
snapshotChanges.perform()

between each phase of ComposeScene.render.

Testing

Test: Added a new unit test to verify that the drawn text in Text changes after one render iteration.

Issues Fixed

Fixes: JetBrains/compose-multiplatform#3137

@m-sasha m-sasha requested a review from igordmn May 13, 2023 13:18
@m-sasha m-sasha merged commit 40cf889 into jb-main May 16, 2023
1 of 2 checks passed
@m-sasha m-sasha deleted the m-sasha/apply-snapshot-changes-between-render-phases branch May 16, 2023 18:08
igordmn pushed a commit that referenced this pull request Jun 8, 2023
…rform the corresponding changes. (#563)

# Conflicts:
#	compose/ui/ui/src/skikoMain/kotlin/androidx/compose/ui/ComposeScene.skiko.kt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants