Open Reabs opened 1 year ago
Feels like a variation of #6698 but OpenGL instead of Vulkan. Can probably be fixed the same way if someone is interested.
We spent time debugging this issue, and here are the two three main points we discovered:
My personal theory is that for laptops, NVIDIA's internal code creates a separate thread for blitting the OpenGL backbuffer to the desktop or something. Either way, it happens in a separate thread than the OpenGL thread of the process, so it's possible that the passthrough trick may not be adequate.
So I took a stab at fixing this doing the methods we talked about but it seems like it will be a bit more complicated then just add a variable for first hooked and then don't let it hook into the other systems. After doing the fix and running my current setup I can avoid the crash.
Testing with various games however leads to various problems where games will sometimes hook into different setups that they don't use anyway notably hooking into dx9 first but then the capture hook you want is actually through dxgi. Also I've run into other games that will hook into openGL even though they end up using dx. My own setup seems to not work unless I have the openGL hook before the directX hook (I have multiple game captures of different programs at once) which is why I was able to notice the previous issue.
Just wanted to give an update to this since I said I would try to do a pull but also don't want to cause other issues to surface.
We spent time debugging this issue, and here are the ~two~ three main points we discovered:
- NVIDIA's driver/interface is creating its own DXGI context separately from the OpenGL context
- The rendering happens in a completely separate thread
- It only appears to happen with laptops (presumably because of multiple adapters)
My personal theory is that for laptops, NVIDIA's internal code creates a separate thread for blitting the OpenGL backbuffer to the desktop or something. Either way, it happens in a separate thread than the OpenGL thread of the process, so it's possible that the passthrough trick may not be adequate.
This might've been the result of NVIDIA's "Threaded Optimizations", which has been known to cause several problems with OpenGL (a quick example is the Sodium mod for Minecraft).
This might've been the result of NVIDIA's "Threaded Optimizations", which has been known to cause several problems with OpenGL (a quick example is the Sodium mod for Minecraft).
Not relevant.
This is probably due to combined hooking from multiple applications, which OBS doesn't perform well via its stock implementation of Detours.
Nahimic, Default install of RTSS (has a detours compatible mode at the users discretion) Asus GPU tweak overlay, etc, can all die when trying to co-exist with OBS leading to crashing.
Operating System Info
Windows 10
Other OS
No response
OBS Studio Version
29.1.3
OBS Studio Version (Other)
No response
OBS Studio Log URL
https://obsproject.com/logs/QbSPUOoZFrMFhQda
OBS Studio Crash Log URL
No response
Expected Behavior
My program would not crash when disabling and re-enabling capture source in obs.
Current Behavior
Disabling and re-enabling capture feed in obs will crash my program using openGL due to an access violation inside of graphics-hook.dll
Steps to Reproduce
Anything else we should know?
I use the same engine for a lot of different programs and they all have this same issue I've tried to see if there is some way I can change how swapbuffers is working but google doesn't seem to be any help and the feature on nvidia's control panel "Vulkan/OpenGL present method" doesn't seem to have any effect on it.
I believe this is related to this issue https://github.com/obsproject/obs-studio/pull/970
I think this is because SwapBuffers seems to use dxgi under the hood. If I remove SwapBuffers from my code when obs tries to hook into my program it outputs this....
however when I make the call to SwapBuffers then the output looks like this....
This is actually still fine as long as the source remains active at all times however if I disable the source or switch to a scene that doesn't have this source obs does this....
Which then when I either re-enable the source or switch back to the scene with the source in it my program will crash inside of graphics-hook.dll with this "Exception thrown at 0x77CCF633 (ntdll.dll) in GameSync.exe: 0xC0000005: Access violation writing location 0x00000014."
Call Stack:
Occasionally one other scenario can happen where it seems to actually hook to the dxgi (Maybe 1 out or 20 executions)....
When this happens everything seems to work as normal and disabling and re-enabling the source over and over seems to have no problem...