Unity-Technologies / com.unity.uiwidgets

UIWidgets is a Unity Package which helps developers to create, debug and deploy efficient, cross-platform Apps.
https://unity.cn/uiwidgets
625 stars 78 forks source link

创建多次含有decoration的Container发生崩溃 #345

Open tomcatter opened 2 years ago

tomcatter commented 2 years ago

测试代码如下:

using System.Collections;
using System.Collections.Generic;
using Unity.UIWidgets.engine;
using Unity.UIWidgets.material;
using Unity.UIWidgets.ui;
using Unity.UIWidgets.widgets;

using ui_ = Unity.UIWidgets.widgets.ui_;
using TextStyle = Unity.UIWidgets.painting.TextStyle;
using Unity.UIWidgets.painting;
using Unity.UIWidgets.foundation;
using uiwidgets;
using Unity.UIWidgets.rendering;

public class DialogTest : UIWidgetsPanel
{
    protected void OnEnable()
    {
        base.OnEnable();
    }

    protected override void main()
    {
        ui_.runApp(new MyApp());
    }
}

class MyApp : StatelessWidget
{
    public override Widget build(BuildContext context)
    {
        return new MaterialApp(home: new CounterApp());
    }
}

internal class CounterApp : StatefulWidget
{
    public override State createState()
    {
        return new CountDemoState();
    }
}

internal class CountDemoState : State<CounterApp>
{
    private int count = 0;

    public override Widget build(BuildContext context)
    {
        return new Container(
            color: Color.fromARGB(255, 0, 0, 0),
            child: new Column(
                children: new List<Widget>()
                {
                    new Text(
                        data: $"count: {count}",
                        style: new TextStyle(
                            decoration: TextDecoration.none,
                            color: Color.fromARGB(255, 0, 0, 255)
                        )
                    ),
                    new FlatButton(
                        onPressed: () =>
                        {
                            setState(
                                () =>
                                {
                                    count++;
                                }
                            );

                            material_.showDialog<object>(
                                context: context,
                                builder: (ctx) =>
                                {
                                    //var container = new Container(
                                    //    width: 600,
                                    //    height: 400,
                                    //    decoration: new ShapeDecoration(
                                    //        color: Color.fromRGBO(0, 166, 185, 0.24f),
                                    //        shape: new BeveledRectangleBorder(
                                    //            borderRadius: BorderRadius.all(Radius.circular(10)),
                                    //            side: new BorderSide(
                                    //                color: Color.fromRGBO(34, 232, 255, 1),
                                    //                width: 1.5f
                                    //            )
                                    //        )
                                    //        shadows: new List<BoxShadow>
                                    //        {
                                    //            new BoxShadow(
                                    //                color: Color.fromRGBO(255, 255, 255, 0.01f),
                                    //                blurRadius: 20
                                    //            )
                                    //        }
                                    //    )
                                    //);

                                    var container = new Container(
                                        width: 600,
                                        height: 400,
                                        decoration: new BoxDecoration(
                                            color: Color.fromRGBO(0, 166, 185, 0.24f),
                                            boxShadow: new List<BoxShadow>
                                            {
                                                new BoxShadow(
                                                    color: Color.fromRGBO(255, 255, 255, 0.01f),
                                                    blurRadius: 20
                                                )
                                            }
                                        )
                                    );

                                    return new Dialog(
                                        shape: new RoundedRectangleBorder(
                                            borderRadius: BorderRadius.circular(0)
                                        ),
                                        elevation: 0,
                                        child: container,
                                        backgroundColor: Colors.transparent
                                    );
                                }
                            );
                        },
                        child: new Container(
                            color: Color.fromARGB(255, 0, 255, 0),
                            width: 100,
                            height: 40
                        )
                    ),
                }
            )
        );
    }
}

使用Unity 2020.3.24f1c1版本,编译成Android mono 以上代码点击按钮调用showDialog多次发生崩溃,如果去掉decoration的设置则正常 日志见附件:

log.txt

zhuxingwei commented 2 years ago

Thanks for the bug reporting !

The team will give it a quick investigation first and give you some feedbacks then. Thanks !

zhuxingwei commented 2 years ago

This PR #350 should fix the issue. Please try it and look forward to your feedback!