{"record":{"id":"0d56e71b31845748","repo":"fyne-io/fyne","slug":"eglcreatewindowsurface-failed-n","errorCode":null,"errorMessage":"eglCreateWindowSurface failed\\n","messagePattern":"eglCreateWindowSurface failed\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"internal/driver/mobile/app/x11.c","lineNumber":85,"sourceCode":"\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[] = {\n\t\tEGL_CONTEXT_CLIENT_VERSION, 2,\n\t\tEGL_NONE\n\t};\n\t*ctx = eglCreateContext(e_dpy, config, EGL_NO_CONTEXT, ctx_attribs);\n\tif (!*ctx) {\n\t\tfprintf(stderr, \"eglCreateContext failed\\n\");\n\t\texit(1);\n\t}\n\t*surf = eglCreateWindowSurface(e_dpy, config, win, NULL);\n\tif (!*surf) {\n\t\tfprintf(stderr, \"eglCreateWindowSurface failed\\n\");\n\t\texit(1);\n\t}\n\treturn win;\n}\n\nDisplay *x_dpy;\nEGLDisplay e_dpy;\nEGLContext e_ctx;\nEGLSurface e_surf;\nWindow win;\n\nvoid\ncreateWindow(void) {\n\tx_dpy = XOpenDisplay(NULL);\n\tif (!x_dpy) {\n\t\tfprintf(stderr, \"XOpenDisplay failed\\n\");\n\t\texit(1);\n\t}","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/fyne-io/fyne/blob/8860ee95c356385effa5a7be51adb11c6be9d2b6/internal/driver/mobile/app/x11.c#L67-L103","documentation":"With a context created, x11.c calls eglCreateWindowSurface on the just-created X window using the same config. Failure means EGL refused to bind a window surface to that window/drawable: typically a config-vs-window visual mismatch, an EGL that expects a different platform, or an invalid drawable. The process prints 'eglCreateWindowSurface failed' and exits(1).","triggerScenarios":"eglCreateWindowSurface returning EGL_NO_SURFACE: window depth/visual incompatible with the chosen config under some drivers, EGL auto-platform detection picking the wrong platform (Xwayland quirks), or the window being destroyed before surface creation.","commonSituations":"Running under Xwayland with vendor EGL; outdated Mesa; apps or window managers closing the window during startup; remote X without GLX where a surface cannot be bound.","solutions":["Update Mesa / GPU driver to a current release","Force the X11 platform explicitly: EGL_PLATFORM=x11 ./yourapp","Run on a native X session (or Xvfb with GLX) rather than a remote display","Try software rendering to rule out the vendor path: LIBGL_ALWAYS_SOFTWARE=1 ./yourapp","Ensure nothing destroys the window between creation and surface binding (check for early WM_DELETE or crash in startup hooks)"],"exampleFix":"# before: platform auto-detection fails under Xwayland / vendor EGL\n./yourapp  # eglCreateWindowSurface failed\n\n# after: pin the X11 EGL platform explicitly\nEGL_PLATFORM=x11 ./yourapp","handlingStrategy":"validation","validationCode":"func surfacePreflight() error {\n\tif err := glesPreflight(); err != nil {\n\t\treturn err\n\t}\n\tif os.Getenv(\"WAYLAND_DISPLAY\") != \"\" && os.Getenv(\"EGL_PLATFORM\") == \"\" {\n\t\treturn fmt.Errorf(\"Xwayland session detected; set EGL_PLATFORM=x11 before running\")\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Export EGL_PLATFORM=x11 in launch scripts for this driver","Keep Mesa current; surface-creation failures are mostly fixed driver-side","Do not run the X11 driver against remote X servers without GLX"],"tags":["c","egl","x11","surface","xwayland","driver"],"backgroundTag":null,"analyzedSha":"8860ee95c356385effa5a7be51adb11c6be9d2b6","analyzedAt":"2026-08-15T22:01:51.624Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}