New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WinGLContext.MakeCurrent fails with error code 2004 #3196
Comments
The issue seems to be that BlockonUIThread tries to make the OpenGL graphics context current while the draw thread is using the context to draw. I fixed it by adding a locking around my load context and around my entire draw call. Locking is only added to asset getting and setting, not to anything that happens on the main thread. It seems to me that a lock should be added inside GraphicsDevice.DrawUserIndexedPrimitives and in all other places where GL calls are made in the main thread. |
I'm getting this issue as well - though sometimes the error code appears as 0. My project is also Windows OpenGL. It happens incredibly frequently (in less than one minute most times) |
I am also seeing this error, although for me it is triggered by my terrain paging system disposing of either vertex or index buffers. Vs indicates the last active thread to be GC Finalizer.
Tested with latest release and also current dev code compiled 7th feb. |
@cra0zy @dellis1972 @KonajuGames Any thoughts on this?
Note that the DirectX path does lock the device context for drawing, state setting, content set/get data, and presentation operations. It doesn't lock on resource creation as at least that is assured to be thread safe in DirectX. |
Bump... @cra0zy @dellis1972 @KonajuGames |
Graphics resources must be explicitly disposed. If it is left to the
garbage collector to dispose the resources, it will likely fail with cross
thread issues. The finalizer is called from the GC thread and we can never
release the GPU resources correctly in this manner. Thank OpenGL for not
being thread-friendly.
If you see a call to the Finalizer in your callstack, it means the object
was not explicitly disposed.
|
For the locking around the draw, we may end up doing what we do on Android
and make the OpenGL context single threaded. GL calls on other threads are
then invoked on the main thread. This should also improve rendering
performance as enabling multithreaded support in an OpenGL context incurs a
performance hit.
|
Context is now single threaded in DesktopGL. I believe this issue is not relevant anymore. |
@tomspilman This can be closed. |
I'm having rather frequent errors when starting MonoGame (Windows OpenGL) projects. The stacktrace is listed below and the target machine is running Windows 8.1 pro 64bit.
The error code 2004 corresponds to ERROR_TRANSFORM_NOT_SUPPORTED (The requested transformation operation is not supported.) Another error that is thrown with the same stack trace and the same GraphicsContextException is error code 6 (ERROR_INVALID_HANDLE).
The text was updated successfully, but these errors were encountered: