maui icon indicating copy to clipboard operation
maui copied to clipboard

Don't propagate handler updates when updating the Frame inside VisualElement

Open PureWeen opened this issue 1 year ago • 0 comments

Description

While working on https://github.com/dotnet/maui/pull/22270 I noticed we are hitting a scenario that's causing an infinite layout loop.

When you look at the following stack trace we can see there's a path where

Platform Arrange happens => Sets the Frame on VisualElement => this triggers a propertychanged event on Width => propagates to handler => RequestLayout fires.

Because RequestLayout on Android fires up the whole tree this can sometimes cause weird layout loops or excessive measure/layout paths.

My current thinking is that we just need to short circuit the "Handler.Updatevalue" call inside Element if the property change is related to the readonly height/width/x/y properties and we are inside a "BatchCommitted" path.

image

PureWeen avatar May 07 '24 16:05 PureWeen