By using AWS re:Post, you agree to the Terms of Use
/Cannot run GUI/OpenGL on headless macOS EC2 Instance/

Cannot run GUI/OpenGL on headless macOS EC2 Instance

0

Hello,

I am currently trying to use EC2 mac instances to run a CI/CD pipeline which involves running tests with electron/selenium. In order to run these tests openGL needs to be available. Im currently getting there error on line 49 of https://chromium.googlesource.com/chromium/src/+/8f066ff5113bd9d348f0aaf7ac6adc1ca1d1cd31/ui/gl/init/gl_initializer_mac.cc.

With the output on the instance giving:

2022-06-09 19:38:25.937 Electron[52243:188559] +[NSXPCSharedListener endpointForReply:withListenerName:]: an error occurred while attempting to obtain endpoint for listener 'ClientCallsAuxiliary': Connection interrupted
[52245:0609/193826.555969:ERROR:gl_initializer_mac.cc(65)] Error choosing pixel format.
[52245:0609/193826.556035:ERROR:gl_initializer_mac.cc(193)] GLSurfaceCGL::InitializeOneOff failed.
[52245:0609/193826.664827:ERROR:viz_main_impl.cc(188)] Exiting GPU process due to errors during initialization

The root cause of this is there is no display connected to the mac1 bare metal dedicated host. It seems the work around here is either using a plug to fake that a display is connected, or connecting to the instance via vnc with the following commands:

On ec2 instance

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
-activate -configure -access -on \
-configure -allowAccessFor -specifiedUsers \
-configure -users ec2-user \
-configure -restart -agent -privs -all

sudo /System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart \
 -configure -access -on -privs -all -users ec2-user

On local macbook

ssh -L 5900:localhost:5900 -C -N -i <your private key.pem> ec2-user@<your public ip address>
open vnc://localhost

After establishing the connection over screen share, I no longer get the openGL issues and the run succeeds. Unfortunately this is not a solution/workaround for my use case as I will need to restart/reboot these instances after each run. I have tested this multiple times and after rebooting the instance the display is no longer present. (I have verified the displays being recognized / not being recognized with displayplacer list)

Some more background, this is an issue on the latest AWS Monterey and BigSur AMIs.

Is there any way to make the mac1 mini dedicated host think that there is a display plugged into it or trick it into thinking there is a display via software. I need a solution here that can be implemented via a script so setting something up like https://github.com/waydabber/BetterDummy does not work for me. Github seems to have a solution for this with their self-hosted github action runners so I am curious why AWS doesn't seem to support this / should this not be a common use case for an EC2 Mac Instance?

1 Answers
-1

Hello, thank you for your post. I understand you are running tests on your EC2 Mac instance and the tests require OpenGL. You have managed to workaround the OpenGL errors you initially encountered, by establishing a VNC connection via Apple Remote Desktop (ARD). This requires the use of the kickstart utility in order to set access privileges for the ARDAgent. The problem you are facing is that your workflow requires restarting the Mac instance, but after a restart, the display is no longer present. You need a solution that can be implemented via script.

In my review of the issue, I determined the best solution would be to use the "Run Command" feature of AWS Systems Manager. We have a blog post[1] with Mac-specific instructions for configuring the Run Command feature and executing scripts. Please take a look at this blog post to determine if it works for you.

References:
[1] https://aws.amazon.com/blogs/mt/manage-your-amazon-ec2-macos-instances-with-aws-systems-manager/

answered 20 days ago
  • Hi Sam, This work around does not work for me since it requires manually connecting to each instance via screen share and logging into the machine. I need the image to boot and already think that there is a display/monitor attached to it. So far I have no solution which can run as a script.

  • Is it possible to configure a dedicated host so it has an EDID or thinks a monitor/display is attached to the machine?

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions