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

Finder tabs show as separate windows #383

Closed
alt-tab-macos-bot opened this issue Jun 19, 2020 · 21 comments
Closed

Finder tabs show as separate windows #383

alt-tab-macos-bot opened this issue Jun 19, 2020 · 21 comments
Labels
bug Something isn't working

Comments

@alt-tab-macos-bot
Copy link

This issue was opened by a bot after a user submitted feedback through the in-app form.

From: [email protected]

Message:

你好,同一个Finder的所有标签页都会成为单独的窗口,这样在有时候会显得混乱,建议让Finder和Safari类似成为一个窗口,或者加一个开关,谢谢。
(我关闭了「以窗口形式显示某些标签页」依然有这个问题)

Debug profile

  • App version: 4.1.3
  • App preferences:
    • NSStatusItem Preferred Position Item-0: 571.5
    • NSWindow Frame com.sindresorhus.Preferences.FrameAutosaveName: 409 384 423 415 0 0 1280 800
    • SUAutomaticallyUpdate: 0
    • SUEnableAutomaticChecks: 0
    • SUHasLaunchedBefore: 1
    • SULastCheckTime: 2020-06-19 07:30:35 +0000
    • alignThumbnails: 0
    • fadeOutAnimation: false
    • hideSpaceNumberLabels: true
    • holdShortcut: ⌥
    • minCellsPerRow: 5
    • preferencesVersion: 4.1.3
    • quitAppShortcut: ⇧Q
    • rowsCount: 3
    • screensToShow: 0
    • showHiddenWindows: true
    • showTabsAsWindows: false
    • spacesToShow: 0
    • theme: 0
  • Applications: 71
  • Windows: 10
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 192, spaceIndex: 7}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 192, spaceIndex: 7}
    • {isFullscreen: true, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 192, spaceIndex: 7}
    • {isFullscreen: true, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 192, spaceIndex: 7}
    • {isFullscreen: true, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 192, spaceIndex: 7}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 23, spaceIndex: 3}
    • {isFullscreen: false, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 4, spaceIndex: 1}
    • {isFullscreen: true, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 12, spaceIndex: 5}
    • {isFullscreen: true, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 9, spaceIndex: 4}
    • {isFullscreen: true, isMinimized: false, isHidden: false, isTabbed: false, isOnAllSpaces: false, spaceId: 15, spaceIndex: 6}
  • OS version: 版本10.15.5(版号19F101)
  • OS architecture: x86_64
  • Locale: zh-Hans_JP (current)
  • Spaces: 7
  • Dark mode: Light
  • "Displays have separate Spaces": checked
  • Hardware model: MacBookPro12,1
  • Screens: 1
    • {x: 0.0, y: 0.0, width: 1280.0, height: 800.0}
  • CPU model: Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz
  • Memory size: 8.59 GB
  • Active CPU count: 4
  • Current CPU frequency: 2.7 Ghz
  • Resource utilization:
    • CPU: 0.2%
    • Memory: 54M+
    • Threads count: 11

@lwouis lwouis added unclear Need help from the author to provide more information to flesh out the issue unreproducible Need help from the author to reproduce the issue labels Jun 22, 2020
@lwouis
Copy link
Owner

lwouis commented Jun 22, 2020

I can't reproduce this issue locally, so I contacted the author and asked for them to film/screenshot the situation on their machine, to help me understand it better.

@lwouis lwouis changed the title [In-app feedback] Finder/Safari tabs show as separate windows Jun 22, 2020
@lwouis lwouis changed the title Finder/Safari tabs show as separate windows Finder tabs show as separate windows Jun 22, 2020
@lwouis lwouis removed unclear Need help from the author to provide more information to flesh out the issue unreproducible Need help from the author to reproduce the issue labels Jun 22, 2020
@lwouis
Copy link
Owner

lwouis commented Jun 22, 2020

The author shared more information, and I was able to reproduce. The issue happens:

  • Only with Finder
  • When the window is fullscreen
  • When each tab has been visited

While reproducing, I actually noticed another issue. It happens when opening tabs really fast like spamming command+t. Then some of the tabs appear as separate windows in AltTab. Visiting them "fixes" them (i.e. they are no longer shown as independent windows).

@lwouis lwouis added the bug Something isn't working label Jun 22, 2020
@thomassross
Copy link

I'm not sure if this is related (I can't read the original message), but when I have multiple terminal tabs and I have visited two different terminal tabs recently, those tabs show up in AltTab, even though "Show standard tabs as windows" is unchecked. I would like only the windows to show in the switcher, not the tabs, which I believe is the intended behaviour of that option. Reproduce by:

  1. Open a terminal
  2. Create a new tab (this should auto switch to the new tab)
  3. Switch back to the original tab
  4. Activate AltTab, you should see both terminal tabs in the switcher.

@lwouis
Copy link
Owner

lwouis commented Jun 30, 2020

@thomassross I can't reproduce the issue by following your steps. However, I can reproduce a similar end situation by quickly opening 2 tabs in the terminal (with 2 quick cmd+t). This is a situation I noted in my message above. I imagine the issue is that if you spawn a tab while the first is still loading, then the "finished loading" event from the first tab never triggers, and we list it as a window, not a tab.

Not sure what can be done to improve that situation. Tabs are one of the messiest part of AltTab, due to the complete lack of API from macOS. We basically listen to unrelated events, and observe side-effects of windows being tabbed, to determine if a window is a tab or not. These work arounds are brittle. Over at yabai for instance, tabs are simply officially not supported as there is no known robust way to handle them.

@koekeishiya
Copy link

koekeishiya commented Jun 30, 2020

@lwouis I assume you rely on the fact that the window creates an AXTabGroup? I had the following observation when I dug into this previously:

The accessibility API is not reliable. All it really gives us is the fact that a tabgroup has been created, and the number of tabs. However, if you go from a non-tabbed window to a window with 3 or more tabs (spamming new tab hotkey). The creation of all but the last tab will not report as part of a tabgroup, as the tabgroup have yet to be created.

@lwouis
Copy link
Owner

lwouis commented Jun 30, 2020

I assume you rely on the fact that the window creates an AXTabGroup?

Actually that's not the trick I use. I listen to kAXFocusedUIElementChangedNotification, which happens pretty much with any user interaction, including making a window a tab. Then when it triggers, I get the windows from its app, and if the window is not returned by the AX call, then it is a tab (i.e. tabs don't appear as windows of an app, whereas separate windows do).

@thomassross
Copy link

@thomassross I can't reproduce the issue by following your steps. However, I can reproduce a similar end situation by quickly opening 2 tabs in the terminal (with 2 quick cmd+t). This is a situation I noted in my message above. I imagine the issue is that if you spawn a tab while the first is still loading, then the "finished loading" event from the first tab never triggers, and we list it as a window, not a tab.

Not sure what can be done to improve that situation. Tabs are one of the messiest part of AltTab, due to the complete lack of API from macOS. We basically listen to unrelated events, and observe side-effects of windows being tabbed, to determine if a window is a tab or not. These work arounds are brittle. Over at yabai for instance, tabs are simply officially not supported as there is no known robust way to handle them.

It's strange that you can't reproduce it. The tabs show in my AltTab switcher far more often than they don't, and I'm not sure that it's related to opening tabs quickly.

I'm not too familiar with the macOS APIs, are you saying the list of windows you get includes tabs? As in you try to fetch a list of windows you can switch through and that list includes the tabs of my terminal windows, but they are listed as separate "windows"?

@lwouis
Copy link
Owner

lwouis commented Jun 30, 2020

AltTab uses the Accessibility API to query the state of the OS: apps running, their windows, events on these windows, etc.

When asking an app for its windows, you get an array of windows. This array doesn't list tabs. It lists only: independent windows, and focused tab in a tabbed-windows. Let's say you have 1 terminal window with 3 tabs. The array will only contain the focused tab, like the app had only 1 window.

The trick we use in AltTab is that we keep track of windows when they are created, so when you create the 3 tabs, AltTab is aware of all 3. Then when tab/untab them later on, we ask the app again for its window list, and we flag all missing windows as being tabbed, and all windows remaining in the list as being un-tabbed.

Here this code fails somehow, maybe because when it's too fast, some events get missed, or something. I need to investigate more on why this is happening.

@thomassross
Copy link

thomassross commented Jun 30, 2020

Maybe I'm missing something, but when "Show standard tabs as windows" is unchecked, can't the tab tracking code just be disabled and AltTab will just switch to the focused tab (i.e. the only window that the app tells AltTab about)?

@lwouis
Copy link
Owner

lwouis commented Jun 30, 2020

I think you're imagining that AltTab asks the app for windows when summoned through the shortcut. When the user presses the shortcut, we really made a huge effort to have AltTab pop as fast as possible so it feels snappy. It turns out that the Accessibility API is slow because you have to wait for the OS to answer. Thus we avoid doing check on summon. We observe the OS as events happen (like the user tabbing/untabbing windows), and note the state these windows are in. Then when summoned, we display the windows we were tracking.

Here is an example scenario:

  • User launches Terminal
  • AltTab notes that this app was launched, and observe its Accessibility API
  • Terminal opens its window
  • AltTab notes the creation of the window
  • User summons AltTab. It shows 1 terminal window
  • User opens a new tab
  • AltTab receives 2 events: new window, then focusedUiElementChanged. At this point AltTab will note that the first window is no longer listed by the Terminal app, so it flags it as tabbed.
  • User summons AltTab. It shows 1 terminal window

I hope it makes it a bit more clear why it's not that simple. We don't ask the app for its window at summon-time. That would be expensive, for all the apps, for all the windows. Instead we establish what's tabbed/untabbed continuously.

@thomassross
Copy link

thomassross commented Jun 30, 2020

That makes sense. Thanks for the explanation.

@lwouis
Copy link
Owner

lwouis commented Jul 8, 2020

I think I have fixed tab detection. With the fix, it seems to handle correctly these scenarios:

  • The bug that the OP was experiencing (Finder fullscreen'ed)
  • The bug I found (opening tabs very quickly)
  • No regression on a previous bug (windows that are created immediately fullscreen)
  • Adding tabs to a window > fullscreening that window > adding/removing tabs > un-fullscreening the window

I have tested all these scenarios with the preference "Show standard tabs as separate windows" turned on and off. Everything looks good to me.

This ticket will be closed automatically once the fix is merged and a new version is released. Please let me know if you still see tabs issues! (@thomassross)

lwouis pushed a commit that referenced this issue Jul 8, 2020
## [4.1.6](v4.1.5...v4.1.6) (2020-07-08)

### Bug Fixes

* potential crash in very rare data-race scenario ([4ff5d89](4ff5d89))
* tabs would sometimes show as separate windows (closes [#383](#383)) ([c03d48f](c03d48f))
* update korean localization ([ecdeed8](ecdeed8))
@mparry
Copy link

mparry commented Jul 10, 2020

Unfortunately, I think that this change has actually broken #335 again - neither Remote Desktop nor Citrix windows are showing for me if they start fullscreen, now that I'm running 4.1.6.

@lwouis
Copy link
Owner

lwouis commented Jul 10, 2020

@mparry that's unfortunate. I think you meant #335 not #383, right? I'm surprised as I retested it with MRD. It was working great. What are you symptoms exactly? Could you possibly share a quick Loom?

@mparry
Copy link

mparry commented Jul 10, 2020

I did mean that, yes; I've edited my previous comment.

It seems to be behaving much as it did before you fixed #335, TBH. If it starts fullscreen then there is no sign of the Remote Desktop session window in AT. If I take it out of FS and back in, now it shows up.

Unfortunately, I would be unable to capture video (or probably upload it anywhere even if I did).

@thomassross
Copy link

The good news is that so far (from my somewhat limited testing), tabs are working correctly! I'll write another comment here if it starts being broken again.

@thomassross
Copy link

Bad news: I'm still seeing the issue. Seems to just appear after running Terminal.app with a few tabs open and switching between tabs/apps for a few hours. I don't really have very strong reproduction instructions unfortunately.

@lwouis
Copy link
Owner

lwouis commented Jul 14, 2020

@thomassross is your terminal fullscreen? How many tabs do you have? How did you create the tabs? Did you split them into windows then back into tabs? I just tried a lot again, and no matter the trickiness of my scenarios, it's always working great

@thomassross
Copy link

thomassross commented Jul 14, 2020

@thomassross is your terminal fullscreen? How many tabs do you have? How did you create the tabs? Did you split them into windows then back into tabs? I just tried a lot again, and no matter the trickiness of my scenarios, it's always working great

My terminal is not fullscreen. I usually have around 5-10 tabs. I create them using Command-T, just whenever I need them, and I open and close different ones (with Command-W) fairly often. I do not split into windows and back. I'll also try to come up with a way to consistently reproduce and report back here.

@lwouis
Copy link
Owner

lwouis commented Jul 14, 2020

Actually, as soon as you have a clearer picture on which scenario is not working, please open a new ticket. It will make the scope of the issue clearer as this current one was about fullscreen windows with tabs

@pablorsk
Copy link

I have the same problem with Terminal (zsh).

Has anyone opened a new issue? Maybe #2017 is related, but is not the same bug reported here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants