Cannot run GUI/OpenGL on headless macOS EC2 Instance



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

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/] Error choosing pixel format.
[52245:0609/] GLSurfaceCGL::InitializeOneOff failed.
[52245:0609/] 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/ \
-activate -configure -access -on \
-configure -allowAccessFor -specifiedUsers \
-configure -users ec2-user \
-configure -restart -agent -privs -all

sudo /System/Library/CoreServices/RemoteManagement/ \
 -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 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?

2 Answers

You can setup autologin via defaults command in mac depending on your security requirements.

answered 2 years ago

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.


answered 2 years 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