On Mon Jul 1 16:42:43 2024 +0000, Tim Clem wrote:
I'm seeing these issues now (though I didn't have to revert !5798). Not sure how I missed them earlier. I tried doing everything in the background thread that `getCurrentProcessShareableContent` is called back on, but it didn't help - `captureImageWithFilter:` still doesn't call its block until the window is restored. Doing something heinous like blocking the main thread until the SCK calls complete actually does work and grab a snapshot in time, but I'd really rather not do that. Not sure what our best option is. Maybe Apple can make SCK able to capture miniaturized windows, or perhaps they can make `CGWindowListCreateImageFromArray` not prompt for permissions if you're asking for images of windows from your own app. Any thoughts?
Actually, I just had a realization - we're not going to be capturing minimized windows, we're going to be capturing *hidden* ones. In the actual use case for this code, we're trying to grab an image of a child window that's about to be hidden because its zero-sized parent is miniaturizing; we're not trying to snapshot the parent itself. The hacky way we're testing isn't representative of what would really happen.
The good news is that snapshotting a hidden window does seem to work without a delay. I'll try to find a real-world application that relies on this behavior, or make one myself.