fyne-io/fyne · critical
eglInitialize failed\n
Error message
eglInitialize failed\n
What it means
x11.c then calls eglInitialize on the EGL display. Failure means EGL was given a display but could not initialize it: driver mismatch (32/64-bit or vendor confusion), no usable GPU device for this user, or a broken Mesa install. The process prints 'eglInitialize failed' and exits(1).
Source
Thrown at internal/driver/mobile/app/x11.c:111
EGLContext e_ctx;
EGLSurface e_surf;
Window win;
void
createWindow(void) {
x_dpy = XOpenDisplay(NULL);
if (!x_dpy) {
fprintf(stderr, "XOpenDisplay failed\n");
exit(1);
}
e_dpy = eglGetDisplay(x_dpy);
if (!e_dpy) {
fprintf(stderr, "eglGetDisplay failed\n");
exit(1);
}
EGLint e_major, e_minor;
if (!eglInitialize(e_dpy, &e_major, &e_minor)) {
fprintf(stderr, "eglInitialize failed\n");
exit(1);
}
eglBindAPI(EGL_OPENGL_ES_API);
win = new_window(x_dpy, e_dpy, 500, 1000, &e_ctx, &e_surf);
wm_delete_window = XInternAtom(x_dpy, "WM_DELETE_WINDOW", True);
if (wm_delete_window != None) {
XSetWMProtocols(x_dpy, win, &wm_delete_window, 1);
}
XMapWindow(x_dpy, win);
if (!eglMakeCurrent(e_dpy, e_surf, e_surf, e_ctx)) {
fprintf(stderr, "eglMakeCurrent failed\n");
exit(1);
}
// Window size and DPI should be initialized before starting app.
XEvent ev;View on GitHub (pinned to 8860ee95c3)
Solutions
- Check GPU access: ls -l /dev/dri/ and add the user to the video and render groups, then re-login
- Diagnose with EGL logging: EGL_LOG_LEVEL=debug LIBGL_DEBUG=verbose eglinfo
- Fall back to software EGL: LIBGL_ALWAYS_SOFTWARE=1 ./yourapp
- Reinstall/upgrade Mesa and vendor ICDs to clear the broken state
Example fix
# before: no permission on GPU nodes -> eglInitialize failed ./yourapp # after: grant DRI access (re-login required) or use software EGL sudo usermod -aG video,render "$USER" LIBGL_ALWAYS_SOFTWARE=1 ./yourapp
Defensive patterns
Strategy: validation
Validate before calling
func gpuAccessPreflight() error {
entries, err := os.ReadDir("/dev/dri")
if err != nil || len(entries) == 0 {
return fmt.Errorf("no DRI devices; run with LIBGL_ALWAYS_SOFTWARE=1 or enable GPU access")
}
return nil
} Prevention
- Ensure the runtime user is in the video and render groups
- Run EGL_LOG_LEVEL=debug eglinfo when initialization fails to get the driver reason
- Support LIBGL_ALWAYS_SOFTWARE=1 as a documented fallback in containers and CI
When it happens
Trigger: eglInitialize returning false: GPU device nodes (/dev/dri/*) unreadable for the running user, vendor ICD libraries in a bad state, or EGL picked up a display for a platform that has no backing device.
Common situations: Users not in the video/render groups (common in fresh Linux installs and WSL); containers without GPU device passthrough; systems after partial NVIDIA/Mesa upgrades; running as an unprivileged service user.
Related errors
- eglGetConfigAttrib failed\n
- eglCreateContext failed\n
- eglGetDisplay failed\n
- eglChooseConfig failed\n
- eglCreateWindowSurface failed\n
AI-assisted analysis of fyne-io/fyne@8860ee95c3 (2026-08-15).
Data as JSON: /api/errors/34c82c2e0b8a7f9f.
Report an issue: GitHub.