fyne-io/fyne · critical

eglChooseConfig failed\n

Error message

eglChooseConfig failed\n

What it means

First step of window creation in the X11/EGL backend of Fyne's mobile/app package (compiled for (linux && !android) || freebsd || openbsd, file x11.c). eglChooseConfig is asked for exactly one config that is GLES2-renderable, has EGL_WINDOW_BIT, 8-bit RGBA, 16-bit depth and no caveat. If EGL returns no matching config the program prints 'eglChooseConfig failed' to stderr and exits(1).

Source

Thrown at internal/driver/mobile/app/x11.c:33

static Atom wm_delete_window;

static Window
new_window(Display *x_dpy, EGLDisplay e_dpy, int w, int h, EGLContext *ctx, EGLSurface *surf) {
	static const EGLint attribs[] = {
		EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,
		EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
		EGL_BLUE_SIZE, 8,
		EGL_GREEN_SIZE, 8,
		EGL_RED_SIZE, 8,
		EGL_ALPHA_SIZE, 8,
		EGL_DEPTH_SIZE, 16,
		EGL_CONFIG_CAVEAT, EGL_NONE,
		EGL_NONE
	};
	EGLConfig config;
	EGLint num_configs;
	if (!eglChooseConfig(e_dpy, attribs, &config, 1, &num_configs)) {
		fprintf(stderr, "eglChooseConfig failed\n");
		exit(1);
	}
	EGLint vid;
	if (!eglGetConfigAttrib(e_dpy, config, EGL_NATIVE_VISUAL_ID, &vid)) {
		fprintf(stderr, "eglGetConfigAttrib failed\n");
		exit(1);
	}

	XVisualInfo visTemplate;
	visTemplate.visualid = vid;
	int num_visuals;
	XVisualInfo *visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);
	if (!visInfo) {
		fprintf(stderr, "XGetVisualInfo failed\n");
		exit(1);
	}

	Window root = RootWindow(x_dpy, DefaultScreen(x_dpy));

View on GitHub (pinned to 8860ee95c3)

Solutions

  1. Install a complete Mesa userspace: apt install libegl1 libegl-mesa0 libgl1-mesa-dri libgles2 mesa-utils
  2. Verify a matching config exists: eglinfo -B should list an EGL_WINDOW_BIT GLES2 config with alpha and depth
  3. Run with software rendering: LIBGL_ALWAYS_SOFTWARE=1 ./yourapp
  4. Use a real X server with GLX: xvfb-run -a -s '-screen 0 1024x768x24 +extension GLX' ./yourapp
  5. If you build this driver yourself, relax the attrib list in x11.c (drop EGL_ALPHA_SIZE or the EGL_CONFIG_CAVEAT line) and retry eglChooseConfig

Example fix

// before (x11.c): hard requirement of alpha + depth16, exit on no match
static const EGLint attribs[] = {
	EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
	EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8,
	EGL_ALPHA_SIZE, 8, EGL_DEPTH_SIZE, 16,
	EGL_NONE };
if (!eglChooseConfig(e_dpy, attribs, &config, 1, &num_configs)) { exit(1); }

// after: fall back to a config without alpha, then without depth
static const EGLint attribs_fallback[] = {
	EGL_SURFACE_TYPE, EGL_WINDOW_BIT,
	EGL_BLUE_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_RED_SIZE, 8,
	EGL_NONE };
if (!eglChooseConfig(e_dpy, attribs, &config, 1, &num_configs) || num_configs < 1) {
	if (!eglChooseConfig(e_dpy, attribs_fallback, &config, 1, &num_configs) || num_configs < 1)
		exit(1);
}
Defensive patterns

Strategy: validation

Validate before calling

func eglPreflight() error {
	if os.Getenv("DISPLAY") == "" {
		return fmt.Errorf("DISPLAY not set; run under X or xvfb-run")
	}
	if err := exec.Command("xdpyinfo").Run(); err != nil {
		return fmt.Errorf("X server unreachable: %w", err)
	}
	out, err := exec.Command("eglinfo", "-B").CombinedOutput()
	if err != nil || !bytes.Contains(out, []byte("OpenGL ES")) {
		return fmt.Errorf("no GLES-capable EGL config; install libgl1-mesa-dri libegl-mesa0 libgles2 mesa-utils")
	}
	return nil
}

// call before creating any window
if err := eglPreflight(); err != nil {
	log.Fatal(err)
}

Prevention

When it happens

Trigger: createWindow() at driver startup when the installed EGL implementation exposes no config matching RGBA8888 + depth16 + window-bit + GLES2: software EGL without depth, RGBX-only configs, or EGL on a display with no GPU support.

Common situations: Docker/CI containers with partial Mesa installs (libegl-mesa0 without libgl1-mesa-dri); Xvfb started without the GLX extension; VNC servers; Wayland-only stacks where EGL only advertises Wayland surface types; old or stripped proprietary drivers.

Related errors


AI-assisted analysis of fyne-io/fyne@8860ee95c3 (2026-08-15). Data as JSON: /api/errors/1076345288e25bad. Report an issue: GitHub.