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

First window created is not in a tab on macOS... #2238

Open
sshock opened this issue Apr 4, 2022 · 6 comments
Open

First window created is not in a tab on macOS... #2238

sshock opened this issue Apr 4, 2022 · 6 comments
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - macos

Comments

@sshock
Copy link
Contributor

sshock commented Apr 4, 2022

For this test make sure you have "Prefer tabs" set to "always" in system preferences.

When testing the multiwindow example program I noticed:

  • Initial 3 windows created in the code are grouped together with tabs.
  • First window created by hitting a key ends up in a totally separate window.
  • Further windows created by hitting a key do get grouped with that one.

I don't understand why it makes a separate window that first time.

The good news is this problem doesn't occur in at least one downstream project, alacritty. But that just makes me even more curious to know what causes the problem and how one would avoid it.

@madsmtm madsmtm added B - bug Dang, that shouldn't have happened DS - macos C - needs investigation Issue must be confirmed and researched labels Apr 17, 2022
@madsmtm
Copy link
Member

madsmtm commented Apr 17, 2022

Can't test it myself (macOS 10.14.6 Mojave doesn't have that setting), but there are commonly smaller issues on macOS when creating windows outside EventLoop::run (which we should reconsider whether to allow at some point).

Could you try it with the first three windows being created inside Event::NewEvents(StartCause::Init) instead?

@madsmtm
Copy link
Member

madsmtm commented Apr 18, 2022

I tested this using a custom menubar setup (where the "Merge All Windows" option is available), can reproduce that windows created before EventLoop::run are in some way "separate" from windows created inside.

Odd that it doesn't happen in alacritty though, I think they create the first window outside of EventLoop::run?

@sshock
Copy link
Contributor Author

sshock commented Apr 19, 2022

Odd that it doesn't happen in alacritty though, I think they create the first window outside of EventLoop::run?

Yeah, that's what I thought too, and it makes me really curious how it doesn't have this issue...

Could you try it with the first three windows being created inside Event::NewEvents(StartCause::Init) instead?

Sure, I'll give it a try soon.

@kchibisov
Copy link
Member

I think they create the first window outside of EventLoop::run?

Yes, we create the first Window before EventLoop::run_return on macOS.

@sshock
Copy link
Contributor Author

sshock commented Apr 19, 2022

Still no idea why alacritty doesn't suffer from this problem, but I have good news: I just confirmed with the multiwindow example program that the problem goes away if I have it wait and create the initial windows inside of the event_loop.run.

@madsmtm
Copy link
Member

madsmtm commented Jun 8, 2022

A hunch I had was that the application hadn't entered multithreading mode yet and that's what's causing the differences, but that's not it either...

(Can be checked using [NSThread isMultiThreaded], it changes to true at some point inside -[NSApplication finishLaunching])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B - bug Dang, that shouldn't have happened C - needs investigation Issue must be confirmed and researched DS - macos
Development

No branches or pull requests

3 participants