Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: A bug with Wayland display (Error 71) in WSL #4864

Merged
merged 2 commits into from
Sep 10, 2024

Conversation

Zamoca42
Copy link
Contributor

☕️ Reasoning

Hello Team! This PR has been created after reviewing issue #4039.

`[email protected](xdg_wm_base@20, 4, "xdg_surface buffer (1160 x 757) does not match the configured maximized state (0 x 0)"

[3521097-278] -> [email protected]._maximized()
[3521097.300] -> [email protected]_fullscreen()
[3521098.399] [email protected](0, 0, array[4])
[3521098.410] [email protected] (900)
[3521101.5681] → [email protected]_min_size(900, 587)
[3521101.586] -> [email protected]_max_size (3840, 2160)
[3521101.617] -> [email protected]_window_geometry(0, 0, 1160, 757)

After running the command WAYLAND_DEBUG=1 pnpm run dev:desktop, I reviewed the logs and noticed the issue occurs when the window tries to maximize and then revert to its original size.

It seems that the tauri_plugin_window_state plugin conflicts with the maximized state in Wayland while attempting to restore the previously saved window size.

In fact, by removing the tauri_plugin_window_state plugin in gitbutler-tauri/src/main.rs, I confirmed that the application works in WSL.

Additionally, after removing the plugin, I verified that the application still opens correctly on other OS (Windows, macOS).
Although there would be a temporary loss of window state saving functionality, would it be a good idea to temporarily comment out the plugin as a workaround until the issue is fully resolved?

Before and after commenting out the plugin

comment-out-before-after

Retesting after commenting out

tauri-window-plugin-remove

🧢 Changes

  • Temporarily disabled the tauri_plugin_window_state plugin in gitbutler-tauri/src/main.rs to resolve compatibility issues with WSL.

🎫 Affected issues

Fixes: #4039

The window state plugin is causing issues with the application, so it is being temporarily disabled. This change will allow the application to function without the plugin until the issue can be resolved.
Copy link

vercel bot commented Sep 10, 2024

@Zamoca42 is attempting to deploy a commit to the GitButler Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added the rust Pull requests that update Rust code label Sep 10, 2024
@krlvi
Copy link
Member

krlvi commented Sep 10, 2024

Hey, thanks for debugging this @Zamoca42! Nice catch with this bug. Since this is only happening for Linux, how about we make the plug in conditionally added for all targets except linux?

Like so:

diff --git a/crates/gitbutler-tauri/src/main.rs b/crates/gitbutler-tauri/src/main.rs
index 03230a6b6..ccf40df66 100644
--- a/crates/gitbutler-tauri/src/main.rs
+++ b/crates/gitbutler-tauri/src/main.rs
@@ -38,7 +38,7 @@ fn main() {
                 .target(LogTarget::LogDir)
                 .level(log::LevelFilter::Error);
 
-            tauri::Builder::default()
+            let builder = tauri::Builder::default()
                 .setup(move |tauri_app| {
                     let window = gitbutler_tauri::window::create(
                         &tauri_app.handle(),
@@ -118,7 +118,6 @@ fn main() {
 
                     Ok(())
                 })
-                .plugin(tauri_plugin_window_state::Builder::default().build())
                 .plugin(tauri_plugin_single_instance::init(|_, _, _| {}))
                 .plugin(tauri_plugin_context_menu::init())
                 .plugin(tauri_plugin_store::Builder::default().build())
@@ -239,7 +238,11 @@ fn main() {
                         }
                         _ => {}
                     }
-                })
+                });
+            #[cfg(not(target_os = "linux"))]
+            let builder = builder.plugin(tauri_plugin_window_state::Builder::default().build());
+
+            builder
                 .build(tauri_context)
                 .expect("Failed to build tauri app")
                 .run(|app_handle, event| {

Disable the `tauri_plugin_window_state` plugin on Linux platforms as it
causes issues with the application's window behavior. This change ensures
the application runs smoothly across all supported platforms.
@Zamoca42
Copy link
Contributor Author

Wow, thanks for the review, @krlvi! That solution looks better than mine.

builder-refactor

After applying the code and testing it again, it still works perfectly. 👍

@krlvi krlvi merged commit 620ea14 into gitbutlerapp:master Sep 10, 2024
16 of 17 checks passed
@Byron
Copy link
Collaborator

Byron commented Sep 10, 2024

I looked at this for a moment and thought that maybe despite fixing a bug in Wayland, it introduces a regression for other linux users who now won't have their window-state set.
Maybe one day there is an even better solution, or the tauri plugin sees a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Can't open GitButler if closed when maximized (WSL)
3 participants