fyne-io/fyne · critical

XCreateColormap failed\n

Error message

XCreateColormap failed\n

What it means

After resolving the visual, x11.c creates a colormap for it before creating the window. XCreateColormap returning NULL means the X server refused the allocation: usually resource limits on the server or an exotic visual (DirectColor, unusual depth) rather than TrueColor, for which colormaps are essentially free. The process prints 'XCreateColormap failed' and exits(1).

Source

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

		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));
	XSetWindowAttributes attr;

	attr.colormap = XCreateColormap(x_dpy, root, visInfo->visual, AllocNone);
	if (!attr.colormap) {
		fprintf(stderr, "XCreateColormap failed\n");
		exit(1);
	}

	attr.event_mask = StructureNotifyMask | ExposureMask |
		ButtonPressMask | ButtonReleaseMask | ButtonMotionMask;
	Window win = XCreateWindow(
		x_dpy, root, 0, 0, w, h, 0, visInfo->depth, InputOutput,
		visInfo->visual, CWColormap | CWEventMask, &attr);
	XFree(visInfo);

	XSizeHints sizehints;
	sizehints.width  = w;
	sizehints.height = h;
	sizehints.flags = USSize;
	XSetNormalHints(x_dpy, win, &sizehints);
	XSetStandardProperties(x_dpy, win, "App", "App", None, (char **)NULL, 0, &sizehints);

	static const EGLint ctx_attribs[] = {

View on GitHub (pinned to 8860ee95c3)

Solutions

  1. Run the X server at 24-bit TrueColor depth where colormap allocation cannot fail: xvfb-run -a -s '-screen 0 1024x768x24' ./yourapp
  2. Close leaking X clients or restart the X server / Xvfb instance
  3. Check server limits with xdpyinfo | grep -i 'number of' before launching
  4. Update the graphics stack if the failure persists on a normal desktop server

Example fix

# before: Xvfb at 8-bit depth, colormap allocation fails
Xvfb :99 -screen 0 1024x768x8 & DISPLAY=:99 ./yourapp

# after: TrueColor 24-bit server, colormap allocation succeeds
Xvfb :99 -screen 0 1024x768x24 & DISPLAY=:99 ./yourapp
Defensive patterns

Strategy: validation

Validate before calling

func xResourcePreflight() error {
	out, err := exec.Command("sh", "-c", "xdpyinfo | grep -i 'number of clients'").CombinedOutput()
	if err != nil {
		return fmt.Errorf("cannot query X server: %w", err)
	}
	_ = out // server reachable; restart it if colormap resources are exhausted
	return nil
}

Prevention

When it happens

Trigger: Creating a colormap for visInfo->visual fails on a server at its resource limit, or for a visual class that requires real colormap cells on an 8-bit/pseudocolor or otherwise non-TrueColor server.

Common situations: Long-running or leaky X servers (many clients allocated colormaps/cells); Xvfb started at low depth (8/16-bit); embedded or minimal X servers with tight resource pools.

Related errors


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