LottieUWP, встроенный в Xamarin.Forms

Я создал специальный рендерер для LottieUWP

[assembly: ExportRenderer(typeof(LottieView), typeof(LottieViewRenderer))]
namespace Gorilla.Forms.UWP.Source.Renderer.Lottie
{
public class LottieViewRenderer : ViewRenderer<LottieView, LottieAnimationView>
{
    private LottieAnimationView AnimationView;

    protected override void OnElementChanged(ElementChangedEventArgs<LottieView> e)
    {
        base.OnElementChanged(e);

        if (Control == null)
        {
            if (e.NewElement == null) return;

            AnimationView = new LottieAnimationView()
            {
                Name = e.NewElement.AnimationPath,
                FileName = e.NewElement.AnimationPath,
                AutoPlay = true,
                RepeatCount = -1
            };

            SetNativeControl(AnimationView);
        }
    }
}
}

А вот и LottieView

public class LottieView : View
{
    public static readonly BindableProperty AnimationPathProperty = BindableProperty.Create(
        propertyName: nameof(AnimationPath),
        returnType: typeof(string),
        declaringType: typeof(LottieView));

    public string AnimationPath
    {
        get => (string)GetValue(AnimationPathProperty);
        set => SetValue(AnimationPathProperty, value);
    }
}

Это работает, но иногда при зависании или ожидании несколько секунд я получаю сообщение об ошибке:

WinRT information: Attempting to close a CanvasActiveLayer that is not top of the stack. The most recently created layer must be closed first.

at System.Runtime.InteropServices.WindowsRuntime.IClosable.Close() at System.Runtime.InteropServices.WindowsRuntime.IClosableToIDisposableAdapter.Dispose() at LottieUWP.LottieDrawable.Draw(CanvasDevice device, BitmapCanvas bitmapCanvas, CompositionLayer compositionLayer, Rect bounds, Single scale, Byte alpha, Matrix3X3 matrix, Double width, Double height, CanvasDrawingSession canvasDrawingSession) at LottieUWP.LottieDrawable.CanvasControlOnDraw(ICanvasAnimatedControl canvasControl, CanvasAnimatedDrawEventArgs args) at Windows.ApplicationModel.Core.UnhandledError.Propagate() at Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.<.ctor>b__17_1(Object sender, UnhandledErrorDetectedEventArgs eventArgs) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AppCenter.Utils.ApplicationLifecycleHelper.<.ctor>b__17_1(Object sender, UnhandledErrorDetectedEventArgs eventArgs)

Похоже, это ошибка в LottieUWP или моя реализация неверна?


person Daniel DirtyNative Martin    schedule 21.11.2018    source источник
comment
Это может помочь увидеть ваш LottieView и AnimationPath. Я предполагаю, что это строка json? IOW, можете ли вы предоставить MCVE (минимальный, полный, проверяемый пример? stackoverflow.com/help/mcve   -  person jgoldberger - MSFT    schedule 22.11.2018
comment
Судя по информации об ошибке, CanvasActiveLayer не является вершиной стека, и он будет освобожден, тогда это приведет к тому, что параметр canvasControl станет пустым в методе CanvasControlOnDraw. Итак, вам нужно проверить LottieView класс и то, как вы его используете.   -  person Nico Zhu - MSFT    schedule 22.11.2018
comment
LottieView - это мой самодельный класс, в котором реализованы только Property и BindableProperty   -  person Daniel DirtyNative Martin    schedule 26.11.2018