Skip to content

fix(desktop): call disableTitleBar off the EDT to avoid macOS deadlock - #72

Open
YSoung99 wants to merge 1 commit into
NihilDigit:mainfrom
YSoung99:fix/macos-titlebar-deadlock
Open

YSoung99 wants to merge 1 commit into
NihilDigit:mainfrom
YSoung99:fix/macos-titlebar-deadlock

Conversation

@YSoung99

@YSoung99 YSoung99 commented Dec 2, 2026

Copy link
Copy Markdown

Refs #69

Problem

On macOS, Piko can freeze permanently when a window (e.g. the player / clip preview) is shown. A sample of the frozen process (posted in #69) shows:

  • AWT-EventQueue-0 blocked in Skiko's -[LayerHandler disableTitlebar:] → dispatch_sync(dispatch_get_main_queue(), …)
  • the AppKit main thread inside LWCToolkit.doAWTRunLoop (nested run loop in javaRunLoopMode, which doesn't drain the GCD main queue), waiting for the EDT

So the EDT waits for the main queue while the main thread waits for the EDT.

Change

MacTitleBarEffect now runs disableTitleBar() on Dispatchers.IO instead of the EDT, so only a background thread blocks on dispatch_sync. The main thread can finish its nested loop and then run the block. The rest of the effect (waiting for isShowing, MacOs.patchTitleBarDoubleClick()) is unchanged.

Testing

  • Built :desktopApp:compileKotlinDesktop from the v1.7.0 tag with this change (macOS 27.3, Apple M4) and swapped the two changed classes into an installed 1.7.0 build. The app starts normally and the custom title bar is applied as before.
  • The deadlock is timing dependent, so I can't fully prove it's gone. I'm continuing to use the patched build and will report back in [macOS] Piko becomes unresponsive when opening a video in the built-in player #69.
  • Not compiled for Android locally; the change is in desktopMain only.

Note

Skiko's native lookup iterates its global layerStorage, which is otherwise mutated on the EDT, so calling it off the EDT has a small theoretical race. A cleaner fix might belong in Skiko itself. @K-MarkLee is also trying a "call before the window is shown" approach in #69; the two could be combined.

🤖 Generated with Claude Code

Skiko's native disableTitlebar does dispatch_sync to the main queue. When
MacTitleBarEffect calls it on the EDT while the AppKit main thread is in
LWCToolkit's nested run loop waiting for the EDT, both threads wait on each
other and the UI freezes permanently. Run the call on Dispatchers.IO so only
a background thread blocks.

Refs NihilDigit#69

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@YSoung99

YSoung99 commented Dec 3, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request Dec 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant