关于 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 或者是电脑中的其他任何设置、进程、窗口产生的影响,所以目前只能用上面提到的方式解决,也期待官方能够修复这个问题。

2022-01-28 补充:

新版 Chrome 竟然直接隐藏了 Calculate window occlusion on Windows 这个选项(我的是 Chrome 97)!问题都还没解决呢?!补充一下临时的几种解决方案:

  • 在快捷方式目标后加一个参数 --disable-features=CalculateNativeWinOcclusion
    例:"C:\Program Files\Google\Chrome\Application\chrome.exe" --disable-features=CalculateNativeWinOcclusion

  • (未验证)在快捷方式目标后加一个参数 --disable-backgrounding-occluded-windows

  • Temporarily unexpire M96 flags 改成 Enabled 然后 Calculate window occlusion on Windows 就會出來了(注意在我 Chrome 99.0.4844.74 版本已经没有 M96 的选项,所以该方法在较新版本的 Chrome 已经失效,请留意你的浏览器版本),如下图:

  • 修改注册表,在 HKEY_LOCAL_MACHINEHKEY_CURRENT_USER 下面的 Software\Policies\Google\Chrome 中新建 DWORD 值并设置为 0。需要注意的是,如果你在 HKEY_LOCAL_MACHINE 当中修改会导致 Chrome 当中出现 由贵单位管理 字样,你将无法修改部分设置,而在 HKEY_CURRENT_USER 下面新建之后不会出现这个情况,但因为没有明确提示且验证较为复杂所以我无法确保后者是否有效。

  • 更换浏览器。

参考链接: