Skip to content

Ubuntu 22.04 (GTK 4.6) support: two root causes blocking build and runtime #10

Description

@Taeyoung96

Summary

Limux v0.1.4 fails to build and run on Ubuntu 22.04 (Jammy Jellyfish) for two independent reasons. This issue documents both root causes with reproduction steps, and a companion PR contains the minimal fixes.


Root Cause 1 — gtk4-rs 0.11 API is incompatible with GTK 4.6

Background

Ubuntu 22.04 ships GTK 4.6.x as its stable GTK release. The gtk4-rs Rust crates version-match the underlying C library:

gtk4-rs crate version Compatible GTK C version
0.6.x GTK 4.6.x (Ubuntu 22.04)
0.7.x GTK 4.8.x
0.8.x GTK 4.10.x
0.9–0.11.x GTK 4.12–4.16+

Limux v0.1.4 declares:

# rust/limux-host-linux/Cargo.toml (upstream v0.1.4)
gtk4       = { version = "0.11", features = ["v4_10"] }
gdk4-wayland = "0.11"
libadwaita  = "0.9"
webkit6     = { version = "0.6", optional = true }

What breaks

a) features = ["v4_10"] enables GTK 4.10 symbols that are absent on Ubuntu 22.04

The v4_10 feature gate enables gtk4-rs to compile in calls to symbols first introduced in GTK 4.10 (e.g. gdk_display_create_gl_context). On Ubuntu 22.04 those symbols do not exist in libgtk-4.so.1, so the linker fails.

Reproduction:

# On Ubuntu 22.04 (GTK 4.6.7)
cargo build -p limux-host-linux
# error: could not find function `gdk_display_create_gl_context` in `libgtk-4.so.1`

b) glib::Propagation and glib::ControlFlow do not exist in gtk4-rs 0.6

gtk4-rs 0.9+ replaced the signal::Inhibit type and glib::Continue with:

// gtk4-rs ≥ 0.9 (does NOT compile on 0.6):
glib::Propagation::Stop
glib::Propagation::Proceed
glib::ControlFlow::Continue

gtk4-rs 0.6 (the version that matches GTK 4.6) still uses the legacy API:

// gtk4-rs 0.6 (required for Ubuntu 22.04):
use gtk::glib::signal::Inhibit;
Inhibit(true)   // stop propagation
Inhibit(false)  // allow propagation
glib::Continue(true)  // keep timer/idle running

Attempting to build the upstream code with gtk4-rs 0.6 produces errors like:

error[E0433]: failed to resolve: use of undeclared crate or module `Propagation`
  --> src/terminal.rs:520:13
   |
   | glib::Propagation::Stop
   |       ^^^^^^^^^^^ not found in `glib`

c) libwebkitgtk-6.0-dev is not available on Ubuntu 22.04

webkit6 = { version = "0.6" } requires the libwebkitgtk-6.0-dev system package, which is only available from Ubuntu 23.04 (Lunar) onwards. On Ubuntu 22.04:

sudo apt install libwebkitgtk-6.0-dev
# E: Unable to locate package libwebkitgtk-6.0-dev

Fix

Pin the crate versions to those that match GTK 4.6 and stub out the unavailable WebKit feature:

gtk4         = { version = "0.6" }      # no version feature flags
gdk4-wayland = "0.6"
libadwaita   = "0.3"
# webkit removed; stub feature retained for build-script compatibility

Replace glib::Propagation::Stop/ProceedInhibit(true/false) and glib::ControlFlow::Continueglib::Continue(true) in all signal handlers.


Root Cause 2 — GTK 4.6 ignores set_required_version(4, 3) and always creates an OpenGL 3.2 context

Background

Ghostty's GPU renderer requires OpenGL 4.3 core profile. The natural way to request this from GtkGLArea is:

gl_area.set_required_version(4, 3);

What breaks on GTK 4.6

GTK 4.6's GDK backend honours only OpenGL 3.2 when creating the GdkGLContext for a GtkGLArea, regardless of the version requested. The required-version property is effectively ignored.

Additionally, GTK 4.6 on Ubuntu 22.04 defaults to the EGL backend even on X11 (including NVIDIA systems). glXGetCurrentDisplay() therefore returns NULL inside connect_realize, making a pure GLX fallback insufficient.

The result: Ghostty calls OpenGL 4.3 entry points (compute shaders, SSBOs, etc.) on a 3.2 context, which immediately produces GL errors and a blank/crashed terminal.

Reproduction:

# On Ubuntu 22.04 with NVIDIA GPU (GTK 4.6, EGL backend)
./target/release/limux
# Terminal pane is black / blank; stderr shows:
# GL_INVALID_OPERATION ... compute shaders require OpenGL 4.3+
# (or similar Ghostty renderer errors)

Fix

After GTK calls make_current() inside connect_realize (making the 3.2 context current), manually create an OpenGL 4.3 core context via raw EGL or GLX using dlopen/dlsym:

  1. Try EGL first (GTK 4.6 default, even on X11):
    • eglGetCurrentDisplay() / eglGetCurrentContext() to obtain the current EGL state
    • eglCreateContext() requesting major=4, minor=3, core profile
  2. Fall back to GLX if EGL is not active:
    • glXGetCurrentDisplay() + glXCreateContextAttribsARB() requesting 4.3

Switch to this context before each call to ghostty_surface_draw().

An environment variable LIMUX_GL_BACKEND=auto|egl|glx lets users override the backend selection when needed.

This approach works because NVIDIA's driver supports OpenGL 4.3 over both EGL and GLX; the limitation is only in GTK 4.6's GDK layer, not in the driver itself.


Affected versions

Component Affected Notes
Ubuntu 22.04 (Jammy) ✅ Both root causes GTK 4.6.7, EGL default
Ubuntu 22.10 / 23.04+ RC1 only (gtk4-rs API) GTK 4.8+
Arch / Fedora (GTK 4.14+) Not affected gtk4-rs 0.11 works fine

Related

Companion PR with minimal fixes: #11

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions