Skip to content

fix(mac): fix creating new windows while in fullscreen - #1197

Open
atlv24 wants to merge 1 commit into
tauri-apps:devfrom
atlv24:ad/mac-fix
Open

atlv24 wants to merge 1 commit into
tauri-apps:devfrom
atlv24:ad/mac-fix

Conversation

@atlv24

@atlv24 atlv24 commented Mar 20, 2026

Copy link
Copy Markdown

on macOS, the set_visible(true), set_focus(), and WindowBuilder::build() with visible=true all deadlock when called from inside the event loop callback while another window is in fullscreen. There's no way to detect or prevent this without pulling in objc2, which is nasty in code that should be platform agnostic.

The problem is that make_key_and_order_front_sync() uses run_on_main() to call makeKeyAndOrderFront: which triggers a macOS Space transition animation when another window is in fullscreen. The animation needs the Cocoa run loop to pump events, but the run loop is blocked waiting for the event loop callback to return, so it deadlocks.

This PR fixes this by just making make_key_and_order_front_sync and related helpers to use DispatchQueue::main().exec_async() instead of run_on_main(), like most other operations in the file.

Repro:

Run this app:

use tao::event::{Event, StartCause, WindowEvent};
use tao::event_loop::{ControlFlow, EventLoop};
use tao::window::{Fullscreen, WindowBuilder};

fn main() {
  let event_loop = EventLoop::new();
  let window = WindowBuilder::new()
    .with_title("mac bug repro")
    .build(&event_loop)
    .unwrap();
  let mut second_window: Option<tao::window::Window> = None;
  event_loop.run(move |event, event_loop, control_flow| {
    *control_flow = ControlFlow::Wait;
    match event {
      Event::WindowEvent {
        event: WindowEvent::KeyboardInput { .. },
        ..
      } => {
        second_window = Some(
          WindowBuilder::new()
            .with_title("Second Window")
            .build(event_loop)
            .unwrap(),
        );
      }
      Event::WindowEvent {
        event: WindowEvent::CloseRequested,
        ..
      } => {
        *control_flow = ControlFlow::Exit;
      }
      _ => {}
    }
  });
}

Press a key to spawn another window

Use this menu option to enter split-screen with the other window of the same app
image

Press a key

Before fix behavior: deadlock/hang
After fix: no deadlock, it spawns windows tabbed.

@atlv24
atlv24 requested a review from a team as a code owner March 20, 2026 02:56
@github-actions

Copy link
Copy Markdown
Contributor

Package Changes Through 10303cb

There are 1 changes which include tao with patch

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tao 0.34.6 0.34.7

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants