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 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?
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 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.
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?
Nested Virtualization with HyperV on EC2 instanceasked 3 years ago
Can I force each job to run on a dedicated instance?Accepted Answerasked 3 years ago
Unable to use Session Manager on EC2 instances in a private subnet with SSM VPC endpointAccepted Answerasked 3 years ago
Cannot run GUI/OpenGL on headless macOS EC2 Instanceasked 24 days ago
How to use EventBridge with Systems Manager Run Command to run shell commands?Accepted Answerasked 5 months ago
SSM Run CMD Support for MacOS in eu-central-1Accepted Answerasked 7 months ago
Cli "Unable to locate credentials" on EC2 instanceasked 13 days ago
Can't run angular tests within an Amplify Console Pipeline on amazonlinux:1Accepted Answerasked 3 years ago
Run Command Missing from EC2 ConsoleAccepted Answerasked 2 years ago
Unable to run tests reliablyasked 10 months ago