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

Schedule Android layout requests received during layout on the UI thread #19349

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

hartez
Copy link
Contributor

@hartez hartez commented Dec 11, 2023

Description of Change

The current implementation of RequestLayoutIfNeeded() on Android ignores the request if the View is already in the process of layout. This means that any update of a layout-affecting property during layout does not trigger an additional layout pass. In situations where the user has creating a Binding between two layout-affecting properties (as in #18039), this means that a layout pass which affects the dependent property value will not happen immediately.

Worse, whenever the next layout pass is triggered, the new property value will be available. This can cause unexpected behavior during screen refreshes, device rotations, etc..

These changes modify RequestLayoutIfNeeded() to post the layout requests to the UI thread so that they occur during the subsequent layout pass. This brings the Android behavior in MAUI in line with the rest of the platforms and makes it backward-compatible with the Xamarin.Forms behavior.

Issues Fixed

Fixes #18039

@hartez hartez marked this pull request as ready for review December 12, 2023 16:10
@hartez hartez requested a review from a team as a code owner December 12, 2023 16:10
@PureWeen PureWeen removed the request for review from StephaneDelcroix December 12, 2023 17:06
@PureWeen PureWeen merged commit 6ef3167 into main Dec 13, 2023
47 checks passed
@PureWeen PureWeen deleted the fix-18039 branch December 13, 2023 22:28
@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants