Open timunie opened 10 months ago
In general, we need samples for these different approaches:
We have samples for all of these approaches randomly scattered across our repositories. At the very least this comment should help with googling them. Ideally, yes, these should be duplicated here.
This is a simple but yet stunning sample, so we want to show it.
Description
The problem is very strange for me, I have never encountered this before, and, to be honest, I am not entirely sure what exactly the problem is, in my code, in Avalonia, in .NET Core, or maybe in the debugger. Or maybe not a problem at all, but an inevitable behavior when using a debugger and breakpoints.
When I add my custom control to Window (this control uses Render), and then execute an asynchronous command in the WindowViewModel that awaits something longer than ~2 seconds (and has a breakpoint on it), and after that it also executes some code, then when the code of this command is completed, the application freezes completely and then crashes.
Steps to reproduce the behavior
Add a custom SnowfallControl to the project with the following code:
Add this control to MainWindow.axaml:
public class MainWindowViewModel : ViewModelBase {
pragma warning disable CA1822 // Mark members as static
pragma warning restore CA1822 // Mark members as static
}
Fatal error. Internal CLR error. (0x80131506) at Avalonia.Rendering.Composition.Drawing.RenderDataDrawingContext.DrawRectangleCore(Avalonia.Media.IBrush, Avalonia.Media.IPen, Avalonia.RoundedRect, Avalonia.Media.BoxShadows) at Avalonia.Media.DrawingContext.DrawRectangle(Avalonia.Media.IBrush, Avalonia.Media.IPen, Avalonia.Rect, Double, Double, Avalonia.Media.BoxShadows) at AvaloniaCustomControlRenderBugReproduction.Controls.SnowfallControl.Render(Avalonia.Media.DrawingContext) at Avalonia.Rendering.Composition.CompositingRenderer.UpdateCore() at Avalonia.Rendering.Composition.CompositingRenderer.Update() at Avalonia.Rendering.Composition.Compositor.CommitCore() at Avalonia.Rendering.Composition.Compositor.Commit() at Avalonia.Media.MediaContext.CommitCompositor(Avalonia.Rendering.Composition.Compositor) at Avalonia.Media.MediaContext.CommitCompositorsWithThrottling() at Avalonia.Media.MediaContext.RenderCore() at Avalonia.Media.MediaContext.Render() at Avalonia.Threading.DispatcherOperation.InvokeCore() at Avalonia.Threading.DispatcherOperation.Execute() at Avalonia.Threading.Dispatcher.ExecuteJob(Avalonia.Threading.DispatcherOperation) at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean) at Avalonia.Threading.Dispatcher.Signaled() at Avalonia.Win32.Win32DispatcherImpl.DispatchWorkItem() at Avalonia.Win32.Win32Platform.WndProc(IntPtr, UInt32, IntPtr, IntPtr) at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG ByRef) at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG ByRef) at Avalonia.Win32.Win32DispatcherImpl.RunLoop(System.Threading.CancellationToken) at Avalonia.Threading.DispatcherFrame.Run(Avalonia.Threading.IControlledDispatcherImpl) at Avalonia.Threading.Dispatcher.PushFrame(Avalonia.Threading.DispatcherFrame) at Avalonia.Threading.Dispatcher.MainLoop(System.Threading.CancellationToken) at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(System.String[]) at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(Avalonia.AppBuilder, System.String[], Avalonia.Controls.ShutdownMode) at AvaloniaCustomControlRenderBugReproduction.Program.Main(System.String[])