Skip to content

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

Merged
PureWeen merged 2 commits into
mainfrom
fix-18039
Dec 13, 2023
Merged

Schedule Android layout requests received during layout on the UI thread#19349
PureWeen merged 2 commits into
mainfrom
fix-18039

Conversation

@hartez
Copy link
Copy Markdown
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
Comment thread src/Controls/tests/DeviceTests/Elements/Layout/LayoutTests.cs Outdated
Comment thread src/TestUtils/src/DeviceTests/AssertionExtensions.cs
@PureWeen PureWeen removed the request for review from StephaneDelcroix December 12, 2023 17:06
@PureWeen PureWeen merged commit 6ef3167 into main Dec 13, 2023
@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

Development

Successfully merging this pull request may close these issues.

[regression/8.0.0-preview.3.8149] Result of "WidthRequest="{Binding Width, Source={x:Reference input}}" is different to each platforms

3 participants