Skip to content

Conversation

@Fandroid745
Copy link
Contributor

@Fandroid745 Fandroid745 commented Dec 27, 2025

Purpose / Description

This is enhancement to prevent the Blank Screen bug on devices with an outdated WebView (e.g-old huawei models) by checking the WebView version. It will show the alert dialog when the user with an outdated webview tries to import decks.

Fixes

This pr fixes the issue #19914

Approach

  1. implemented logic to extract the Chromium version from the User-Agent string. This correctly identifies outdated engines even when OEMs report inflated versionCode values (e.g., manifest code 21311 ( downloaded and verified the manifest.xml in android studio https://www.apkmirror.com/apk/huawei/huawei-webview-2/huawei-webview-15-0-4-326-release/)

  2. Added a requiresModernWebView() hook in PageFragment (defaulting to false) and removed checkWebViewVersion(this) from DeckPicker as it was causing dialog to show on app launch in main screen

  3. Changed checkWebviewVersion function in WebViewUtils.kt to return a Boolean. It returns true only if the webview is outdated and a warning dialog is displayed.

  4. In PageFragment.onViewCreated, if the guard triggers, the app immediately calls onBackPressed() and returns. This physically prevents the WebView from initializing, avoiding the "White Screen" crash on incompatible devices.

How Has This Been Tested?

Unit Testing:
Included test cases using real-world version codes from Honor/Huawei bug reports (Manifest code 21311 and threshold 450M) to ensure the User-Agent audit correctly identifies outdated webviews
All the tests pass:

./gradlew :AnkiDroid:testPlayDebugUnitTest --tests "com.ichi2.utils.WebViewUtilsTest"
Parallel Configuration Cache is an incubating feature.
[Incubating] Problems report is available at: file:///home/dhanush/Anki-Android/build/reports/problems/problems-report.html
Deprecated Gradle features were used in this build, making it incompatible with Gradle 10.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/9.2.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD SUCCESSFUL in 12s
135 actionable tasks: 8 executed, 127 up-to-date

Learning (optional, can help others)

None

Checklist

Please, go through these checks before submitting the PR.

  • You have a descriptive commit message with a short title (first line, max 50 chars).
  • You have commented your code, particularly in hard-to-understand areas
  • You have performed a self-review of your own code
  • UI changes: include screenshots of all affected screens (in particular showing any new or changed strings)
  • UI Changes: You have tested your change using the Google Accessibility Scanner

Copy link
Member

@david-allison david-allison left a comment

Choose a reason for hiding this comment

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

This doesn't look correct.

I'll need strong evidence of testing, (ideally with a unit test), using values from a real Huawei device before I approve this.

savedInstanceState: Bundle?,
) {
val ankiActivity = requireActivity() as AnkiActivity
if (checkWebviewVersion(ankiActivity)) {
Copy link
Member

Choose a reason for hiding this comment

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

This breaks the app more than it was previously. Some pages would work on lower APIs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have added the unit tests and the warning dialog will only be displayed if the user tries importing with an outdated webview version and not on the main screen

@david-allison david-allison added the Needs Author Reply Waiting for a reply from the original author label Dec 27, 2025
@Fandroid745 Fandroid745 force-pushed the feat/webview-version-check branch from 1eca614 to 7643e0e Compare December 27, 2025 11:50
@david-allison
Copy link
Member

Cheers, what's the source of the test data?

@Fandroid745
Copy link
Contributor Author

Fandroid745 commented Dec 27, 2025

Cheers, what's the source of the test data?

2113 was the version code I got after analyzing the webview apk 15.0.4 from the apk mirror. 450 M is just a threshold that I am using, I don't know for sure if it is equal to 78 or not it is a guess.

@david-allison
Copy link
Member

Cheers. Could you provide a link in the source code

@AnEht
Copy link

AnEht commented Dec 28, 2025

apk link for testing
https://drive.google.com/file/d/1saeZe9_IgU8zuCQXY5sI7wNAWu0-_4G_/view?usp=drive_link

This is the screen shoot of what it runs on the honor device.
https://pan.huang1111.cn/s/MN1Aoix

@david-allison
Copy link
Member

@Fandroid745 What was the intention of the debug APK?

Given AnEht has updated the WebView, diagnostic information is likely to be out of date

@AnEht
Copy link

AnEht commented Dec 28, 2025

Given AnEht has updated the WebView, diagnostic information is likely to be out of date

I used an Honor device that had not been updated and a Huawei device that was updated before.

This is the screen shoot of what it runs on the honor device.

This was performed on my unupdated Honor device, which showed no changes and no warning dialogs.

@david-allison
Copy link
Member

david-allison commented Dec 29, 2025

@AnEht oh, fantastic, thanks so much

On the 'bad' device, can you go to: AnkiDroid: sidebar - help - get help - send troubleshooting report

Then settings - about - copy debug info and paste it here

@Fandroid745
Copy link
Contributor Author

Fandroid745 commented Dec 29, 2025

@Fandroid745 What was the intention of the debug APK?

Given AnEht has updated the WebView, diagnostic information is likely to be out of date

I thought the debug apk will help verify if it works on unupdated honor phones or not

@AnEht
Copy link

AnEht commented Dec 29, 2025

AnkiDroid Version = 2.23.1 (3f3133b)
Backend Version = 0.1.62-anki25.09.2 (25.09.2 3890e12c9e48c028c3f12aa58cb64bd9f8895e30)
Android Version = 10 (SDK 29)
ProductFlavor = play
Device Info = HUAWEI | HUAWEI | HWTAS | TAS-AL00 | TAS-AL00 | kirin990
Webview User Agent = Mozilla/5.0 (Linux; Android 10; TAS-AL00 Build/HUAWEITAS-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/114.0.5735.196 Mobile Safari/537.36
ACRA UUID = aed8344c-9c29-4b4b-8b94-de0c7b1a9f2b
FSRS = 5.1.0 (Enabled: true)
Crash Reports Enabled = true

@Fandroid745 Fandroid745 force-pushed the feat/webview-version-check branch from 7643e0e to 1b107a6 Compare January 2, 2026 15:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Author Reply Waiting for a reply from the original author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants