{"record":{"id":"03aa90d9649d3f42","repo":"fyne-io/fyne","slug":"xcreatecolormap-failed-n","errorCode":null,"errorMessage":"XCreateColormap failed\\n","messagePattern":"XCreateColormap failed\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/driver/mobile/app/x11.c","lineNumber":56,"sourceCode":"\t\tfprintf(stderr, \"eglGetConfigAttrib failed\\n\");\n\t\texit(1);\n\t}\n\n\tXVisualInfo visTemplate;\n\tvisTemplate.visualid = vid;\n\tint num_visuals;\n\tXVisualInfo *visInfo = XGetVisualInfo(x_dpy, VisualIDMask, &visTemplate, &num_visuals);\n\tif (!visInfo) {\n\t\tfprintf(stderr, \"XGetVisualInfo failed\\n\");\n\t\texit(1);\n\t}\n\n\tWindow root = RootWindow(x_dpy, DefaultScreen(x_dpy));\n\tXSetWindowAttributes attr;\n\n\tattr.colormap = XCreateColormap(x_dpy, root, visInfo->visual, AllocNone);\n\tif (!attr.colormap) {\n\t\tfprintf(stderr, \"XCreateColormap failed\\n\");\n\t\texit(1);\n\t}\n\n\tattr.event_mask = StructureNotifyMask | ExposureMask |\n\t\tButtonPressMask | ButtonReleaseMask | ButtonMotionMask;\n\tWindow win = XCreateWindow(\n\t\tx_dpy, root, 0, 0, w, h, 0, visInfo->depth, InputOutput,\n\t\tvisInfo->visual, CWColormap | CWEventMask, &attr);\n\tXFree(visInfo);\n\n\tXSizeHints sizehints;\n\tsizehints.width  = w;\n\tsizehints.height = h;\n\tsizehints.flags = USSize;\n\tXSetNormalHints(x_dpy, win, &sizehints);\n\tXSetStandardProperties(x_dpy, win, \"App\", \"App\", None, (char **)NULL, 0, &sizehints);\n\n\tstatic const EGLint ctx_attribs[] = {","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/fyne-io/fyne/blob/8860ee95c356385effa5a7be51adb11c6be9d2b6/internal/driver/mobile/app/x11.c#L38-L74","documentation":"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).","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run the X server at 24-bit TrueColor depth where colormap allocation cannot fail: xvfb-run -a -s '-screen 0 1024x768x24' ./yourapp","Close leaking X clients or restart the X server / Xvfb instance","Check server limits with xdpyinfo | grep -i 'number of' before launching","Update the graphics stack if the failure persists on a normal desktop server"],"exampleFix":"# before: Xvfb at 8-bit depth, colormap allocation fails\nXvfb :99 -screen 0 1024x768x8 & DISPLAY=:99 ./yourapp\n\n# after: TrueColor 24-bit server, colormap allocation succeeds\nXvfb :99 -screen 0 1024x768x24 & DISPLAY=:99 ./yourapp","handlingStrategy":"validation","validationCode":"func xResourcePreflight() error {\n\tout, err := exec.Command(\"sh\", \"-c\", \"xdpyinfo | grep -i 'number of clients'\").CombinedOutput()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"cannot query X server: %w\", err)\n\t}\n\t_ = out // server reachable; restart it if colormap resources are exhausted\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use 24-bit TrueColor servers where colormaps are trivially allocated","Restart long-lived Xvfb instances in CI between heavy jobs","Avoid 8-bit or pseudocolor depths for OpenGL apps"],"tags":["c","x11","colormap","visual","xvfb"],"backgroundTag":null,"analyzedSha":"8860ee95c356385effa5a7be51adb11c6be9d2b6","analyzedAt":"2026-08-15T22:01:51.624Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}