Skip to content
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

Doesn't work with Mangohud #38

Closed
Hubro opened this issue Sep 11, 2021 · 10 comments
Closed

Doesn't work with Mangohud #38

Hubro opened this issue Sep 11, 2021 · 10 comments

Comments

@Hubro
Copy link

Hubro commented Sep 11, 2021

obs-glcapture doesn't seem to work when used at the same time as Mangohud. Instead, the outermost invocation gets precedence. For example, when running a OpenGL Steam game like:

obs-glcapture mangohud %command%

Game capture works, but Mangohud doesn't work.

If I use:

mangohud obs-glcapture %command%

Now Mangohud works, but game captures doesn't. (I just get a black screen.)

Is it possible to make them work at the same time?

@nowrep
Copy link
Owner

nowrep commented Sep 11, 2021

I don't think so, both use dlsym. Similarly I think it can't work with Steam overlay either.

@Hubro
Copy link
Author

Hubro commented Sep 11, 2021

I don't think so, both use dlsym. Similarly I think it can't work with Steam overlay either.

Actually Steam overlay does work while I'm recording. It even gets included in the recording.

Screenshot from OBS:

image

@nowrep
Copy link
Owner

nowrep commented Sep 11, 2021

Hmm, then maybe Steam is hooking the functions without dlsym.
I think it's not possible to chain hooks with dlsym, but I am not absolutely sure. Does mangohud + libstrangle work together?

Also one thing to note, mangohud by default isn't using dlsym - you have to use mangohud --dlsym ....

@nowrep
Copy link
Owner

nowrep commented Sep 12, 2021

You can try this

diff --git a/src/glinject.c b/src/glinject.c
index e4b22a2..c9fb3c8 100644
--- a/src/glinject.c
+++ b/src/glinject.c
@@ -16,6 +16,8 @@ You should have received a copy of the GNU General Public License along
 with this program. If not, see <https://www.gnu.org/licenses/>
 */
 
+#define _GNU_SOURCE
+
 #include "glinject.h"
 #include "capture.h"
 #include "utils.h"
@@ -59,7 +61,10 @@ struct gl_data {
 static struct gl_data data;
 
 #define GETADDR(s, p, func) \
-    p.func = (typeof(p.func))real_dlsym(handle, #s #func); \
+    p.func = (typeof(p.func))real_dlsym(RTLD_NEXT, #s #func); \
+    if (!p.func) { \
+        p.func = (typeof(p.func))real_dlsym(handle, #s #func); \
+    } \
     if (!p.func) { \
         hlog("Failed to resolve " #s #func); \
         return false; \

Problem with this is that it makes mangohud + alacritty EGL crash. It will crash when trying to call GL functions obtained from mangohud's eglGetProcAddress.
And with libstrangle + glxgears glXGetProcAddress will return functions from obs-glcapture which crashes it too.

Honestly it's a mess.

@nowrep nowrep closed this as completed in 42abffa Sep 12, 2021
@Hubro
Copy link
Author

Hubro commented Sep 12, 2021

Any idea how Steam overlay is working fine with all these other hooks? 🤔

@nowrep
Copy link
Owner

nowrep commented Sep 12, 2021

Not really, and of course there's no source code to look into.
It does use dlsym and seems to be calling the original functions resolved with dlsym(RTLD_NEXT, ...), but it also is linked to libGL. Maybe that's enough to make it work, hmmm.

@Hubro
Copy link
Author

Hubro commented Sep 12, 2021

By the way, I tried mangohud --dlsym just to be sure, and it didn't make a difference.

@nowrep
Copy link
Owner

nowrep commented Sep 12, 2021

Didn't make a difference when I tried myself either.

With current master it should work now with mangohud, as long as obs-glcapture is before mangohud.

@Hubro
Copy link
Author

Hubro commented Sep 12, 2021

Nice! I guess the perfect world scenario, where all OpenGL "overlay" applications work together no matter the order they are applied in, is impossible? 😄

Perhaps at some point we'll have a good translation layer to convert OpenGL calls to Vulkan on the fly, like DXVK does for DirectX 😄 (I wonder if Zink is in a working state for games yet?)

@nowrep
Copy link
Owner

nowrep commented Sep 12, 2021

Nice! I guess the perfect world scenario, where all OpenGL "overlay" applications work together no matter the order they are applied in, is impossible? smile

Yes, there is no standard way how to do it with OpenGL, as it is with Vulkan.

I've pushed another changes and it should now work fine with mangohud even for EGL. But I wonder what else will break.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants