Svg.Skia icon indicating copy to clipboard operation
Svg.Skia copied to clipboard

Completely freezes Rider Avalonia UI visual previewer when used

Open angelsix opened this issue 1 year ago • 5 comments

New Avalonia project, using all the latest releases to day (fresh install of .Net Core, Rider, Avalonia etc...) running on a Mac.

New project, add this library using dotnet add command line, then in a axaml file add either <svg ... /> or <Image Source="{SvgImage ...}" /> and the visual previewer in Rider completely hangs and doesn't work.

Comment it out and replace with <Image Path="image.png" /> and UI starts working again.

image

Tried restarts, remaking the application, and 2 machines, exactly the same issue.

Source code is here https://github.com/angelsix/youtube/tree/08a0263702ba319b0e7553ddcc7934a3ec127772/Avalonia/AvaloniaLoudnessMeter and video of issue is here https://youtu.be/VM-4NwdeXlo

angelsix avatar Jul 24 '22 16:07 angelsix

Interesting didn't run into that issue yet, will investigate. One thing is that previewer is using immediate renderer while application defaults to deferred.

wieslawsoltes avatar Jul 24 '22 17:07 wieslawsoltes

@angelsix It's know issue with previewer not resolving some external assemblies, unfortunately not know fix, but there is workaround to make previewer work.

Replace this lines: https://github.com/angelsix/youtube/blob/08a0263702ba319b0e7553ddcc7934a3ec127772/Avalonia/AvaloniaLoudnessMeter/Program.cs#L16-L19

with:

        public static AppBuilder BuildAvaloniaApp()
        {
            GC.KeepAlive(typeof(SvgImageExtension).Assembly);
            GC.KeepAlive(typeof(Avalonia.Svg.Skia.Svg).Assembly);
            return AppBuilder.Configure<App>()
                .UsePlatformDetect()
                .LogToTrace();
        }

this will load needed assemblies for previewer.

wieslawsoltes avatar Jul 24 '22 19:07 wieslawsoltes

Added comment to README so others can also find the workaround https://github.com/wieslawsoltes/Svg.Skia#avalonia-previewer

wieslawsoltes avatar Jul 24 '22 19:07 wieslawsoltes

Awesome thanks that KeepAlive fixed it. Perhaps keep this open until its fixed somehow?

angelsix avatar Jul 25 '22 07:07 angelsix

Awesome thanks that KeepAlive fixed it. Perhaps keep this open until its fixed somehow?

I added comment to README with the workaround, and I don't think it's easily fixable as it's related to .netcoreapp model and dependency resolution, so way bigger issue than Avalonia.

wieslawsoltes avatar Jul 25 '22 11:07 wieslawsoltes