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

Call measureAndLayout again before draw #1356

Merged
merged 2 commits into from
May 14, 2024

Conversation

m-sasha
Copy link
Member

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

Android currently does two things differently from CMP:

  1. Between layout and draw, Android's Choreographer flushes the main dispatcher. We can't do quite that, but an important side effect of that is that the GlobalSnapshotManager gets to run and call Snapshot.sendApplyNotifications(), which we can do.
  2. Right before drawing, AndroidComposeView.dispatchDraw calls measureAndLayout again, followed by Snapshot.sendApplyNotifications().

This PR aligns the behavior of CMP with that of Android.

Testing

  • Added a unit test that verifies measure and layout are being called again before drawing.

@m-sasha m-sasha requested a review from igordmn May 13, 2024 12:01
@m-sasha m-sasha force-pushed the m-sasha/fix-infinite-relayout branch from 99e91a7 to ec35b33 Compare May 13, 2024 13:08
@m-sasha m-sasha force-pushed the m-sasha/remeasureAndLayout-before-draw branch from c83a186 to 8c9be88 Compare May 13, 2024 13:18
Base automatically changed from m-sasha/fix-infinite-relayout to jb-main May 13, 2024 14:38
@m-sasha m-sasha merged commit 3cf0354 into jb-main May 14, 2024
6 checks passed
@m-sasha m-sasha deleted the m-sasha/remeasureAndLayout-before-draw branch May 14, 2024 19:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants