Project

General

Profile

Actions

Bug #927

closed

Fix WebView's Dark Mode on APIs 29 - 32.

Added by anonymous same over 1 year ago. Updated about 1 month ago.

Status:
Closed
Priority:
Next Release
Start date:
11/17/2022
Due date:
% Done:

0%

Estimated time:

Description

i can't enable "Dark Webview" despite setting dark mode on system-wide using the android settings nor by using the browser's own settings. i didn't have this issue with 3.11.
i have attached a ZIP containing my device's specs and some logcat outputs i could capture using adb(adb shell logcat | grep -i -e com.stoutner.privacybrowser.standard -e com.android.webview), though i'm not sure whether they're actually of any use. if you need any more logs on the situation, please mention the respective commands and i'd be very happy to report them.

regards


Files

info.zip (4.67 KB) info.zip anonymous same, 11/18/2022 12:48 AM
screenshots.zip (745 KB) screenshots.zip anonymous same, 11/18/2022 07:27 AM
screenshots2.zip (548 KB) screenshots2.zip anonymous same, 11/18/2022 09:27 AM
Navegador Privado 3.12.2 Logcat.txt (4.86 KB) Navegador Privado 3.12.2 Logcat.txt Logcat Juan Manuel, 11/26/2022 09:38 AM
Actions #1

Updated by Soren Stoutner over 1 year ago

  • Status changed from New to Closed

This is actually the way Google changed WebViews to work for all apps that target API 33.

You can read about this in the blog post:

https://www.stoutner.com/privacy-browser-3-12/

And also in Google's official documentation:

https://developer.android.com/reference/androidx/webkit/WebSettingsCompat#setAlgorithmicDarkeningAllowed(android.webkit.WebSettings,boolean)

Basically, if the app has a light theme (day mode) the WebView cannot be in dark mode. However, if you set Privacy Browser to have a dark theme or if you set your whole OS to have a dark theme then you can set the WebView to be in dark mode.

It is a silly restriction, but one that I have no control over.

Actions #2

Updated by anonymous same over 1 year ago

Soren Stoutner wrote in #note-1:

if you set Privacy Browser to have a dark theme or if you set your whole OS to have a dark theme then you can set the WebView to be in dark mode.

yeah, that's what i'm referring to. i set dark theme system-wide, WebView remains light "only" in Privacy Browser. the same happens when i set Privacy Browser to dark mode(app and webview). no matter what i try to do, webview is always in light mode "only" in Privacy Browser 3.12 for me.

i attached related screenshots that you might want to have a look at.

regards

Actions #3

Updated by Soren Stoutner over 1 year ago

According to your screenshot, you have domain settings applied. You showed a screenshot with the Dark WebView system setting, but what is the setting you have for that domain?

Actions #4

Updated by anonymous same over 1 year ago

Soren Stoutner wrote in #note-3:

but what is the setting you have for that domain?

i have attached some more screenshots. two of that domain settings values plus another website's loaded page without domain settings applied.

Actions #5

Updated by Soren Stoutner over 1 year ago

  • Subject changed from [3.12] broken dark webview? to Fix WebView's Dark Mode on APIs 29 - 32.
  • Status changed from Closed to In Progress
  • Priority changed from 3.x to Next Release

Further investigation indicates that for apps that target API 33, the current configuration is broken on API < 33 if the WebView is relatively new. Most of my testing of older APIs is in emulators that have non-upgradable WebViews stuck in the past, which is why I didn't catch this problem before release.

Looking carefully over the documentation, it should be possible to fix this problem for APIs 29 - 32. For APIs 23 - 28 it doesn't look like there is any solution as Google does not want to support the older `forceDarkMode` option on newer WebViews so they have made it a NoOp for any app targeting API 33.

Actions #7

Updated by . . over 1 year ago

I have API 28... there's no way to fix it for the rest of us?

Actions #8

Updated by Soren Stoutner over 1 year ago

No. If you read Google's documentation you can see that they have intentionally killed off support for older APIs and they have no current intention of reversing course.

https://developer.android.com/reference/androidx/webkit/WebSettingsCompat#setAlgorithmicDarkeningAllowed(android.webkit.WebSettings,boolean)

Previously I could use `setForceDark()`, but that no longer does anything after the target API is set to 33 (Tiramisu).

https://developer.android.com/reference/androidx/webkit/WebSettingsCompat#setForceDark(android.webkit.WebSettings,int)

All that is left is `setAlgorithmicDarkeningAllowed()` which was only added in API 29.

Actions #9

Updated by Lager Brewer over 1 year ago

Thank you for Privacy Browser. My experience with it is positive, and you have my appreciation.

This is my first post here. Please forgive me if I am posting incorrectly. I only see "Edit", and not "Post", so I am concerned that I am making an error. My apologies in advance if using "Edit" is the incorrect way to add content.

Losing dark mode, unfortunately, is a deal-breaker for me. I don't want to lose Privacy Browser, so I'm trying to think of solutions/workarounds.

My Android uses API <29. To clarify, if `setForceDark()` is called and Privacy Browser's target API is set to 33, nothing happens, even on devices that only support API<33 (most devices)?

If so, that's horrible of Google, but that sort of forced obsolescence seems to part of their game plan to get people to part with as much money as Google can, while simultaneously polluting our planet's landfills with expensive and often toxic electronics (and all this will hopefully lead to even more legal actions against Google).

What would be the downside of setting the target API for Privacy Browser to 32 so that dark mode will still work?

I only feel mildly comfortable asking here, but I respect this project so much that I think Soren and other people here may be able to provide the best responses: if Privacy Browser can't support dark mode due to Google's manufactured limitations, which other web browsers may have a similar feature set, but still allow dark mode?

Actions #10

Updated by Soren Stoutner over 1 year ago

I thought about doing that, but there are too many downsides to not targeting the current version of Android. For example, you lose access to new features, like per-app language settings (see https://redmine.stoutner.com/issues/910). More importantly, updates to the library dependencies are often not available unless targeting the current API. For example, you can not use the latest Kotlin libraries unless you are targeting API 33.

From a big picture perspective, when you choose to build on an ecosystem like Android, you are committed for security reasons to always running supported versions. I wish that Android hardware manufacturers would support firmware updates for older devices (or even better, open source their firmware code). But because none of them do, there is no way to run a secure device on hardware that is older than about 4 years.

Actions #11

Updated by Juan Manuel over 1 year ago

Hi, I'm experiencing the behaviour described here with dark mode after updating from version 3.12.1 to 3.12.2. As far as I can tell, I have API 29 (Android 10) so this shouldn't be an issue, should it? It's strange because all worked as expected on previous versions, so I don't know what's happening. Perhaps I'm missing something, but can't realize.

As soon as I run Privacy Browser, I see a white background instead of a dark one. I set dark mode on system and also on the app. WebView is set on dark mode as well. I tried reselecting those settings just in case, but it didn't work.

When loading several websites, I enter the menu and dark mode is unticked, but I can't tick it manually. I attach the logcat I get on that particular situation.

Here are several specifications:

Navegador Privado
Versión 3.12.2 (código de versión 63)

Hardware
Marca:  Motorola
Fabricante:  Motorola
Modelo:  Moto E LTE
Dispositivo:  surnia
Cargador de arranque:  0x8022
Radio:  M8916_2020629.41.03.21.51R

Software
Android:  10 (API 29)
Parche de seguridad:  2022-01-05
Versión de compilación:  lineage_surnia-userdebug 10 QQ3A.200805.001 10039282
Kernel:  3.10.108-NPD26.48-24-1-gccff8f0ae7b
Proveedor de WebView:  com.android.webview
Versión de WebView:  97.0.4692.98

If there is anything else needed, just let me know.

Thank you!

Actions #12

Updated by Soren Stoutner over 1 year ago

You are running a really old version of Android's WebView. If you update it to 108.0.x.x I would imagine it would resolve the problem.

Actions #13

Updated by Juan Manuel over 1 year ago

Thanks for the advice! I'll see what I can do. I'll let you know if I can update and that solves the issue.

Actions #14

Updated by . . over 1 year ago

can't a fix be implemented from the side of Privacy Browser? for API 23-28?

Actions #15

Updated by Soren Stoutner over 1 year ago

As explained in the comments above, there is nothing Privacy Browser can do to override Google's decision to remove this feature on API <= 28.

Actions #16

Updated by Forest O over 1 year ago

Upgrading from 3.12.1 to 3.12.2 broke dark mode for me too, despite being on Android 10, which I believe is API 29.

Curiously, duckduckgo.com briefly renders with a dark background before repainting in white. I have javascript disabled, so I don't think that color switch is coming from their web site.

This is a very recent LineageOS 17.1 build, with the November 5 2022 Android security patches. The built-in WebView is version 100.0.4896.127, which I think is only a few months old. If there is no way to restore dark mode with this WebView branch, I guess I have two questions:

How can a LineageOS 17.1 user get an updated WebView without the Google Play store or any proprietary APKs? (I use F-Droid for my apps.)

Since Privacy Browser 3.12.1 still works, can it be kept in the F-Droid repositories for people who still need dark mode?

Actions #17

Updated by Soren Stoutner over 1 year ago

Upgrading WebView to a current version will fix your problem.

WebView 100.0.4896.127 is from April 2022 and has multiple known security vulnerabilities. I would not recommend that anyone run it in production.

https://www.apkmirror.com/?post_type=app_release&searchtype=apk&s=android+system+webview+100

The way you update WebView depends on the signature on the package you currently have (the signatures must match for an update). If the version you currently have was signed by Google you can get an update form an app like Aurora. If the version you currently have was signed by LineageOS, you will need to get an updated version from them.

https://f-droid.org/en/packages/com.aurora.store/

Actions #18

Updated by Juan Manuel about 1 month ago

Hi! Just wanted to say that I finally managed to update the Android WebView on my device and now dark mode is back again, so problem solved!

For those who run LineageOS, the way I could update the app is by downloading the APK —signed by LineageOS— from APKmirror. I couldn't find a better source. The link is the following

https://www.apkmirror.com/apk/lineageos/android-system-webview-2/

and you need to know your device's architecture to download the right file.

The app will get installed beside the original one (extra disk space), but it will be recognized as an update, so there's no need to configure anything else once it's installed.

Actions #19

Updated by Soren Stoutner about 1 month ago

Thanks for the info.

Actions

Also available in: Atom PDF