MicrosoftEdge / MicrosoftEdge/WebView2Feedback
[Problem/Bug]: Setting PreferredColorScheme on ICoreWebView2Profile4 affects all WebViews in the same Environment
Nobody has claimed this yet.
- Dominant language
- PowerShell
- Stars
- 526
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
What happened?
Bug Report: Setting PreferredColorScheme on ICoreWebView2Profile4 affects all WebViews in the same Environment
Reproduction Steps
Create a WebView2 Environment
auto hr = CreateCoreWebView2EnvironmentWithOptions(...);
Create WebView #1 and set LIGHT theme
2.1 webViewEnvironment10->CreateCoreWebView2ControllerWithOptions(...)
2.2 In the controller-created callback:
HRESULT OnCreatedWebViewController(HRESULT result, ICoreWebView2Controller* controller, int clientBrowserId)
Inside the callback:
auto webView2_13 = webviewWindow_.try_query<ICoreWebView2_13>();
auto webView2Profile4 = webView2Profile.try_query<ICoreWebView2Profile4>();
webView2Profile4->put_PreferredColorScheme(COREWEBVIEW2_PREFERRED_COLOR_SCHEME_LIGHT);
Create WebView #2 and set DARK theme
3.1 webViewEnvironment10->CreateCoreWebView2ControllerWithOptions(...)
3.2 In the controller-created callback:
HRESULT OnCreatedWebViewController(HRESULT result, ICoreWebView2Controller* controller, int clientBrowserId)
Inside the callback:
auto webView2_13 = webviewWindow_.try_query<ICoreWebView2_13>();
auto webView2Profile4 = webView2Profile.try_query<ICoreWebView2Profile4>();
webView2Profile4->put_PreferredColorScheme(COREWEBVIEW2_PREFERRED_COLOR_SCHEME_DARK);
Expected Behavior
WebView #1 should use LIGHT theme.
WebView #2 should use DARK theme.
Each WebView instance should respect its own ICoreWebView2Profile4::PreferredColorScheme.
Actual Behavior
WebView #1 → DARK theme (incorrect)
WebView #2 → DARK theme (correct)
Setting PreferredColorScheme on the profile for WebView #2 unexpectedly changes the theme of WebView #1 as well.
Conclusion
This appears to be a bug:
ICoreWebView2Profile4::put_PreferredColorScheme modifies the color scheme for all WebViews created from the same WebView2Environment, rather than only the WebView associated with that profile.
Desired Behavior
PreferredColorScheme should apply only to the specific WebView/Profile instance, and should not affect other WebViews created from the same WebView2Environment.
This is important for applications that host multiple WebViews with different theme requirements.
Importance
Blocking. My app's basic functions are not working due to this issue.
Runtime Channel
Stable release (WebView2 Runtime)
Runtime Version
138.0.3351.83
SDK Version
No response
Framework
Win32
Operating System
Windows 11
OS Version
No response
Repro steps
Create a WebView2Environment
auto hr = CreateCoreWebView2EnvironmentWithOptions();
Create WebView #1 and set it to LIGHT theme
Call CreateCoreWebView2ControllerWithOptions
After WebView is created, get its ICoreWebView2Profile4
Set:
webView2Profile2_->put_PreferredColorScheme(
COREWEBVIEW2_PREFERRED_COLOR_SCHEME_LIGHT);
Create WebView #2 and set it to DARK theme
Call CreateCoreWebView2ControllerWithOptions
After WebView is created, get its ICoreWebView2Profile4
Set:
webView2Profile2_->put_PreferredColorScheme(
COREWEBVIEW2_PREFERRED_COLOR_SCHEME_DARK);
Expected Result
WebView #1 should use LIGHT theme
WebView #2 should use DARK theme
Actual Result
WebView #1 becomes DARK
WebView #2 becomes DARK
Setting the theme on WebView #2 changes the theme of WebView #1.
Conclusion (Bug Summary)
This is a bug:
Setting PreferredColorScheme on ICoreWebView2Profile4 affects all WebViews created from the same WebView2Environment, instead of applying only to the specific WebView/profile.
Expected behavior:
Changing the theme on a profile should not modify the theme of other WebViews in the same environment.
Repros in Edge Browser
Yes, issue can be reproduced in the corresponding Edge version
Regression
No, this never worked
Last working version (if regression)
No response
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the CreateCoreWebView2EnvironmentWithOptions and CreateCoreWebView2ControllerWithOptions entry points, then follow ICoreWebView2Profile4::put_PreferredColorScheme for each WebView. Reproduce the LIGHT/DARK sequence on Windows 11 with the Stable WebView2 Runtime 138.0.3351.83. Done means each WebView retains its own configured color scheme without changing the other.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 30/100