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

macOS 12+ cannot find the OpenGL framework #826

Open
tanis2000 opened this issue Sep 26, 2022 · 4 comments
Open

macOS 12+ cannot find the OpenGL framework #826

tanis2000 opened this issue Sep 26, 2022 · 4 comments
Labels

Comments

@tanis2000
Copy link

I have compiled apitrace from source on macOS Monterey on a Silicon M1 Mac and it looks like everything went smooth.
But when I try to run apitrace with any OpenGL-based applications I get the following error:

apitrace: tracing to /Users/tanis/Documents/binocle-c-adventure-game/cmake-build-debug/src/binocle-c-adventure-game.app/Contents/MacOS/binocle-c-adventure-game.1.trace
apitrace: error: couldn't load /System/Library/Frameworks/OpenGL.framework/OpenGL

Anyone who has any clue what is going wrong here and how to fix it?

@jrfonseca
Copy link
Member

jrfonseca commented Sep 27, 2022

Yep, tracing on recent macOS is completely broken. 😞

The trick that apitrace used of symlink /System/Library/Frameworks/OpenGL.framework/OpenGL in order to get the true OpenGL framework no longer works because /System/Library/Frameworks/OpenGL.framework/OpenGL not longer exists as a file on the file system, but it's rather pre-compiled into /System/Library/dyld/dyld_shared_cache_* and emulated by dlopen.

And I don't see another solution to get to the true /System/Library/Frameworks/OpenGL.framework/OpenGL, because dlopen("/System/Library/Frameworks/OpenGL.framework/OpenGL") returns the apitrace's CGL wrapper framework, causing infinite recursing.

Probably the only solution is to use DYLD_INSERT_LIBRARIES as prototyped in https://github.com/apitrace/apitrace/tree/dyld-interpose

But I don't have much interest or time for OpenGL on macOS. I honestly feel tempted to drop macOS support altogether.

However I just rebased https://github.com/apitrace/apitrace/tree/dyld-interpose branch on top of master, and confirmed it does work. So give it that branch a go. glretrace won't work. But tracing at least does. Then you can build glretrace/qapitrace on the master branch to analyze the trace. Is the best I can do for now.

@jrfonseca jrfonseca changed the title macOS M1 Silicon cannot find the OpenGL framework macOS 12+ cannot find the OpenGL framework Sep 27, 2022
@tanis2000
Copy link
Author

I will give that branch a go, thanks so much! And please do not drop support for macOS. I understand your frustration but apitrace has saved my day so many times while building my own OpenGL engine, I can't even count them!

I can also help maintaining macOS compatibility but I am not familiar with the codebase, thus why I asked here rather than trying to tweak the code to make it work. And I believe there are others out there that still benefit from apitrace on macOS :)

@jrfonseca
Copy link
Member

Help with macOS would definitely be appreciated!

The changes in master...dyld-interpose are few, but unfortunately it breaks:

  • retrace on macOS
  • trace on all other OSes

So getting dyld-interpose in a state where it can be merged implies fixing up the code

This is easier said than those, because the DYLD_INSERT_LIBRARIES is quite unique compared with all other interception mechanisms.

If merging dyld-interpose is too hard, then what we can do is to fork macOS support onto this branch, ie, drop support from macOS from master, and drop support for everything but macOS on dyld-interpose (perhaps renamed to macos) It still requires fixing up glretrace support on this branch, but that's easier than dealing with very different injection mechanisms on the same branch.

After all, OpenGL on macOS is not going to change ever (no new extensions, etc.) so forking apitrace for macOS might be the right call to make, certainly the least uphill struggle.

@JayFoxRox
Copy link
Contributor

JayFoxRox commented Aug 24, 2023

Currently I build apitrace twice: once for glretrace, and then another time for the cgl tracer.

Would it be an option to generate preprocessor macros which will become part of the generated files?
Then different platforms or tracing and retracing could use different code-paths.

I'm not familiar with the codebase, but I might try it when I find some free-time (which might still take a while).


I think keeping macOS upstream is very important because it's pretty much the only remaining tool to debug OpenGL on macOS. When Renderdoc removed macOS the state of it got worse quickly.

Also, although OpenGL won't change much on macOS, apitrace will probably continue to get updates (even if at slow pace). Maintaining a fork is probably more work than keeping macOS alive in the current codebase (and fixing it from time to time).


I had to do rebase dyld-interpose because my system has Qt6 already (I couldn't get it to compile with Qt5).

It worked then but there was a Qt error with QString + QLatin1String("("). It was trivial to fix by using QString instead of QLatin1String.
Not sure why it doesn't affect other platforms?

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

No branches or pull requests

3 participants