{"record":{"id":"e5b9ba131267f0e5","repo":"openjdk/jdk","slug":"s-i-error-domain-i-code-i-message-s-n","errorCode":null,"errorMessage":"!!! %s:%i Error: domain %i code %i message: \"%s\"\\n","messagePattern":"!!! (.+?):(.+?) Error: domain (.+?) code (.+?) message: \"(.+?)\"\\\\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/java.desktop/unix/native/libawt_xawt/awt/screencast_portal.c","lineNumber":54,"sourceCode":"extern volatile bool isGtkMainThread;\nextern gboolean isRemoteDesktop;\n\nextern struct ScreenSpace screenSpace;\n\nstruct XdgDesktopPortalApi *portal = NULL;\nextern int DEBUG_SCREENCAST_ENABLED;\n\nGDBusProxy *getProxy() {\n    return isRemoteDesktop ? portal->remoteDesktopProxy : portal->screenCastProxy;\n}\n\nvoid errHandle(\n        GError *error,\n        const gchar *functionName,\n        int lineNum\n) {\n    if (error) {\n        fprintf(stderr, \"!!! %s:%i Error: domain %i code %i message: \\\"%s\\\"\\n\",\n                functionName, lineNum,\n                error->domain, error->code, error->message);\n    }\n    if (error) {\n        gtk->g_error_free(error);\n    }\n    error = NULL;\n}\n\ngboolean validateToken(const gchar *token) {\n    if (!token) {\n        return FALSE;\n    }\n\n    gboolean isValid = gtk->g_uuid_string_is_valid(token);\n    if (!isValid) {\n        DEBUG_SCREENCAST(\"!!! restore token \"\n                         \"is not a valid UUID string:\\n\\\"%s\\\"\\n\",","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/java.desktop/unix/native/libawt_xawt/awt/screencast_portal.c#L36-L72","documentation":"The single error sink for all GLib/GIO GError conditions in the JDK's Wayland screencast portal code (used by java.awt.Robot screen capture under GNOME Wayland). errHandle() prints the failing function and line, the GError domain/code, and the DBus message, then frees the error. Seeing it means a portal DBus call — ScreenCast/RemoteDesktop session setup, SelectSources, Start, or PipeWire stream creation — failed.","triggerScenarios":"Robot.createScreenCapture()/createMultiFormatScreenCapture() on Wayland when the org.freedesktop.portal.Desktop request is denied or fails: user dismisses the screencast permission dialog, xdg-desktop-portal(-gnome) is missing or crashed, the compositor lacks screencast support, or the session token times out. The domain/code (e.g. G_IO_ERROR / portal Response errorCode) identifies which.","commonSituations":"Headless-ish containers or minimal WMs with no portals installed; first-run per-app portal permission denied and not remembered; GNOME version changes breaking portal API; flatpak/sandbox restrictions; PipeWire not running. Robot then throws or returns a failed capture.","solutions":["Check domain/code in the message: response errorCode 1 = user cancelled, 2 = failed — instruct/allow the user to grant permission","Ensure xdg-desktop-portal, xdg-desktop-portal-gnome (or -gtk) and pipewire/pipewire-pulse services are installed and running","Verify the desktop session is a portal-capable Wayland session (echo $XDG_SESSION_TYPE) and not a bare WM without screencast support","Run the app outside sandboxes or grant it screencast permission (flatpak override / portals config)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// before Robot capture on Linux, detect Wayland-without-portal capability\nif (System.getenv(\"XDG_SESSION_TYPE\", \"\").equals(\"wayland\") && !portalsAvailable()) {\n    // fall back to asking the user or running under XWayland\n}\nstatic boolean portalsAvailable() {\n    return Path.of(\"/usr/share/xdg-desktop-portal/portals\").toFile().list().length > 0\n        && new ProcessBuilder(\"systemctl\",\"is-active\",\"--user\",\"pipewire\").start().waitFor() == 0;\n}","typeGuard":null,"tryCatchPattern":"try { BufferedImage img = new Robot().createScreenCapture(rect); } catch (AWTException | RuntimeException e) { /* portal denied/failed: show manual-upload fallback */ }","preventionTips":["Document that Wayland screen capture needs xdg-desktop-portal + PipeWire and a granted permission","For automation/CI, run under X11/Xvfb where Robot needs no portal","Cache the portal permission by using a stable app ID so the grant persists"],"tags":["wayland","portal","dbus","robot","screencast","gnome","native"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}