whistyun / Markdown.Avalonia

render markdown with Avalonia UI
MIT License
301 stars 24 forks source link

Native AOT Crashes on Startup #122

Closed cybertron-cube closed 1 year ago

cybertron-cube commented 1 year ago

Using 11.0.0 release and building with PublishAot set to true, the text : https://github.com in MarkDownScrollViewer causes the application to crash. It seems any colon followed by a web link causes this crash when compiling with AOT.

Starting a new Avalonia project and putting this image in MainWindow.axaml along with setting PublishAot to true is what I did to produce the exception below

Exception Details
System.TypeInitializationException: A type initializer threw an exception. To determine which type, inspect the InnerException's StackTrace property.
---> System.PlatformNotSupportedException: Operation is not supported on this platform.
at System.Reflection.Assembly.GetCallingAssembly() + 0x5b
at Markdown.Avalonia.EmojiTable.LoadTxt() + 0x5c
at Markdown.Avalonia.EmojiTable..cctor() + 0x1e
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0xc6
--- End of inner exception stack trace ---
at System.Runtime.CompilerServices.ClassConstructorRunner.EnsureClassConstructorRun(StaticClassConstructionContext*) + 0x167
at
System.Runtime.CompilerServices.ClassConstructorRunner.CheckStaticClassConstructionReturnNonGCStaticBase(StaticClassConstructionContext*, IntPtr) + 0xd
at Markdown.Avalonia.EmojiTable.TryGet(String, String&) + 0x19
at Markdown.Avalonia.Markdown.DoTextDecorations(String, Func`2) + 0x1e4
at Markdown.Avalonia.Markdown.g__RunSpanRest|74_0(String, Int32, Int32, Int32, List`1) + 0x159
at Markdown.Avalonia.Markdown.PrivateRunSpanGamut(String) + 0x4d
at Markdown.Avalonia.Markdown.d__78.MoveNext() + 0x1a4
at System.Collections.Generic.List`1.InsertRange(Int32, IEnumerable`1) + 0x120
at Markdown.Avalonia.Markdown.g__RunBlockRest|73_0(String, Int32, Int32, ParseStatus, Int32, List`1) + 0x154
at Markdown.Avalonia.Markdown.PrivateRunBlockGamut(String, ParseStatus) + 0x308
at Markdown.Avalonia.Markdown.Transform(String) + 0x3c
at Markdown.Avalonia.MarkdownScrollViewer.UpdateMarkdown() + 0x3b
at MpvTest.Views.MainWindow.!XamlIlPopulate(IServiceProvider, MainWindow) + 0x22e
at MpvTest.Views.MainWindow.InitializeComponent(Boolean) + 0x14
at MpvTest.App.OnFrameworkInitializationCompleted() + 0x41
at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder, String[], ShutdownMode) + 0x4b
at MpvTest.Program.Main(String[]) + 0x21
whistyun commented 1 year ago

Markdown.Avalonia 11.0.1 has be released. This version fixes the issue.

cybertron-cube commented 1 year ago

Thank you and great work!