Microsoft’s switch to Chromium has benefited Chrome more than anything else. Google Chrome now has better scrolling, improved font management, and even better battery performance on Windows 11, all thanks to Microsoft. Now, Microsoft is making the dark mode work better with Desktop Windows Manager (DWM.exe).
At the moment, if you use Chrome in dark mode (either when Windows 11 or Windows 10 are set to use a dark theme) and open a new window in Chrome, you might notice a white flash that appears before loading a new window. The temporary white screen shouldn’t appear, but it does because neither Chrome nor Windows knows what to do.
You’ll also notice the white flash when you launch Chrome and Edge on Windows 11 or Windows 10 when the OS is set to follow the dark theme.
In the past, Google and Microsoft have worked on improving the dark theme integration in Chrome and Windows, but one place where the integration doesn’t just work yet is the opening of browser windows. This is similar to an issue with File Explorer, where Explorer will flash bang with a white screen before loading.
The File Explorer issue has been fixed for everyone in Windows 11 23H2, and Microsoft is now patching the same bug in Chrome.
As browser researcher Leo noticed on X, Microsoft has patched an issue in Chromium to avoid white flash on window creation in dark mode.
How Microsoft is fixing Chromium dark mode “white flash” issue
Based on the Chromium code commit reviewed by Windows Latest, it looks like Windows doesn’t know how to handle a newly created window by Chrome. When you create a new window, Windows 11 turns it white, and it remains white until Google Chrome or Microsoft Edes takes over.
In other words, when Windows 11 is in dark mode, and you switch or create a window in Chrome or Edge, Windows needs to handle that window load phase until the app (Chrome/Edge in this case) starts its own rendering. Unfortunately, Windows is unable to respect the dark mode when it is handling window management.
Microsoft’s developer Chris Davis, who works with the web team, proposed a solution to cloak the window to hide until a dark background can be shown by Chrome/Edge. This sounds more like a workaround than a proper fix for Windows 11’s Desktop Window Manager (DWM.exe), but it seems to be the best bet for now.
As noted by Chris Davis, “When a window is first created, DWM will use a default white background colour for the window. This can cause a white flash when first showing the window in dark mode. To avoid this, we cloak the window before showing it for the first time and force a paint of the intended background colour before uncloaking.”
Windows Latest took a closer look at the Chromium commits, and we noticed that it modifies ui/views/win/hwnd_message_handler.cc.
Microsoft dev is modifying DWMWA_CLOAK to TRUE to tell Windows to cloak the newly created window (basically hide it). While cloaked, the code uses GDI calls to fill the client area with a dark colour.
Once it is dark, Microsoft sets DWMWA_CLOAK to FALSE, which makes the window visible again, and by that time, you’ll see a dark colour, not a white flash.
Some Chromium contributors are not sure if this is a good idea because there could be a race condition where a GPU process finishes drawing the page contents right when the window is being updated to use a dark background. In such a case, Chrome might overwrite the original screen content with dark colours.
In Microsoft’s tests, they didn’t see this happening, so it’s likely Chrome won’t run into such issues once the patch is rolled out.
Meanwhile, in future, Google and Microsoft could change how Chromium handles top-level windows. For example, they can use WS_EX_NOREDIRECTIONBITMAP or newer Windows APIs like DWM_SYSTEMBACKDROP_TYPE), which could bypass the white flash.
But for now, Dave’s cloaking approach is getting implemented, and it means you’ll not see the flash-bang anymore on Windows 11 (and Windows 10).
These changes will begin rolling out to Chrome and Edge soon.
The post Microsoft finally fixing Chrome & Edge’s white flash in dark mode on Windows 11 & Windows 10 appeared first on Windows Latest
Source: Read MoreÂ