{"record":{"id":"10d129ffca793256","repo":"Yalantis/uCrop","slug":"cimgdisplay-screen-height-failed-to-open-x11-d","errorCode":null,"errorMessage":"CImgDisplay::screen_height(): Failed to open X11 display.","messagePattern":"CImgDisplay::screen_height\\(\\): Failed to open X11 display\\.","errorType":"exception","errorClass":"CImgDisplayException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":10567,"sourceCode":"#ifdef cimg_use_xrandr\n        if (X11_attr.resolutions && X11_attr.curr_resolution)\n          res = X11_attr.resolutions[X11_attr.curr_resolution].width;\n        else res = DisplayWidth(dpy,DefaultScreen(dpy));\n#else\n        res = DisplayWidth(dpy,DefaultScreen(dpy));\n#endif\n      }\n      return res;\n    }\n\n    static int screen_height() {\n      cimg::X11_attr &X11_attr = cimg::X11_attr::ref();\n      Display *const dpy = X11_attr.display;\n      int res = 0;\n      if (!dpy) {\n        Display *const _dpy = XOpenDisplay(0);\n        if (!_dpy)\n          throw CImgDisplayException(\"CImgDisplay::screen_height(): Failed to open X11 display.\");\n        res = DisplayHeight(_dpy,DefaultScreen(_dpy));\n        XCloseDisplay(_dpy);\n      } else {\n\n#ifdef cimg_use_xrandr\n        if (X11_attr.resolutions && X11_attr.curr_resolution)\n          res = X11_attr.resolutions[X11_attr.curr_resolution].height;\n        else res = DisplayHeight(dpy,DefaultScreen(dpy));\n#else\n        res = DisplayHeight(dpy,DefaultScreen(dpy));\n#endif\n      }\n      return res;\n    }\n\n    static void wait_all() {\n      cimg::X11_attr &X11_attr = cimg::X11_attr::ref();\n      if (!X11_attr.display) return;","sourceCodeStart":10549,"sourceCodeEnd":10585,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L10549-L10585","documentation":"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).","triggerScenarios":"Thrown at ucrop/src/main/jni/CImg.h:10567 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}