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

CoreGraphics.CGWindowListCreateImage() failed when running as a system process. #133

Open
brummetj opened this issue Nov 14, 2019 · 6 comments

Comments

@brummetj
Copy link

brummetj commented Nov 14, 2019

General information:

  • OS name: macOS Catalina
  • OS version: 10.15
  • OS architecture: 64 bits
  • Resolutions:
    • Monitor 1: 1920x1080
  • Python version: 3.7.3
  • MSS version: 3.2.0

Description of the warning/error

I'm trying to run my python program as a launchd daemon process since its a REST flask app that needs to be running at all times and needs to have the ability to relaunch if the macOS gets rebooted.

One of the endpoints allows me to grab a screenshot of the current monitor. I really like to use your library for the lower level performance... but running as a launchd it seems that this will always fail to create the Image from the CoreGraphics.

CoreGraphics.CGWindowListCreateImage() failed.

Otherwise it works as long as it's being executed as the user, or even executing sudo on the python script works fine.

Am i missing something with System context and CoreGraphics API's ?

@BoboTiG
Copy link
Owner

BoboTiG commented Nov 14, 2019

In "Utilities > Console", do you have an error that may help us?
I think there is a security thing involved. Could you post the launchd code please?

@brummetj
Copy link
Author

Thanks for the prompt response.

I've been rummaging through the console logs and can't seem to find anything directly related to the CoreGraphics besides some CoreCapture crash logs which doesn't pertain anything related to the CoreGraphics module.

Do you have an idea on what error message could possibly look like ? I also think this is a security thing involved as well..

The launchd code is a 0. And runs fine, but once I hit that endpoint /screenshot which utilizes your mss library it will fail to get that screen capture with CoreGraphics.CGWindowListCreateImage() failed.

I have a potential work around idea of executing a subprocess script which will stdout the binary image as a different user.

@brummetj
Copy link
Author

Update:

I tried launching a forked screenshot process and executing as another user and will still get a failure with the CoreGraphics module... will need to look until other solutions until this is fixed

@BoboTiG
Copy link
Owner

BoboTiG commented Nov 15, 2019 via email

@ishandutta2007
Copy link

Same error whenever I run it from cron. Works fine when triggered explicitly from terminal

@BoboTiG BoboTiG reopened this Sep 6, 2021
@BoboTiG
Copy link
Owner

BoboTiG commented Sep 6, 2021

I do not have a macOS machine anymore. If someone wants to give a hand, that would be great :)

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

No branches or pull requests

3 participants