Skip to content

Continuous rendering results in random crashes. #38

Description

@IceReaper

For a live renderer i use the following code:

private class ContinuousGlSurface : GLSurface
{
	private const int FrameDelay = 1000 / 60;

	private readonly Stopwatch stopwatch;

	public Action RenderLoop;

	public ContinuousGlSurface(GraphicsMode graphicsMode, int major, int minor, GraphicsContextFlags graphicsContextFlags)
		: base(graphicsMode, major, minor, graphicsContextFlags)
	{
		this.stopwatch = Stopwatch.StartNew();
	}

	protected override void OnDraw(EventArgs args)
	{
		base.OnDraw(args);

		if (this.stopwatch.ElapsedMilliseconds >= ContinuousGlSurface.FrameDelay)
		{
			this.stopwatch.Restart();
			this.RenderLoop();
		}

		this.Invalidate(false);
	}
}

This works flawless.. basically, because it only works properly with either single buffering (due to frameswap glitches), or not using the stopwatch because not using it will results in rendering as fast as your pc can.
So this works till suddenly out of nowhere a random (sometimes after seconds, sometimes after minutes) crash appears:

OpenTK.Graphics.GraphicsContextException: Failed to make context 65537 current. Error: 2004
   at OpenTK.Platform.Windows.WinGLContext.MakeCurrent(IWindowInfo window)
   at OpenTK.Graphics.GraphicsContext.MakeCurrent(IWindowInfo window)
   at Eto.OpenTK.WinForms.WinGLUserControl.MakeCurrent()
   at Eto.OpenTK.Wpf.WpfWinGLSurfaceHandler.MakeCurrent()
   at Eto.OpenTK.Wpf.WpfWinGLSurfaceHandler.UpdateView()
   at Eto.OpenTK.Wpf.WpfWinGLSurfaceHandler.<AttachEvent>b__7_2(Object sender, PaintEventArgs e)
   at System.Windows.Forms.Control.OnPaint(PaintEventArgs e)
   at Eto.OpenTK.WinForms.WinGLUserControl.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.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.UserControl.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

When searching for that crash, i came across this one: MonoGame/MonoGame#3196
Which looks quite similar.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions