electron/electron

[Bug]: BrowserWindow#show() does not consistently activate and show window

jz-notion opened this issue · 0 comments

Preflight Checklist

Electron Version

Reproducible since 30.0.0

What operating system are you using?

macOS

Operating System Version

Sonoma 14.4.1

What arch are you using?

arm64 (including Apple Silicon)

Last Known Working Electron version

29.3.3

Expected Behavior

Calling show() on a BrowserWindow instance should foreground and focus the window.

Actual Behavior

  • show() appears to be inconsistent in whether or not it foregrounds the window. Sometimes it works, sometimes it doesn't.
  • showInactive() appears to be consistent in foregrounding the window. (It just doesn't focus the window, which is expected.)

Testcase Gist URL

https://gist.github.com/jz-notion/20accc61a10f011eef7b2255a5b90c36

Additional Information

I noticed the implementation difference below for macOS 14.0 onwards. According to Apple docs, activate does not guarantee app activation.

Use this method to request app activation; calling this method doesn’t guarantee app activation.

if (@available(macOS 14.0, *)) {
[[NSApplication sharedApplication] activate];
} else {
[[NSApplication sharedApplication] activateIgnoringOtherApps:YES];

This topic was discussed during the change to using activate instead of activateIgnoringOtherApps: #40307 (comment)