maui icon indicating copy to clipboard operation
maui copied to clipboard

Using Shapes causes continuous layout recalculation on Android

Open albi005 opened this issue 1 year ago • 2 comments

Description

When a Shape is used in an Android app, the layout is constantly recalculated, significantly hurting performance.

Steps to Reproduce

  1. Create a Maui app
  2. Add a Shape, for example:
<Line
    IsVisible="true"
    Stroke="Blue"
    X1="0"
    X2="100"
    Y1="0"
    Y2="50" />
  1. 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);
    }
}
  1. 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

albi005 avatar Nov 28 '22 17:11 albi005

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.

ghost avatar Nov 29 '22 08:11 ghost

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 .

BioTurboNick avatar Dec 22 '22 13:12 BioTurboNick