Yalantis/uCrop · error · CImgDisplayException
CImgDisplay::screen_height(): Failed to open X11 display.
Error message
CImgDisplay::screen_height(): Failed to open X11 display.
What it means
Thrown by CImgDisplay::screen_height() when no X11 display connection is available: the cached X11_attr display pointer is null and a fallback XOpenDisplay(0) also fails to connect to an X server (typically no DISPLAY environment variable or no server running on headless systems).
Solutions
- Set the DISPLAY environment variable to a reachable X server (e.g. export DISPLAY=:0) before running the program
- Run the application in a desktop session or under an X server (Xvfb, VNC, or XQuartz for remote/headless use)
- Link CImg with an alternative display backend supported on your platform instead of X11
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at ucrop/src/main/jni/CImg.h:10567 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Yalantis/uCrop@f788b534b4 (2026-09-08).
Data as JSON: /api/errors/10d129ffca793256.
Report an issue: GitHub.
Appendix: source
Thrown at ucrop/src/main/jni/CImg.h:10567
#ifdef cimg_use_xrandr
if (X11_attr.resolutions && X11_attr.curr_resolution)
res = X11_attr.resolutions[X11_attr.curr_resolution].width;
else res = DisplayWidth(dpy,DefaultScreen(dpy));
#else
res = DisplayWidth(dpy,DefaultScreen(dpy));
#endif
}
return res;
}
static int screen_height() {
cimg::X11_attr &X11_attr = cimg::X11_attr::ref();
Display *const dpy = X11_attr.display;
int res = 0;
if (!dpy) {
Display *const _dpy = XOpenDisplay(0);
if (!_dpy)
throw CImgDisplayException("CImgDisplay::screen_height(): Failed to open X11 display.");
res = DisplayHeight(_dpy,DefaultScreen(_dpy));
XCloseDisplay(_dpy);
} else {
#ifdef cimg_use_xrandr
if (X11_attr.resolutions && X11_attr.curr_resolution)
res = X11_attr.resolutions[X11_attr.curr_resolution].height;
else res = DisplayHeight(dpy,DefaultScreen(dpy));
#else
res = DisplayHeight(dpy,DefaultScreen(dpy));
#endif
}
return res;
}
static void wait_all() {
cimg::X11_attr &X11_attr = cimg::X11_attr::ref();
if (!X11_attr.display) return;View on GitHub (pinned to f788b534b4)