-
Notifications
You must be signed in to change notification settings - Fork 1.7k
bug: WebUI mode crashes on headless Linux without a DISPLAY variable #310
Description
Description
When running AionUi --webui on a headless Linux system (e.g., inside a proot-distro container without a graphical environment), the application crashes with a Segmentation fault.
This happens because the $DISPLAY environment variable is not set, and even though the application attempts to enable headless mode, Electron's UI platform fails to initialize.
Steps to Reproduce
- Set up a headless Linux environment (like a base Ubuntu in
proot-distro). - Install AionUi.
- Run
AionUi --webui.
Error Log
[.../ERROR:ui/ozone/platform/x11/ozone_platform_x11.cc:250] Missing X server or $DISPLAY
[.../ERROR:ui/aura/env.cc:257] The platform failed to initialize. Exiting.
Segmentation fault
Analysis
The root cause is that Electron, unlike pure Chromium, still has dependencies on a graphical environment even when running with a --headless flag. The current implementation in src/utils/configureChromium.ts correctly identifies the headless environment and adds the --headless switch, but this is not sufficient to prevent the crash.
The application crashes during the early initialization of the UI platform before the main application logic has a chance to run.
Workaround
The application can be started successfully by "tricking" it into believing a display is present:
export DISPLAY=:1
AionUi --webui --no-sandboxThis allows the application to get past the initial UI platform check and start the web server.
Suggested Fix
A proper fix would be to avoid the dependency on a display server altogether when in --webui mode.
One possible solution could be to use xvfb (X Virtual Framebuffer) to create a virtual display. This could be integrated into the startup script or launcher.
For example, a wrapper script could be used:
#!/bin/bash
if [[ "$OSTYPE" == "linux-gnu"* ]] && [ -z "$DISPLAY" ] && [[ " $* " == *" --webui "* ]]; then
# If on Linux, no display is set, and --webui is a parameter
xvfb-run -a AionUi "$@"
else
AionUi "$@"
fiAlternatively, there might be a more modern way to achieve a truly headless Electron application, but research indicates that xvfb is still the most reliable method.
Another option could be to check for the ELECTRON_RUN_AS_NODE environment variable. If this variable is set, Electron will run as a Node.js process, bypassing the Chromium rendering engine entirely. This might be a viable option for the web UI mode.