Skip to content

AccessViolationException in ImGuiImplOpenGL3.RenderDrawDataNative with Bonsai.ImGui 0.1.0 #33

@bruno-f-cruz

Description

@bruno-f-cruz

Environment

Bonsai 2.9.0
Bonsai.ImGui / Bonsai.ImPlot / Bonsai.ImGui.Visualizers / Bonsai.ImGui.Visualizers.Design: 0.1.0
Hexa.NET.ImGui / Hexa.NET.ImPlot: 2.2.9
Hexa.NET.ImGui.Backends: 1.0.18
HexaGen.Runtime: 1.1.24
Target framework: .NET Framework 4.8 (net480), Windows
OpenGL backend (the default)
Symptoms
Repeated crashes with:

Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory.
   at Hexa.NET.ImGui.Backends.OpenGL3.ImGuiImplOpenGL3.RenderDrawDataNative(ImDrawData* drawData)
   at Bonsai.ImGui.Design.ImGuiControl.OnPaint(PaintEventArgs e)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.UserControl.WndProc(Message& m)
   at Bonsai.ImGui.Design.ImGuiControl.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  ...

The crash occurs frequently (10% rate) at workflow startup, and very rarely during a running session.

What I tried

I initially suspected my own custom Combinator-based ImGui operators in this workflow. After working through several iterations (snapshot pattern for thread safety, removing nested ImGui.Begin/End in favor of BeginChild, disabling recoverable native asserts via io.ConfigErrorRecoveryEnableAssert = false per #29, removing stale package references, etc.), the crash rate decreased somewhat, but did not stop.

I then disabled all custom visualizers — leaving only operators from the Bonsai.ImGui / Bonsai.ImPlot / Bonsai.ImGui.Visualizers packages (ImPlotVisualizerBuilder, ImGuiVisualizerBuilder, PlotBuilder, line/scatter series operators, etc.). The AV in RenderDrawDataNative still occurs, on the same startup-frequent / (never during session).

The workflow I used for test is here:

https://github.com/AllenNeuralDynamics/Aind.Behavior.VrForaging/tree/5950d06888ae41d19a3781357c3c864dc8960186

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions