Skip to content

fix: propagate preferred color scheme to the renderer - #22896

Merged
MarshallOfSound merged 2 commits into
masterfrom
fix-prefers-color-scheme
Mar 30, 2020
Merged

MarshallOfSound merged 2 commits into
masterfrom
fix-prefers-color-scheme

Conversation

@MarshallOfSound

@MarshallOfSound MarshallOfSound commented Mar 30, 2020 •

Copy link
Copy Markdown
Member

Fixes #22846

This regressed in a recent Chromium upgrade:

032552d#diff-8a19e7f384ba27f625eb0e55641ee5feL414-L418

This PR fixes the issue and adds a test to ensure it does not regress by accident in the future. It also fixes a crash that was revealed by the test I wrote. If you close a window as the native theme updates, only possible if you do this with nativeTheme directly but fixed it 👍

It also updates our native_theme implementation to override both web and native_ui themes that Chromium uses. Currently Chromium doesn't use webUI and we opt to use native for everything, but there's no harm overriding and it might help us in the future with edge cases.

Notes: Fixed issue where prefers-color-scheme would not be updated / set correctly when your OS was in dark mode

@electron-cation electron-cation Bot added the new-pr 🌱 PR opened recently label Mar 30, 2020
@MarshallOfSound MarshallOfSound added the fast-track 🚅 Indicates that this PR is intended to bypass the 24 hour rule. Needs approval from Releases label Mar 30, 2020
@electron-cation electron-cation Bot removed the new-pr 🌱 PR opened recently label Mar 30, 2020
#endif

ui::NativeTheme* native_theme = ui::NativeTheme::GetInstanceForNativeUi();
prefs->preferred_color_scheme = native_theme->ShouldUseDarkColors()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you use the new pipeline to set the color scheme for renderer process as mentioned in https://chromium-review.googlesource.com/c/chromium/src/+/1845575

@deepak1556

Copy link
Copy Markdown
Member

Why is this PR under fast-track ?

@MarshallOfSound
MarshallOfSound force-pushed the fix-prefers-color-scheme branch from 97d9e50 to 7e63541 Compare March 30, 2020 20:47
@MarshallOfSound

Copy link
Copy Markdown
Member Author

@deepak1556 Was quite a bad regression in 8 and it's basically just restoring old code. Can we land this restoration of old logic first and I'll follow up with using the new pipeline thing?

@deepak1556

Copy link
Copy Markdown
Member

@MarshallOfSound the content layer no longer reads the value from web preferences https://chromium-review.googlesource.com/c/chromium/src/+/1845575/18/content/renderer/render_view_impl.cc , shouldn't we use the api from native theme directly based on the CL ?

@MarshallOfSound

Copy link
Copy Markdown
Member Author

@deepak1556 It must or that CL must have been reverted because if I match the changes in that CL it doesn't work and the test fails. With these changes it does work and the test passes. Not entirely sure what's going on but I know this works and it's what we had before.

@deepak1556 deepak1556 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarshallOfSound
MarshallOfSound merged commit fea3366 into master Mar 30, 2020
@release-clerk

release-clerk Bot commented Mar 30, 2020

Copy link
Copy Markdown

Release Notes Persisted

Fixed issue where prefers-color-scheme would not be updated / set correctly when your OS was in dark mode

@MarshallOfSound
MarshallOfSound deleted the fix-prefers-color-scheme branch March 30, 2020 22:39
@trop

trop Bot commented Mar 30, 2020

Copy link
Copy Markdown
Contributor

I was unable to backport this PR to "8-x-y" cleanly;
you will need to perform this backport manually.

@trop

trop Bot commented Mar 30, 2020

Copy link
Copy Markdown
Contributor

I have automatically backported this PR to "9-x-y", please check out #22900

MarshallOfSound added a commit that referenced this pull request Mar 30, 2020
* fix: do not crash if the window is closed syncronously with a nativeTheme change

* fix: propogate preferred color scheme to the renderer and keep it up to date
@trop

trop Bot commented Mar 30, 2020

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "8-x-y", please check out #22901

MarshallOfSound added a commit that referenced this pull request Mar 30, 2020
* fix: do not crash if the window is closed syncronously with a nativeTheme change

* fix: propogate preferred color scheme to the renderer and keep it up to date
MarshallOfSound added a commit that referenced this pull request Apr 1, 2020
* fix: do not crash if the window is closed syncronously with a nativeTheme change

* fix: propogate preferred color scheme to the renderer and keep it up to date
MarshallOfSound added a commit that referenced this pull request Apr 2, 2020
* fix: propagate preferred color scheme to the renderer (#22896)

* fix: do not crash if the window is closed syncronously with a nativeTheme change

* fix: propogate preferred color scheme to the renderer and keep it up to date

* chore: update native theme source patch for linux
sentialx pushed a commit to sentialx/electron that referenced this pull request Apr 7, 2020
* fix: do not crash if the window is closed syncronously with a nativeTheme change

* fix: propogate preferred color scheme to the renderer and keep it up to date
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fast-track 🚅 Indicates that this PR is intended to bypass the 24 hour rule. Needs approval from Releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

prefers-color-scheme media query not updated when changing nativeTheme.themeSource

2 participants