Schedule Android layout requests received during layout on the UI thread #19349
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.
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