maui
maui copied to clipboard
Using Shapes causes continuous layout recalculation on Android
Description
When a Shape is used in an Android app, the layout is constantly recalculated, significantly hurting performance.
Steps to Reproduce
- Create a Maui app
- Add a Shape, for example:
<Line
IsVisible="true"
Stroke="Blue"
X1="0"
X2="100"
Y1="0"
Y2="50" />
- Wrap it in a custom layout, for example:
public class MyLayout : Layout
{
protected override ILayoutManager CreateLayoutManager() => new MyLayoutManager(this);
}
public class MyLayoutManager : LayoutManager
{
public MyLayoutManager(Microsoft.Maui.ILayout layout) : base(layout)
{
}
public override Size ArrangeChildren(Rect bounds)
{
foreach (var view in Layout)
view.Arrange(bounds);
return new();
}
public override Size Measure(double widthConstraint, double heightConstraint)
{
return new(widthConstraint, heightConstraint);
}
}
- Run the app in Debug then put a breakpoint in
ArrangeChildren
. Notice how it is constantly being hit, even though the app is not doing anything.
Link to public reproduction project repository
https://github.com/albi005/MauiApp39
Version with bug
7.0 (current)
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
all
Did you find any workaround?
Not using Shapes, replacing them with GraphicsView instead.
Relevant log output
No response
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.
Probably related: #12268
This is a very frustrating issue that seriously interferes with app usage. It can make user interaction very poor. Please reprioritize this, @jsuarezruiz .