Avalonia icon indicating copy to clipboard operation
Avalonia copied to clipboard

OpenGlControlBase.EnsureInitializedCore: Object reference not set to an instance of an object

Open hez2010 opened this issue 3 years ago • 1 comments

Describe the bug

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at Avalonia.OpenGL.Controls.OpenGlControlBase.EnsureInitializedCore() in E:\source\repos\Avalonia\src\Avalonia.OpenGL\Controls\OpenGlControlBase.cs:line 151
   at Avalonia.OpenGL.Controls.OpenGlControlBase.EnsureInitialized() in E:\source\repos\Avalonia\src\Avalonia.OpenGL\Controls\OpenGlControlBase.cs:line 215
   at Avalonia.OpenGL.Controls.OpenGlControlBase.Render(DrawingContext ) in E:\source\repos\Avalonia\src\Avalonia.OpenGL\Controls\OpenGlControlBase.cs:line 22
   at Avalonia.Rendering.Composition.CompositingRenderer.Update() in E:\source\repos\Avalonia\src\Avalonia.Base\Rendering\Composition\CompositingRenderer.cs:line 227
   at Avalonia.Threading.JobRunner.RunJobs(Nullable`1 ) in E:\source\repos\Avalonia\src\Avalonia.Base\Threading\JobRunner.cs:line 38
   at Avalonia.Win32.Win32Platform.WndProc(IntPtr , UInt32 , IntPtr , IntPtr ) in E:\source\repos\Avalonia\src\Windows\Avalonia.Win32\Win32Platform.cs:line 296
   at Avalonia.Win32.Interop.UnmanagedMethods.DispatchMessage(MSG& )
   at Avalonia.Win32.Win32Platform.RunLoop(CancellationToken ) in E:\source\repos\Avalonia\src\Windows\Avalonia.Win32\Win32Platform.cs:line 223
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken ) in E:\source\repos\Avalonia\src\Avalonia.Base\Threading\Dispatcher.cs:line 61
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] ) in E:\source\repos\Avalonia\src\Avalonia.Controls\ApplicationLifetimes\ClassicDesktopStyleApplicationLifetime.cs:line 120
   at ControlCatalog.NetCore.Program.Main(String[] ) in E:\source\repos\Avalonia\samples\ControlCatalog.NetCore\Program.cs:line 103

To Reproduce Steps to reproduce the behavior:

  1. Enable UseWgl in CC.NetCore
  2. Build and run
  3. Click the first menu item "Composition"
  4. Press and hold the down arrow key
  5. Crash

Expected behavior No exception should happen

Analysis CreateSharedContext can returns null without exceptions.

Desktop (please complete the following information):

  • OS: Windows 11
  • Version: build from master

hez2010 avatar Jul 21 '22 17:07 hez2010

This issue has been mitigated by #8569, now failure to create additional OpenGL context will not result in crashing, instead it yields an empty context and give up further rendering. We still need to figure out the reason for the failure after several times of OpenGL shared context creation.

hez2010 avatar Aug 07 '22 07:08 hez2010