-
-
Notifications
You must be signed in to change notification settings - Fork 355
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
Display video of the windows instead of static screenshots #122
Comments
I've played around a bit with this and verified that the return value is indeed a reference to a Here is a full sample on the off chance that someone wants to mess around with this:
Compile using:
|
I think this is what would allows this to work very well: https://avaidyam.github.io/2018/02/17/CAPluginLayer_CABackdropLayer.html |
Oh this is interesting! I actually experimented with this at the very beginnings of the project! I didn't know anything about private APIs at that time though, so I had something working, but quickly replace it with the Quartz APIs. I'll revisit this and see if it can unlock live thumbnails! Thanks for sharing @galli-leo |
I just tested in a VM, and the method seems to work on macOS 10.14. Could someone else perhaps test on their 10.15 system to confirm that it doesn't work anymore? It's as easy as running this app. |
The creator of the blog post made a demo and posted to his github: https://github.com/avaidyam/Diorama Edit: Just noticed your screenshots above showcasing this. |
Yes this API stopped working in 10.15. It is a grim reminder that any private API we rely on to enable our useful apps can disappear with Big Sur or the next release. Not a great place to be in for us, but nothing we can do about it. My hope is that some Apple employees use our apps, and advocate for opening the APIs their require. For example, adding a public API to deal with Spaces. It boggles the mind that your can't write an app, using stable public APIs, that knows about the user Spaces after the feature being a core part of macOS for 10 years. |
Flagging with "big sur" to remember to check if they have new private APIs or (one can dream) public APIs we could use once Big Sur is released. |
New API in macOS 12 to capture video of windows: https://developer.apple.com/documentation/screencapturekit Here's a recap of my experimentations with it. |
Since v2, we have been using the
CGSHWCaptureWindowList
api to capture window images. I tried to refresh them on a timer at screen refresh-rate to simulate video. My POC worked but performance was an issue, when going beyond 30 fps, it becomes laggy and 60fps is not achieved.I noticed the introduction of a new private API in 10.15: SLSHWCaptureStreamCreateWithWindow. The name seems to imply that it may be given us a video stream. The name having
HW
for HardWare in it also implies that it would be a high-performance stream straight from the GPU, before compositing.@koekeishiya helped me guess the signature in an email exchange:
I tried with Hopper and noticed that there is a 5th argument:
Looking at
CGDisplayStream
docs, it seems clear that there is a need for a code block argument that is the callback that gets called on each frame of the display stream. I thus tried running the following code:This code works! We get a
CGDisplayStream
object:The issue now is that while the code block being
nil
doesn't crash, without a block, there is nothing we can do. For instance this is how the public API works:This works and the
debugPrint(status, displayTime, frameSurface, updateRef)
prints multiple linesHere in our private API case, when I try:
I get
Process finished with exit code 138 (interrupted by signal 10: SIGBUS)
I'm posting these notes in case somehow can help me find out with the last block argument is triggering a
SIGBUS
when provided. Maybe it's not of typeCGDisplayStreamFrameAvailableHandler
. How can I find the type then? I played a while with Hopper but I can't reverse-engineer the correct signature.The text was updated successfully, but these errors were encountered: