关于 Alt+Tab 切换窗口时 Chrome 卡住/假死的问题

在开发过程中,经常会遇到使用 Alt+Tab 键从编辑器切换到 Chrome 时窗口卡住无法进行任何操作的情况,需要点击窗口外的地方(例如系统任务栏)之后页面才恢复正常。

我用的开发工具是 VS Code,卡住时的具体表现为:整个 Chrome 窗口点击没有任何响应,包括浏览器按钮、网页的任何鼠标移动、点击。

经过搜索,目前我在谷歌官方的帮助中心找到一个关于这个问题的讨论:Tabs in Chrome 86 on Windows 10 freeze after Alt-Tab to another virtual desktop and back

问题内容如下:

Since the last update I have the following, easily reproducible problem in Chrome: I use multiple virtual desktops, a standard Windows 10 feature. The configuration is such that by Alt-Tab I can also switch to applications located on another virtual desktop. The other application can be anything in my case, such as Windows Explorer or my IDE, it does not make a difference.

Whenever I switch to another desktop via Alt-Tab and do something there, then switch back to Chrome, the current Tab is frozen, I cannot open any menus and when I click on other tabs they are blank. As soon as I click on the application icon on the task bar in order to minimise and again to restore the browser window, everything looks and behaves normal again. As soon as I switch to an app on another virtual desktop via Alt-Tab again, the browser freezes again etc. If I move the browser window to the same tab as the app I switch to, the problem disappears.

If this is relevant, I have activated the Chrome feature for grouping tabs. But I do not think this is the root cause of the problem because when I try the same in a new Chrome user profile without any special settings and without any browser add-ons, the problem also occurs.

I reported this problem twice before via the built-in feedback feature, but received no response by Google, even though this is a severe bug.

另外还有个类似问题:Chrome freezes while using two virtual desktops

目前唯一的解决方法是在 chrome://flags 设置 Calculate window occlusion on WindowsDisabled 状态。

完整答案如下:

@Dino Bytes There seems to be an issue as of late where after Alt+Tabbing out of Chrome to another full-size window and tabbing back, the tabs would freeze until you manually switch tabs. The solution for that is to go to chrome://flags and disable “Calculate window occlusion on Windows” and restart Chrome with the button that appears on the bottom of your screen after applying the new setting.

个人认为这应该算是一个 BUG,所以通过上述方法并不是一个理想的办法,但排查这个问题的难度在于需要确认到具体问题涉及的范围太广,可能是 Chromium、VS Code 或者是电脑中的其他任何设置、进程、窗口产生的影响,所以目前只能用上面提到的方式解决,也期待官方能够修复这个问题。