Thanks to Microsoft’s shift to Chromium, users can now enjoy enhanced functionalities within both Google Chrome and Microsoft Edge. The integration has led to significant enhancements including smoother scrolling, optimized font handling, and better battery efficiency specifically for Windows 11. Now, Microsoft is turning its attention to improving dark mode capabilities alongside the Desktop Window Manager (DWM.exe).
However, a common issue persists: when utilizing Chrome in dark mode on Windows 10 or Windows 11, users often encounter a brief white flash while opening a new window. This undesired occurrence highlights a problem where neither the browser nor the operating system knows how to manage the initial rendering correctly, leading to an unsightly interim screen.
This is likewise noticeable when starting up Chrome and Edge under the dark theme settings of the operating system. While both Google and Microsoft have previously addressed aspects of dark theme integration, the challenge remains particularly evident during the transition between browser windows. Similar flash issues were previously noted within Windows File Explorer, but these have been resolved in the Windows 11 23H2 update.
Addressing the White Flash in Chromium Dark Mode
Based on a recent Chromium code commit analyzed by Windows Latest, it appears the issue stems from Windows lacking the necessary handling for freshly created Chrome windows. When launching a new window, Windows 11 defaults to a white backdrop, remaining visible until Chrome or Edge asserts control.
In this context, when Windows 11 operates in dark mode, the management of new window displays poses a problem, with Windows initially handling the load phase until the respective applications establish their rendering. Regrettably, at this stage, Windows does not acknowledge the dark theme management effectively.
Chris Davis, a Microsoft developer, has introduced a workaround to mitigate the white flash by implementing a cloaking technique. This involves concealing the window until an appropriate dark background can be rendered by Chrome or Edge. While this is more of a patch than a definitive solution to the DWM.exe’s issue, it appears to be the most feasible resolution currently available.
As Chris Davis explains, “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.”
Further examination into the Chromium commits indicates modifications to ui/views/win/hwnd_message_handler.cc
.
In the cloaked state, code employs GDI calls to fill the client area with a dark color. Upon achieving the desired dark hue, Microsoft sets DWMWA_CLOAK
to FALSE
, unveiling the window with the expected dark visual rather than an abrupt white flash.
While some contributors have voiced concerns about potential race conditions—whereby a GPU may render page content as the window updates to a dark backdrop—Microsoft’s testing has not uncovered such issues, which suggests a smooth transition once the patch is deployed.
Looking ahead, it’s plausible that Google and Microsoft will refine how Chromium manages top-level windows. Future solutions could see the implementation of methods like WS_EX_NOREDIRECTIONBITMAP
or newer Windows APIs (e.g., DWM_SYSTEMBACKDROP_TYPE
) to prevent the white flash altogether.
For the time being, though, the cloaking method introduced by Davis will be adopted, eliminating the white flash effect on both Windows 10 and Windows 11. Expect these improvements to roll out soon for Chrome and Edge users.
Additional Insights
1. What is the cause of the white flash issue in Chrome and Edge?
The white flash issue occurs because Windows defaults to a white background each time a new window is created, which contrasts with the dark mode theme settings of the browser.
2. What are the implications of the cloaking method proposed by Microsoft?
The cloaking method is a temporary workaround that conceals the window until the dark background can be displayed properly. This prevents the white flash from appearing during window transitions.
3. Will future updates eliminate the white flash entirely?
While the current cloaking method addresses the white flash, future updates may explore more integrated solutions within Chromium and Windows to eventually resolve the underlying issues more effectively.
Leave a Reply