mono / SkiaSharp.Extended

SkiaSharp is a cross-platform, comprehensive 2D graphics API for all .NET platforms. And, here is where you will find all sorts of extras that you can use with it.
https://mono.github.io/SkiaSharp.Extended
MIT License
235 stars 69 forks source link

[BUG] Lottie crashes when starting in Windows #289

Open eduardoagr opened 1 month ago

eduardoagr commented 1 month ago

Description

When you start an application, with a lottie file, this happens

image

Code

<Grid RowDefinitions="Auto,*,*">
    <Image
        Margin="40"
        Aspect="Center"
        Source="metro_wind_200.png"
        VerticalOptions="Start" />
    <skia:SKLottieView
        Grid.Row="1"
        HeightRequest="300"
        HorizontalOptions="Center"
        Source="metrowind.json"
        VerticalOptions="Start"
        WidthRequest="400">
        <skia:SKLottieView.Behaviors>
            <mct:EventToCommandBehavior
                Command="{Binding GotoHomeCommand}"
                EventName="AnimationCompleted" />
        </skia:SKLottieView.Behaviors>
    </skia:SKLottieView>
    <Label
        Grid.Row="2"
        FontAttributes="Bold"
        FontSize="18"
        HorizontalOptions="Center"
        Text="{x:Static rex:AppResource.Energy}"
        VerticalOptions="Start" />
        public static MauiApp CreateMauiApp() {
            var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>()
#if WINDOWS
                .UseMauiCommunityToolkitMaps("xxx")
#elif ANDROID || IOS
           .UseMauiMaps()
#endif
                .UseSkiaSharp()

Expected Behavior

The app would start normally

Actual Behavior

The app crashes

Basic Information

Detailed IDE/OS information (click to expand) ``` Net 8 Maui 8.0.1 Edition Windows 11 Education Version 23H2 Installed on ‎10/‎24/‎2022 OS build 22631.4317 Experience Windows Feature Experience Pack 1000.22700.1041.0 ```

Screenshots

image

Reproduction Link

(https://github.com/eduardoagr/PopUpError)

superwilly1 commented 1 month ago

I have the same issue, since updating to Visual Studio 17.11.5 (and .NET 8.0.10, SDK 8.0.403). In the output window I see this exception:

Exception thrown: 'System.NotSupportedException' in WinRT.Runtime.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in System.Private.CoreLib.dll

After downgrading Visual Studio (and .NET), it works again.

mattleibow commented 2 weeks ago

I am not sure why it started crashing, but it appears that the latest previews of SkiaSharp fix it.

You can manually install the latest SkiaSharp in your csproj:

<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.9-preview.2.2" />
superwilly1 commented 2 weeks ago

I am not sure why it started crashing, but it appears that the latest previews of SkiaSharp fix it.

You can manually install the latest SkiaSharp in your csproj:

<PackageReference Include="SkiaSharp.Views.Maui.Controls" Version="2.88.9-preview.2.2" />

Yes this appears to fix the issue indeed. The stable version is released which also works: 2.88.9. I didn't have a reference to SkiaSharp.Views.Maui.Controls yet, but did have a reference to SkiaSharp.Extended.UI.Maui (version 2.0.0) Which has a dependency on SkiaSharp.Views.Maui.Controls (>= 2.88.7). When I added the reference to SkiaSharp.Views.Maui.Controls 2.88.9, the app no longer crashes on Windows.