Blank Screen with Self-Compiled GTK4-rs App on Fedora and Debian-Based Templates

I have a fedora-41-xfce and a debian-12-xfce based StandaloneVMs. To make sure that GTK4 apps work correctly in them I installed nautilus to test it and it worked perfectly, although it was throwing this in the terminal:

Unrecognized value "gl-disable". Try GDK_DEBUG=help
Unrecognized value "vulkan-disable". Try GDK_DEBUG=help

I’m trying to compile the test “Hello World” app as detailed in the GTK4-rs book:

First installing the necessary GTK4 dev packages:

sudo dnf install gtk4-devel gcc

and

sudo apt install libgtk-4-dev build-essential

for Debian. Next rust needs to be installed,

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Once that is done we can create a new rust app:

cargo new my-gtk-app
cd my-gtk-app

We then determine the version of GTK4 that we have:

pkg-config --modversion gtk4

On debian it was 4.8 and on fedora 4.18. We can then add the gtk4-rs crate based on that version (for example for 4.18):

cargo add gtk4 --rename gtk --features v4_18

Next we change the src/main.rs file with the code necessary to display “Hello World” and a button:

use gtk::prelude::*;
use gtk::{glib, Application, ApplicationWindow, Button};

const APP_ID: &str = "org.gtk_rs.HelloWorld2";

fn main() -> glib::ExitCode {
    // Create a new application
    let app = Application::builder().application_id(APP_ID).build();

    // Connect to "activate" signal of `app`
    app.connect_activate(build_ui);

    // Run the application
    app.run()
}
fn build_ui(app: &Application) {
    // Create a button with label and margins
    let button = Button::builder()
        .label("Press me!")
        .margin_top(12)
        .margin_bottom(12)
        .margin_start(12)
        .margin_end(12)
        .build();

    // Connect to "clicked" signal of `button`
    button.connect_clicked(|button| {
        // Set the label to "Hello World!" after the button has been clicked on
        button.set_label("Hello World!");
    });

    // Create a window
    let window = ApplicationWindow::builder()
        .application(app)
        .title("My GTK App")
        .child(&button)
        .build();

    // Present window
    window.present();
}

To compile and run it we use:

cargo run

But in the end the app shows a blank screen when a button is supposed to be shown there. It also throws the same error as the one encountered with nautilus:

Unrecognized value "gl-disable". Try GDK_DEBUG=help
Unrecognized value "vulkan-disable". Try GDK_DEBUG=help

This shows that Qubes default configuration of GTK4 apps is indeed passed down to it.

I tried various configurations to force hardware acceleration like:

GDK_DEBUG= LIBGL_ALWAYS_SOFTWARE=1 GSK_RENDERER=cairo cargo run

But it always results in a blank window screen. Does anyone have any idea on what could be different between normal GTK4 apps and this self-compiled GTK4-rs app and why it’s showing a blank screen despite GTK4 apps working perfectly?

1 Like

I can no longer replicate the problem, I guess it was something wrong with my initial setup or something. I will try to see if the problem appears again in the following weeks. But for now I think this can be classified as “Solved”.

1 Like