Opened 12 months ago

Last modified 12 months ago

#18532 new defect

wxGLCanvas::SwapBuffers() hangs when app started on non primary screen on windows 10

Reported by: arhismece Owned by:
Priority: high Milestone:
Component: OpenGL Version: 3.1.0
Keywords: wxglcanvas, SwapBuffers Cc:
Blocked By: Blocking:
Patch: no


OS: Windows 10 x64
GPU: Nvidia 1080
NV-DRIVER: tried many of them, currently on latest studio but latest gaming, latest studio both "normal" and dhc all behave identical
wxWidgets version: 3.1.2

3 monitors attached to computer, "central" is primary, one is left of it and one on top of it.

If I start the application on any of the non-primary monitors the app will not run properly. It gets stuck in wxGLCanvas::SwapBuffers() (enters the method, never exits)

How to reproduce:


change myframe from:

MyFrame::MyFrame( bool stereoWindow )
       : wxFrame(NULL, wxID_ANY, "wxWidgets OpenGL Cube Sample")


MyFrame::MyFrame( bool stereoWindow )
       : wxFrame(NULL, wxID_ANY, "wxWidgets OpenGL Cube Sample", wxPoint(-1000,100) )

this makes the app open on the left screen (non primary) and the app will get stuck on SwapBuffers(); in TestGLCanvas::OnPaint()

Weird behavior:

Create 2 users on windows 10

  • boot up
  • log in as A
  • start app -> fails
  • stay logged in as A, log in as B (switch user)
  • start app -> IT WORKS
  • switch back to user A
  • start app -> it fails
  • sign off from use A
  • login as user B
  • start app -> it FAILS

so the "first" user that's logged in has this problem, the user that logs in after does not have the problem ?!?!?!?

I uninstalled almost everything from the windows 10, antivirus, synergy, reinstalled drivers 20+ times, uninstalled all possible ASUS (motherboard, case ..) addons, killed all bg processes I could, still behaves identical

Change History (4)

comment:1 Changed 12 months ago by vadz

Sorry, really no idea what could this be -- as you can see, we're just calling ::SwapBuffers() and it's really not supposed to hang.

And even if I understand that this doesn't help you much, I can say that I have multiple monitors and don't see this problem so it's definitely not universal.

If you find the root of the problem, please update this ticket, but I don't know how can we help you with it.

comment:2 Changed 12 months ago by arhismece

  • Cc github@… added

yes, I see that it's just calling win gdi swapbuffers() :( ...

It is very weird behavior, I just recently moved to win10 and there I see it. Initially I believed it had to do with my installation, that I messed something up but last 10 days I'm seeing more and more ppl complaining about the same thing (simplify3d and prusa slicer user groups). I uninstalled almost everything from the win10 (from synergy to asus utilities..) reinstalled driver, tried bunch of different nv drivers.. nothing changed :( .. and I'm not really a windows person so debugging it further than "stopped at win gdi swapbuffers(hwnd);" is beyond my knowledge :( .. but if I manage to figure out what's doing it I'll ring here!!!

anyhow, maybe you know, what dll is the whole win gdi in? or in what dll's on win10 x64 ? maybe "something" replaced it / them so I could compare checksums with unaffected installation..

What I noticed so far, all affected installations are 3 monitors desktop computers (no laptops, no dual screens).

Thanks for your comment!

comment:3 Changed 12 months ago by vadz

The function itself is in gdi32.dll, but it's probably forwarded to the OpenGL driver, so I'm not sure if it really helps.

If the issue really only appears when starting the app on a different monitor, could showing its window initially on the primary monitor (in 1x1 size, to avoid flicker) and then moving it to the correct location provide a (very ugly) workaround?

comment:4 Changed 12 months ago by arhismece

  • Cc github@… removed

Not sure if that would work but will try, need to figure out how/when to "move" the MyFrame in this cube example after it is shown on main screen :D ... if I just add

SetPosition(wxPoint(-1000, 100));

at the end of the MyFrame constructor - it does not help :(

changing app oninit to

MyFrame *mf = new MyFrame();
mf->SetPosition(wxPoint(-1000, 100));

instead just doing new MyFrame();

same problem - does not help

now if I add some globals and do something like

if (GLOBALKEETAH > 0) GLOBALFRAME->SetPosition(wxPoint(-1000, 100));

so I move the window only after swapbuffers was execute once on the primary screen, it works.. not ideally as it waits for a refresh so you have to resize or something for it to actually redraw to move etc .. but that could be done properly by someone who knows how to program desktop apps :D (not me :D ) ... but if setposition is moved after first swapbuffer next swapbuffer on any monitor will work.

I'm reading:

Not sure if this wglMakeCurrent() might help in some way (being called in proper place) .. I could not make it work but..

Note: See TracTickets for help on using tickets.