Turning off Native Window Occlusion by default for embedded Chromium.

780 views
Skip to first unread message

David Bienvenu

unread,
Aug 12, 2022, 5:47:25 PM8/12/22
to Chromium Embedders

On Windows, Chrome figures out if Chrome windows are completely covered by other windows (including non-Chrome windows), and if the window is completely covered, it stops rendering the foreground tab. Calculating occlusion can be somewhat expensive, but the savings for Chrome are substantial, as described in this blog post.However, for other Chromium-based applications, the cost probably outweighs the benefits. Chromium tracks WinEvents to know when it should recalculate occlusion, and in some situations, this can cause contention on a Windows lock. The more apps that use WinEvents, the worse the bottleneck can be.


My proposal is to move this code that turns on native window occlusion by default from window_tree_host.cc to browser_desktop_window_tree_host_win.cc. For Electron apps and other non-browser embedded users of Chromium,, this should turn off native window occlusion by default, since Electron doesn’t use browser_desktop_window_tree_host_win.cc. 


Embedders can also turn off occlusion by turning off the calculate-native-win-occlusion flag, but I would like the default behavior to reflect the fact that calculating occlusion is worthwhile for full-blown browsers, and probably not worthwhile for less resource-intensive applications. Apps can always override the default and turn on occlusion by sub-classing WindowTreeHost, like Chrome and Electron do.


Please let me know if you have any questions or concerns.


- David


Reply all
Reply to author
Forward
0 new messages