Vscode: Limited native window tabs functionality in macOS high sierra

Created on 29 Sep 2017  Β·  99Comments  Β·  Source: microsoft/vscode

  • VSCode Version: Code - Insiders 1.17.0-insider (f7962f0682a76516df51de4856f8ccc5d8ad578a, 2017-09-20T05:10:59.524Z)
  • OS Version: Darwin x64 17.0.0
  • Extensions: (unimportant, see below)

Steps to Reproduce:

  1. Try to use "window.nativeTabs": true option, notice the squiggles and message says _Unknown configuration setting_
  2. If you remove the setting, opening a new window does create a new window
  3. If you put the setting back, it is respected, but creating a new window creates (visually) empty native tab bar (previously it showed two tabs, as expected); clicking on the tab creates a new window, as if the whole tab bar is in fact the newly added (looking at 1.17 release notes) "+" button to add a new window/tab
  4. Switching windows works, my custom shortcuts are respected etc. all is well, except tabs display

One more thing πŸ˜‰ bizarrely my insider hasn't been updates since 20th of September (never seen insider go for 10 days without update). Downloading insider from Code's site also yields 20th of Sep version.

Reproduces without extensions: YES (as expected)

bug mac upstream verified workbench-os-integration

Most helpful comment

Sorry, I'll post a screenshot now, it might be clearer (or not, you'll see):
screen shot 2017-09-29 at 10 25 35

The whole "tab" area behaves like a "+" button in your screenshot.

All 99 comments

@ddotlic but you are seeing the native tab bar to the top of the window?

image

Sorry, I'll post a screenshot now, it might be clearer (or not, you'll see):
screen shot 2017-09-29 at 10 25 35

The whole "tab" area behaves like a "+" button in your screenshot.

Needless to say, this worked fine yesterday (before I installed High Sierra update), this is a MacBook Pro 2015, always up to date so I expect no issues with drivers etc.

If I can do something else to help (provide more info by running with particular command line switches) please do not hesitate to ask.

Unfortunately this looks like an issue in Elecron, I filed: https://github.com/electron/electron/issues/10657

For now the functionality seems limited at best. I think all that is going wrong is the rendering of native tabs, but otherwise the tabs are there.

Thanks for the info. We'll likely either see more people confirming the same when 1.17 comes out, or not πŸ˜„ in which case it'll be some fluke on my machine that I'll need to figure out somehow.

@bpasero Do you have any idea if it's normal for insider to not be updated for the last 10 days??

@ddotlic yes, our signing service currently is not active.

Having this issue with VS Code v 1.16.1 and Mac OS High Sierra.

"window.nativeTabs" option is not available in settings anymore.
View > Show Tab Bar: Shows the tab bar but Cmd + Shift + N does not open new window in new tab.

I confirm I have the exact same issue with VSCode 1.17.0. It was working with the previous version on High Sierra (even if the window.nativeTabs was not officially supported)

Just upgraded to v1.17.0 on High Sierra and I too experience this problem when "window.nativeTabs": true is enabled. Got a massive + new tab button (with no label on it) and not seeing any tabs until I go to "Show All Tabs"

I sent a fix here https://github.com/electron/electron/pull/10696#pullrequestreview-67556591

You can work around the issue by building Electron from my PR, then replace it from the VSCode.app/Contents/MacOS. A bit complicated, but I can't live without native tabs support :)

Same issue here

I have the same issue

Everyone: the proposed fix is "flaky" in the sense that it depends on which macOS version Electron/VS Code is built on, not what it runs on. It's a compile time thing, not a runtime thing. As long as VS Code is _not built_ on High Sierra, this fix will do nothing.

Please don't spam this item with useless comments like "me too" - there's a reaction you can use for that. Let's leave this item for pertinent comments regarding the inclusion of an eventual fix.

This should be a lesson to us all to not upgrade to a new OS as soon as possible πŸ˜‰

Maybe the VSCode team could adjust their build process to fix this?

Also having the "massive '+' tab with no label" issue & want to follow this thread

Any update on this issue? I just update to High Sierra and VS Code 1.18 and still having the missing native tabs :(

We are waiting for a real fix from Electron. Forcing a change of build machines to build on high sierra is not a fix of this issue.

It's not a terrible stopgap though, which would give time for Electron to fix the issue on their side before the next MacOS release.

It doesn't seem like a lot to ask to use the latest macOS for macOS software development.

Same issue here.

@PSalant726 be nice and patient. You are more then welcome to submit a PR here. As far as I know this is still open source project and you spend zilch to use this editor. There are alternative editors you can use.

Hey guys, just be patient :D This is not the end of the world!

since the electron bug hasn't been fixed so far, is there any workaround we can do in vscode?

@phoenixgao, This is my workaround:

  1. Add "window.nativeTabs": true to your settings
  2. Restart the vscode
  3. Open multiple windows
  4. Use Window > Merge All Windows (workbench.action.mergeAllWindowTabs command) to merge all windows into one
  5. Use either one of the followings to switch between windows:

    • native way: View > Show All Tabs or Cmd+Shift+\

    • vscode menu: Window > Switch Window... or Ctrl+w (workbench.action.switchWindow command)

The only problem with this is that it always shows a blank bar on top of the window

@primalmotion Hi,I cloned electron repo, but I can't build this project success. But I really need this function. Can you provide an available electron?

+1

Hi,
Just follow this manual and you should be able to build it.

https://electronjs.org/docs/development/build-instructions-osx

@bpasero Any _official_ updates on this?

I followed the manual and took me 6 hours but still not finish downloading the vendor files, I might have a poor network but it requires several gigabytes chromium runtime or so... anyway I gave up and installed Vscode Insider, and put multiple projects under one workspace if that could be considered as a workaround.

Ok, I built the Electron from the source (6 hours), what do I do with it now? How do I add the VSCode functionality to it? Thanks!

Any update?

I have a version of Electron built from the source from master which I can share. But it would be great if someone could come up with some instructions of what to do with it. I have replaced the Electron.framework from inside the package and that just crashed the whole thing.

It's a bug of Electron, so guys you could follow https://github.com/electron/electron/issues/10657

It's a bit hard to build electron from source unless you have built it before, at least I didn't make it -- it need download several gigabytes dependencies.

Someone shared a build you could try:
https://github.com/electron/electron/pull/10696#issuecomment-360061076
But like he said, you need to trust him.

@phoenixgao The file is deleted already.

@phoenixgao what to do next when the electron was built? replace some files under the vscode dir?

@silentred yes, check readme file here
https://github.com/phoenixgao/electron-high-sierra-build

I build the app using yarn.
In the root of the cloned vscode project, choose a branche or tag and then:
yarn run gulp vscode-darwin

A complete standalone app is build. When finished building, you can find it here:../VSCode-darwin/Code - OSS.app (check the size, it should be about 200MB)
From there, you can move it to /Applications.

I did alter the project.json, because the default does not include the config for the extensions repository.

@phoenixgao you are a freaking lifesaver !!! ❀️Works like a charm in High Sierra. I hope we can trust YOU!

Took 10 seconds to do the whole thing ;)

@phoenixgao It's... beautiful!
You build from https://github.com/phoenixgao/electron-high-sierra-build worked perfectly and now native tabs work again!

@phoenixgao It's working now! Thanks! 😍

@phoenixgao working for me too! Thanks a lot! πŸ’˜

Works for me too.

As the README says, all vscode automatic updating will be disabled if you use the downloaded Electron (the menu items don't even show).

I've tested with moving the original Electron back into place and the auto updates are restored, and they work.

Thanks @phoenixgao , I thought I'd be able to wait for a proper fix - but having my workspaces in separate windows was driving me nuts.

What a nice surprise I had today, after completing the High Sierra upgrade. Looking forward to have an Electron fix as part of the official VSCode release. πŸ€’

Still the same issue and even the march release of VS code doesn't have this fix.

I did some more digging into this and found out that a simple change to the CFBundleIdentifier (in /Applications/Visual Studio Code - Insiders.app/Contents/Info.plist) from com.microsoft.VSCodeInsiders to com.microsoft2.VSCodeInsiders makes native tabs show up properly for me.

I cannot explain this behaviour though and feel uneasy about making such a change as a fix. If someone has friends over at Apple that could explain this behaviour, I am happy for some help.

It is true that we are building Electron against the macOS SDK 10.10 which may have an impact on this issue.

I confirm, update from sierra to high sierra breaks merge all windows feature.

This is not a real solution to this problem but I want to mentioned it anyways:

Due to this bug I changed my workflow in Visual Code to use multi-root workspaces.

They can be very helpful when you are working on several related projects at one time. For example, I have created a workspace for all of my private projects.

Using workspaces I do not have to handle multiple VS Code editor windows but always work with one window which includes my current workspace.

I think everything which is not com.microsoft.VSCode will work fine.

confirmed, it works.. sweet!

sed -i -- 's/com.microsoft.VSCode/com.microsoft2.VSCode/g' /Applications/Visual\ Studio\ Code.app/Contents/Info.plist

awesome! Could this be due to this https://worthdoingbadly.com/appkitcompat/

VScode is not in the list, but who knows?

Same as @johnelm but for Insiders:

sed -i -- 's/com.microsoft.VSCode/com.microsoft2.VSCode/g' /Applications/Visual\ Studio\ Code\ -\ Insiders.app/Contents/Info.plist

@primalmotion True. This may be related to one of this "check fixes" in AppKit binary:

image

@primalmotion

awesome! Could this be due to this https://worthdoingbadly.com/appkitcompat/

Interesting theory, but I can reproduce this with a different identifier (com.microsoft.VSCodeExploration) from a custom build we are using for testing Electron 2.0.x and I doubt that one would have made it into that list so quickly.

@pi0 can you explain what I am looking at in https://github.com/Microsoft/vscode/issues/35361#issuecomment-395535757 ?

Interesting theory, but I can reproduce this with a different identifier

@bpasero Speculation on my part, but there might be a _startsWith_ thing going on here, as long as the identifier is com.microsoft.whatever the fixes kick in? Either way, I've learned something interesting (Apple doing these kinds of fixes) πŸ˜„

Yeah. I am sure they have some if microsoft. How could we blame them when you see office on mac ;) but now it leaks on a good product

@ddotlic @primalmotion good point, I guess we somehow need to validate that theory

Confirmed; I've gone for m1cr0s0ft, and tabs work beautifully πŸš€

@bpasero I guess we could confirm by creating a new electron project with tabs and set the bundle identifier to com.microsoft.whatever and see if the tabs are misbehaving.

@primalmotion yes I can confirm that by just setting CFBundleIdentifier to com.microsoft.

Result:

image

I guess the next questions are:

  • how risky would it be to change the CFBundleIdentifier to something else and shipping that, what is the potential impact of doing that for the OS integration of VS Code
  • can we reach out to Apple to remove this behaviour (that would probably need an OS update)

I also think that Apple might have done this for another application that is not necessarily VS Code because it goes bad as soon as the bundle identifier is com.microsoft.

@zhuowei as author of https://worthdoingbadly.com/appkitcompat/, I hope you don't mind my question: did you see com.microsoft.VSCode in the list of bundle identifiers? When I look at https://worthdoingbadly.com/assets/blog/appkitcompat/appkit_processed.html I see some Microsoft applications, but not VS Code. I wonder if that list is complete?

@bpasero I didn't see it, but you could try loading AppKit in IDA and checking the _NSDisableAutomaticWindowTabbingDefaultValueFunction yourself.

Edit: I went through the function and it didn't mention VS Code. Also, that function is only ever used by [NSWindow allowsAutomaticWindowTabbing] to calculate the default value; I actually attached to the Electron process in Xcode and ran print [NSWindow allowsAutomaticWindowTabbing] in the debugger, which returned true. So it's not doing a bundle ID check in AppKit.

I didn't see Chrome in the list either, but Chrome is known to be on the blacklist, so there must be some other check I can't find.

@zhuowei thanks for looking into that. maybe this is actually not related to allowsAutomaticWindowTabbing but something else, because even though visually it does not look like native tabs are working, you can create multiple windows and open them in one tabbed window and switch between them. there is "just" this visual glitch where the tab bar is not displayed properly (as shown in https://github.com/Microsoft/vscode/issues/35361#issuecomment-395970658)

This bug is extremely frustrating and has negatively impacted my productivity in several ways; and I wasted literally at least 1hr to 1.5hrs trying to figure out why my window tabs just disappeared πŸ˜•. Until this is fixed, may I suggest adding a note re this bug to the window.nativeTabs setting documentation in __Visual Studio Code__ (at least for __High Sierra__ users)? Any fixes in the works for this that I can subscribe to?

Thank you for the hard work.

- Jonathan

@jonathanmarvens read the thread, there is one liner that you need to execute to make it work. As simple as that.

edit.. The sed command works.

@bpasero I found the compatibility fix that's breaking the tabs!

I used a DYLD_INSERT_LIBRARIES library to swizzle -[NSBundle bundleIdentifier] to only return a non Microsoft bundle ID for some methods. Using this I was able to isolate the method that breaks tabs: NSUseImprovedLayoutPassDefaultValueFunction.

It indeed checks for a Microsoft bundle ID:

__text:00000000008E776D _NSUseImprovedLayoutPassDefaultValueFunction proc near
__text:00000000008E776D                                         ; DATA XREF: _NSUseImprovedLayoutPass+23↑o
__text:00000000008E776D                                         ; _NSInvalidateSelfLayoutOnFrameChangesDefaultValueFunction+23↓o ...
__text:00000000008E776D                 push    rbp
__text:00000000008E776E                 mov     rbp, rsp
__text:00000000008E7771                 push    rbx
__text:00000000008E7772                 push    rax
__text:00000000008E7773                 lea     rdi, cfstr_ComOvermacsPho ; "com.overmacs.photosweeper"
__text:00000000008E777A                 movsd   xmm0, cs:qword_C170E0
__text:00000000008E7782                 mov     esi, 0Ch
__text:00000000008E7787                 call    __CFAppVersionCheckLessThan
__text:00000000008E778C                 test    al, al
__text:00000000008E778E                 jnz     loc_8E781B
__text:00000000008E7794                 mov     rdi, cs:classRef_NSBundle ; void *
__text:00000000008E779B                 mov     rsi, cs:selRef_mainBundle ; char *
__text:00000000008E77A2                 mov     rbx, cs:_objc_msgSend_ptr
__text:00000000008E77A9                 call    rbx ; _objc_msgSend
__text:00000000008E77AB                 mov     rsi, cs:selRef_bundleIdentifier ; char *
__text:00000000008E77B2                 mov     rdi, rax        ; void *
__text:00000000008E77B5                 call    rbx ; _objc_msgSend
__text:00000000008E77B7                 mov     rsi, cs:selRef_hasPrefix_ ; char *
__text:00000000008E77BE                 lea     rdx, cfstr_ComMicrosoft_0 ; "com.microsoft."
__text:00000000008E77C5                 mov     rdi, rax        ; void *
__text:00000000008E77C8                 call    rbx ; _objc_msgSend
__text:00000000008E77CA                 test    al, al
__text:00000000008E77CC                 jz      short loc_8E77E1
__text:00000000008E77CE                 cmp     cs:_NSViewLinkedOnFuji_onceToken, 0FFFFFFFFFFFFFFFFh
__text:00000000008E77D6                 jnz     short loc_8E7847

Indeed, launching VSCode with this compatibility fix's NSUserDefaults value overridden on the command line:

/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron -- -NSUseImprovedLayoutPass true

Fixes the tabs without changing the bundle ID.

I think this can be worked around with a NSUserDefaults override: in Electron it'll be something like systemPreferences.registerDefaults({NSUseImprovedLayoutPass: true}) at startup.

@zhuowei Yes, this is wonderful news! Thank you for your work πŸ™‚.

@zhuowei I really appreciate you taking the time to investigate this ❀️, but can you (or anyone here) give me some pointers what the impact of NSUseImprovedLayoutPass: true is besides fixing this issue? I am a little bit worried that it could have other consequences that would be hard to understand without knowing and I am not able to find any documentation around this.

@bpasero I'm not sure what the flag does: it's referred to by a bunch of other config variables, and it'll take too long to check what they all do:

cropped1
cropped2

It might be a good idea to file a Radar with Apple to ask about why this "com.microsoft." check exists and whether it's possible to remove VS Code from the check in future macOS versions.

At any rate, Code-OSS has always worked fine, and its bundle ID doesn't trigger the patch, so I doubt changing it would cause any issues.

At any rate, Code-OSS has always worked fine, and its bundle ID doesn't trigger the patch, so I doubt changing it would cause any issues.

@zhuowei First, thanks for looking into this, I'm sure everyone will agree that without your contribution, this item would have lingered quite a bit longer (not for the lack of trying)!

@bpasero I hope I speak for everyone using the insiders release: while we aren't expecting any breakage, we are aware that it's possible. Why don't you simply enable this flag right after the next release (due in a few days) and let us all verify that nothing is broken? (OTOH if you could turns this on _only_ for insiders, then turning it on right now is fine too). The nature of the "fix" is such that I really don't see any smarter way of testing this explicitly.

@zhuowei yeah I was just wondering if NSUseImprovedLayoutPass: true makes the application behave exactly like the OSS one that has a different bundle identifier or if there is more to it, but I guess we will have to just try it out.

@ddotlic we could always go for a change where NSUseImprovedLayoutPass: true is only set if the setting to use native tabs on macOS is also enabled. This means there is only a limited amount of people that would hit issues if there are any.

The fix will be in tomorrows insider build and should land in the June stable release (out next week) unless we find some critical issue with it.

I also reported this to Apple, let's see what happens there.

I spoke too soon, it looks like systemPreferences.registerDefaults() is a method that is not available in Electron 1.7.x (the version we are using). I can add this change to the Electron 2.0.x branch, but we are still at least 1-2 months away from shipping that given all the issues we are seeing with that version.

Ah maybe it was just a method rename?

@nesl247 @bpasero setUserDefault writes a value permanently to the user preferences; registerDefaults writes it temporarily.

https://stackoverflow.com/questions/4931167/what-is-the-use-of-nsuserdefaults-registerdefaults

@zhuowei that would still be OK though right because the value would only be valid for the bundle identifier, not for all applications?

Let's try how it goes with systemPreferences.setUserDefault(), I pushed this for todays insider build.

@bpasero Yeah, it will only affect our application. Anyways, my concern was that setUserDefault is persisted, so if a user turns on native tabs, the preference is set, and after the user disables native tabs, the preference is still set. registerDefaults is in memory only, so that may be a better choice. This should work though.

@zhuowei that is a good point, however I would at one point maybe even turn this on for everyone once we have a better understanding what the impact is

@bpasero The fix works like a charm for me (latest insider from couple hours ago, latest possible macOS).

Thanks for not giving up on this!

Trying to verify this (as per our end-of-milestone ritual), but don't see a difference between the default and native tabs enabled.

With native tabs enabled:
image

@chrmarti I'm not sure but it seems like you're looking at document tabs? These don't change either way.

The tabs this relates to are the ones for the workspace, you need to have multiple workspaces open to be able to see them.

@chrmarti Open a new window. The native tabs aren't for file tabs, they are for window/workspace tabs. If working correctly, when you open a new window, you should see 2 window tabs. If not working correctly (as it has been for months now), you will just see a blank gray bar at the top.

If you've used tabs in Finder, it's the same idea.

@bpasero when is the insider build will make it to stable release?

Thanks! Still no tabs though, I get additional windows. I'm on:

  • VS Code version: Code - Insiders 1.25.0-insider (07d89abf1522a67f0e8105770505077f454ab021, 2018-06-28T05:11:09.274Z)
  • OS version: Darwin x64 17.6.0

@chrmarti Make sure that "window.nativeTabs" is set to true in your user settings.

With that set to true, you shouldn't get multiple windows even if the native tabs fix wasn't present.

@chrmarti You are holding it wrong πŸ˜‰ You cannot verify whether this works or not unless you have triggered the appearance of tabs per workspace. This is another row of tabs above the document tabs.

Got some help from @bpasero. Everything works now, thanks! Marking verified.

@chrmarti when do we have this fix pushed into stable release?

@fmunteanu With 1.25 some time next week.

for me it didn't work at first but after disabling nativeTabs and reenabling them through the new settings editor worked.

I can confirm it is working like a charm now :)

MacOS: 10.13.4
VSCode: 1.25.0-insider

image

Wait, so the native tabs are replacing the _file_ tabs? I was under the impression that native tabs are (finally) a way to properly switch between multiple project windows, and that we have the file tabs rendered in VS Code below those for each project. So with native tabs we're also losing the grid layout editor functionality?

@deyhle They are not replacing the file tabs, see my screenshots below :

screen shot 2018-07-06 at 10 04 43

It's behaving exactly as you'd have them to. I could have show you the grid layout functionality too, it's just that I didn't in my screenshot. But I can confirm it's also working. ;)

@chrmarti I don't see the feature listed in 1.25 (stable just released), can you please confirm it is implemented? Thanks!

@fmunteanu As it's not a new feature (but rather a fix to an existing feature that broke in High Sierra), you'll find it under the "Notable Changes" and "Thank You" sections of the release notes.

I can confirm that it is implemented and working in stable. πŸŽ‰

release_notes__1_25_0_and_limited_native_window_tabs_functionality_in_macos_high_sierra_ _issue__35361_ _microsoft_vscode

release_notes__1_25_0_ _confluence-open-api-connect

I had changed plist setting to com.microsoft2.vscode earlier as a fix. 1.25
reverted that change and broke tabs for me again.

On Fri, Jul 6, 2018, 5:11 PM scottohara notifications@github.com wrote:

@fmunteanu https://github.com/fmunteanu As it's not a new feature (but
rather a fix to an existing feature that broke in High Sierra), you'll find
it under the "Notable Changes" and "Thank You" sections of the release
notes.

I can confirm that it is implemented and working in stable. πŸŽ‰

[image:
release_notes__1_25_0_and_limited_native_window_tabs_functionality_in_macos_high_sierra_
issue__35361 _microsoft_vscode]
https://user-images.githubusercontent.com/289327/42404574-960ad42e-81cd-11e8-96c0-58fad7a3a085.jpg

[image: release_notes__1_25_0_ _confluence-open-api-connect]
https://user-images.githubusercontent.com/289327/42404543-56084ed8-81cd-11e8-99d7-1a84b5399b46.jpg

β€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode/issues/35361#issuecomment-403174283,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGWU73-wPqnzkUivaH_opeq_I-hJLh4Wks5uD_yvgaJpZM4PoUgw
.

Disable then re-enable the native tabs feature and it will work. Confirmed fixed on my end.

On Jul 6, 2018 19:19, RoarkeRandall notifications@github.com wrote:

I had changed plist setting to com.microsoft2.vscode earlier as a fix. 1.25
reverted that change and broke tabs for me again.

On Fri, Jul 6, 2018, 5:11 PM scottohara notifications@github.com wrote:

@fmunteanu https://github.com/fmunteanu As it's not a new feature (but
rather a fix to an existing feature that broke in High Sierra), you'll find
it under the "Notable Changes" and "Thank You" sections of the release
notes.

I can confirm that it is implemented and working in stable. πŸŽ‰

[image:
release_notes__1_25_0_and_limited_native_window_tabs_functionality_in_macos_high_sierra_
issue__35361 _microsoft_vscode]
https://user-images.githubusercontent.com/289327/42404574-960ad42e-81cd-11e8-96c0-58fad7a3a085.jpg

[image: release_notes__1_25_0_ _confluence-open-api-connect]
https://user-images.githubusercontent.com/289327/42404543-56084ed8-81cd-11e8-99d7-1a84b5399b46.jpg

β€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/Microsoft/vscode/issues/35361#issuecomment-403174283,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGWU73-wPqnzkUivaH_opeq_I-hJLh4Wks5uD_yvgaJpZM4PoUgw
.

β€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

philipgiuliani picture philipgiuliani  Β·  3Comments

shanalikhan picture shanalikhan  Β·  3Comments

NikosEfthias picture NikosEfthias  Β·  3Comments

ryan-wong picture ryan-wong  Β·  3Comments

omidgolparvar picture omidgolparvar  Β·  3Comments