Debugging a Qt application with nSight

I am developing an OpenGL application using the Qt framework, and I can not debug this application using the nSight Visual Studio debugger. The HUD doesn’t show and the application freezes when I hit Ctrl+Z to show the toolbar. I have a parallel application using GLFW that works just fine. From an OpenGL perspective the Qt adds only two extra calls for each frame other than wglSwapBuffers(). It adds wglGetCurrentContext() and wglGetCurrentDC() at the beginnning of each frame (on Windows). Does this make a difference for nSight?

I was hoping that someone had experience using nSight with Qt, but searching google and theese forums nets me zip results. If a dev is curious to figure this one out I would be happy to supply a bare bones example for tinkering.

Hi,

What version of Nsight and driver are you using? What about the GPU?

If you can provide me with the binaries so we can reproduce, that would help us reproduce and look into the issue.
Thanks

Hello,

i am having the same issue as sunefred. I am using Qt 5.2 with a minimal hello world example, and the HUD simply doesn’t show up.

I ran the application through gdebugger and it is definetly creating GL contexts and swapping the back buffer correctly (and it draws correctly).

It’s possible that the way Qt initializes its OpenGL context confuses nSight, but I wouldn’t know how to fix it since nSight (even in TRACE level) doesn’t really log much useful information.

I have uploaded the binaries and cpp file for my test-app here: http://www.hartte.de/build-Desktop-Release.zip

To double check, I ran the nSight HUD on other OpenGL applications that are not using Qt 5, and the HUD as well as frame debugging work in these applications. In addition, I tried to create a compat-log with the launcher, but it was simply empty after running the launcher (the application was successfully launched, but the HUD was still missing).

Please let me know if I can provide you with any assistance tracking this problem down.
build-Desktop-Release.zip (15.6 MB)

To make this easier to debug for you, I also attached a call log made using gDebugger.

edit: Attachments don’t seem to be working, so I uploaded the logs here:
http://www.hartte.de/gdebugger_log.zip

I really hope this can be fixed. Please let me know if I can be of any assistance in analyzing this issue.
OpenGLContext1-CallsLog.html (1.33 KB)
OpenGLContext2-CallsLog.html (374 KB)

Hello again,

I am back with a downloadable “Hello World” level Qt5.2 sample application. You can download it from github at GitHub - sunefred/Gravity3D: The Attractive 3D Engine There are executables with debug information as well as MSVC2012 project files if you want to build it on your own. If you do, you will need to download Qt 5.2, glew 1.10.0, glfw 3.0.3 and newmat 1.1. For convenience I have made these available in my Vendor repository.

The application has Maya style navigation, i.e Alt+LM for rotate, Alt+MM for translate, Alt+RM for zoom and Alt+Scroll for zoom. You can also change tessellation level with the scroll wheel.

Finally thanks to shartte for joining with samples. Lets hope there is an easy solution for you guys at nVidia!

I should add that before deciding to use Qt 5.2 I was using the latest 4.x release, the 4.8.5 and I had exactly the same problem. I would assume solving one would fix the other.

I think I should also add that i explicitly compiled Qt for Desktop GL and disabled the ANGLE DX wapper it normally uses.

I’m using Qt 4.7.3 for a stereo application and the app crashes when I try to use the graphics debugger. The performance analysis does work however. Hope there is a fix soon and thanks!

I can report the same. I use Qt 5.1 and 5.2. Is it possible that QOpenGLFunctions causes this problem?

Hello all,

Thanks for the reports with the projects. We are able to reproduce the HUDs not showing up (thanks Shartte) and will start looking into it.
I’ll keep you posted on what we find out.

draj, we have not seen the app crash you mentioned though. If you have any details on how to reproduce this, please let me know.

Thanks

Thanks a lot rafi. :)

A quick update on the HUDs not showing up (reproducible from shartte), we now have a fix and will be going through testing. Assuming no issues in QA, we should have this fix in the new release coming up soon.

Wow that is a great response. I am looking forward to this and will report my findings as soon as it’s released. Thanks a lot!

That is great news rafi! If you wouldn’t mind telling, it would be interesting to know what differs for a Qt application that made it incompatible with the current build. As far as I could see (running it through gDebugger from remedy) it had no weird calls or setup code. It could help get some insight in the overhead of a Qt application versus a custom context creator.

Hi,

No problem sunefred. Basically, it was a bad assumption on our side.
When an app creates an OpenGL context (HGLRC) through WGL, Nsight creates an object that corresponds to the HGLRC, and it remembers the original HDC as well as the last HDC that was used with MakeCurrent and this context (current HDC). Later on we were using the original HDC for other operations, but this is invalid as the original HDC may have been deleted. It is correct to use the current HDC in most situations.

A potential workaround for now is to try avoiding the deletion of HDCs, and/or by just creating a single HDC and using that always. I am not sure if you have control over that.

As for why it didn’t show up in gDebugger, I can only guess, but as Nsight has a way to scrub back (and forth) in time in one frame, we need to keep track of more objects and states, therefore more room for issues.

Thanks

Thank you for your response. I don’t have control over the device contexts, I let Qt handle all that. It is just good to know that Qt doesn’t do anything extraordinarily weird in this regard. Although, admittedly, it is a little bit odd that Qt would release any HDC, when all I use it for in my “Hello World” example is to create a top level window.

I can not wait for the next release, with this fix and VS 2013 support my dev platform will be fully functional.

The NSight 2019.4.1 doesn’t work with Qt 5.13 in 2020.

NSight 2020.3.4 does not work with Qt 5.14 in Oct 2020.

Still not working with Qt4.8.7 from NSight 2021.3. On makeCurrent() call the app crashes if attempted to fire up from NSight. Driver 340.108