Skip to content

[Bug]: BrowserWindow.maximize Does Not Show Window on macOS #32947

Closed

Description

@dsanders11

Preflight Checklist

Electron Version

19.0.0-nightly.20220209

What operating system are you using?

macOS

Operating System Version

macOS 11.6.2

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

Maximizing a window which isn't being shown should show the window. According to the docs for BrowserWindow.maximize():

Maximizes the window. This will also show (but not focus) the window if it isn't being displayed already.

Actual Behavior

On macOS, the window is not shown, but window.isMaximized() returns true, and a subsequent window.show() will show a maximized window as expected.

Testcase Gist URL

https://gist.github.com/09e5ef031f69be2cce1e23c5174d6e5b

Additional Information

Tested on Windows 10 and Ubuntu and it works as expected, so this looks to be just macOS.

Activity

  1. added
    has-repro-gist
    on Feb 17, 2022
  2. moved this to Unsorted Issues in 18-x-yon Feb 17, 2022
  3. Sankingraitus commented on Feb 26, 2022

    @Sankingraitus
  4. moved this from Unsorted Issues to Blocks Stable in 18-x-yon Mar 10, 2022
  5. moved this from Blocks Stable to Doesn't Block Stable in 18-x-yon Mar 16, 2022
  6. Repository owner moved this from Doesn't Block Stable to Blocks Stable in 18-x-yon Mar 29, 2022
  7. moved this from Blocks Stable to Fixed for Next Release in 18-x-yon Mar 30, 2022
  8. bpasero commented on May 27, 2022

    @bpasero
    Contributor

    @dsanders11 I think this fix is not complete. From the docs:

    Maximizes the window. This will also show (but not focus) the window if it isn't being displayed already

    With your change, the window will still not be visible but rather put behind the "key" (active) window. I would expect that the window is put above the active window and thus becomes visible.

  9. dsanders11 commented on May 28, 2022

    @dsanders11
    MemberAuthor

    With your change, the window will still not be visible but rather put behind the "key" (active) window. I would expect that the window is put above the active window and thus becomes visible.

    The associated PR here simply calls through to window.showInactive(), so any incorrect behavior as described would be as a result of that method.

    That said, I can't reproduce this. In my testing it puts the second, unfocused window in front in z-order. Here's the fiddle I'm using to test, on macOS 12.4 and Electron v20.0.0-alpha.1. The second (unshown) window is maximized after 8 seconds. In my tests, it always put above the active window, but does not take focus (as expected).

    If you have a reproduce case, happy to take a look. But I'd suspect any buggy behavior will be in window.showInactive().

  10. bpasero commented on May 28, 2022

    @bpasero
    Contributor

    @dsanders11 yeah, I am also trying out in a Fiddle and I do not see the behaviour of VSCode, but I suspect this is due to how the issue reproduces in VS Code: users have reported that this issue reproduces when they launch VS Code from a terminal while VS Code is already running, so this also involves VS Code being inactive as application and another instance of VS Code trying to bring the first instance to front. To clarify:

    • one instance of VS Code is running with a window active and focused
    • user switches to OS terminal, VS Code is no longer active and focused
    • user types code folder path to open a new window on the folder
    • this launches a separate VS Code process for a very short moment that talks to the existing running instance
    • then it terminates after having send a payload to the first instance
    • the first instance opens a second window
    • this second window is initially show: false and then window.maximize
    • previously this would not show the window as inactive, but with your change it does
    • we check on window.isVisible to decide if we need to call window.show or not
    • now window.isVisible returns true even though the second window is behind the first window

    To clarify: in VS Code we have a condition that sets show: false when the window to open is either maximized or fullscreen. We do that because otherwise there is an ugly transition from normal window bounds to maximized or fullscreen that we want to prevent. As such, in those cases we simply call window.maximize first and then window.show. To be honest, I would love to drop this hack and just have a way to pass maximized: true or fullscreen: true right when creating the window so that we can remove this code on our end, I will file an issue on that maybe.

  11. bpasero commented on May 28, 2022

    @bpasero
    Contributor

    Opened: #34368

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

Metadata

Metadata

Assignees

Labels

14-x-y15-x-y16-x-y17-x-y18-x-ybug 🪲has-repro-gistplatform/macOS

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions