Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

New Tab doesn't work without an open window on macOS #13689

Closed
cndouglas opened this issue Apr 3, 2018 · 9 comments · Fixed by #13749
Closed

New Tab doesn't work without an open window on macOS #13689

cndouglas opened this issue Apr 3, 2018 · 9 comments · Fixed by #13749

Comments

@cndouglas
Copy link

cndouglas commented Apr 3, 2018

Test plan

See #13749

Description

If there is no open window, New Tab (and New Private Tab and New Session Tab) does not work until New Window is selected.

This was working correctly in version 0.21.x but broke in 0.22.x.

Steps to Reproduce

macOS only

  1. Open Brave.
  2. Close the window without quitting Brave.
  3. Select Menubar > File > New Tab

Actual result:
Nothing happens.

Expected result:
A new window with the tab should open.

Reproduces how often:
Always

Brave Version

about:brave info:
Brave: 0.22.13
V8: 6.5.254.41
rev: a8cfb16
Muon: 5.1.2
OS Release: 17.5.0
Update Channel: Release
OS Architecture: x64
OS Platform: macOS
Node.js: 7.9.0
Brave Sync: v1.4.2
libchromiumcontent: 65.0.3325.181

Reproducible on current live release:
Yes, 0.22.13.

Additional Information

@bsclifton bsclifton added this to the Triage Backlog milestone Apr 3, 2018
@bsclifton
Copy link
Member

I believe @armaanahluwalia has identified the cause of this issue:
#13242 (comment)

See #8164 for more info

@armaanahluwalia would you be up for trying a fix? 😄

@bsclifton bsclifton added 0.22.x-single-webview Issue first seen on single-webview build against v0.22.x branch and removed 0.22.x-single-webview Issue first seen on single-webview build against v0.22.x branch labels Apr 3, 2018
@bsclifton bsclifton modified the milestones: Triage Backlog, 0.22.x Release 2 (Beta Channel) Apr 3, 2018
@armaanahluwalia
Copy link

@bsclifton Absolutely would be my pleasure to work on this project. Will begin working on it tomorrow and try to send up a fix soon.

@alexwykoff alexwykoff added release/not-blocking 0.22.x issue first seen in 0.22.x labels Apr 3, 2018
petemill added a commit that referenced this issue Apr 5, 2018
Fix #8164
Fix #13689

This bug was caused because menu items were using a hidden window for their new tabs.

We should _not_ use `electron{.remote}.BrowserWindow.getAllWindows()` or `.get{Active, Focused}Window` directly. There are two reasons that could have bad results:
1. We create BrowserWindows which are not normal tabbed renderer windows (e.g. some code that runs on Bookmark creation)
2. We have a hidden window sometimes (the Buffer Window)
Instead call `app/browser/window.js`: `getAllRendererWindows` and `getActiveWindowId`.
Fix for main menu actions, which can be called when there are no windows, but when searching for `BrowserWindow.`

Test Plan:
- Check all menu items open new tab in currently active window
- Check all menu items open new tab in currently active window, when app is not focused
- Check all menu items open new tab in new window if there is no visible window
- Check tabs in all windows are persisted on restart when app / windows close
- Check process quits in Windows when last visible window is closed
@petemill petemill assigned petemill and unassigned bsclifton Apr 5, 2018
@petemill
Copy link
Member

petemill commented Apr 5, 2018

@armaanahluwalia Apologies, but I had to fix this as we want to get it in to the next release. I also noticed that the fix was a bit more complicated than I had originally thought since on Windows, the code is called by a different process which does not have access to the internal window API. That's because on Windows, the main menu is part of each window process, whereas on other platforms the main menu is part of the application process. It would be great if you could take a look at my PR for the fix at #13749. Thanks for looking in to this issue and finding the cause! If you would like to contribute to any other features / fixes, I'd be happy to help.

@armaanahluwalia
Copy link

@petemill No worries at all. Thanks for taking this on. TBH a bit busy at the moment with job interviews. Anyway, I'm not sure I'd be able to contribute productively to reviewing this PR since I haven't had the time to parse the overall structure of the application code yet. I will do soon. Thanks for the shout out.

@eljuno
Copy link
Contributor

eljuno commented Apr 6, 2018

@bsclifton bsclifton modified the milestones: 0.22.x Release 2 (Beta Channel), 0.22.x Release 3 Apr 6, 2018
petemill added a commit that referenced this issue Apr 6, 2018
Fix #8164
Fix #13689

This bug was caused because menu items were using a hidden window for their new tabs.

We should _not_ use `electron{.remote}.BrowserWindow.getAllWindows()` or `.get{Active, Focused}Window` directly. There are two reasons that could have bad results:
1. We create BrowserWindows which are not normal tabbed renderer windows (e.g. some code that runs on Bookmark creation)
2. We have a hidden window sometimes (the Buffer Window)
Instead call `app/browser/window.js`: `getAllRendererWindows` and `getActiveWindowId`.
Fix for main menu actions, which can be called when there are no windows, but when searching for `BrowserWindow.`

Test Plan:
- Check all menu items open new tab in currently active window
- Check all menu items open new tab in currently active window, when app is not focused
- Check all menu items open new tab in new window if there is no visible window
- Check tabs in all windows are persisted on restart when app / windows close
- Check process quits in Windows when last visible window is closed
petemill added a commit that referenced this issue Apr 6, 2018
Fix #13689

This bug was caused because menu items were using a hidden window for their new tabs.

We should _not_ use `electron{.remote}.BrowserWindow.getAllWindows()` or `.get{Active, Focused}Window` directly. There are two reasons that could have bad results:
1. We create BrowserWindows which are not normal tabbed renderer windows (e.g. some code that runs on Bookmark creation)
2. We have a hidden window sometimes (the Buffer Window)
Instead call `app/browser/window.js`: `getAllRendererWindows` and `getActiveWindowId`.
Fix for main menu actions, which can be called when there are no windows, but when searching for `BrowserWindow.`

Test Plan:
- Check all menu items open new tab in currently active window
- Check all menu items open new tab in currently active window, when app is not focused
- Check all menu items open new tab in new window if there is no visible window
- Check tabs in all windows are persisted on restart when app / windows close
- Check process quits in Windows when last visible window is closed
@LaurenWags
Copy link
Member

@LaurenWags
Copy link
Member

Multiple +1s in community

@LaurenWags
Copy link
Member

Removed macOS label - linked test plan can mostly be checked on all platforms and does include a specific Windows check to be completed.

@LaurenWags
Copy link
Member

LaurenWags commented Apr 20, 2018

Verified on macOS 10.12.6 with
0.22.665 bc13ab6
Muon 5.2.5
libchromiumcontent 66.0.3359.117

Verified on Ubuntu 17.10
0.22.667 0433b26
Muon 5.2.6
libchromiumcontent 66.0.3359.117

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