-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: verify webview version and prevent loading blank screen #19937
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: verify webview version and prevent loading blank screen #19937
Conversation
david-allison
left a comment
There was a problem hiding this 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)) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
1eca614 to
7643e0e
Compare
|
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. |
|
Cheers. Could you provide a link in the source code |
This is the screen shoot of what it runs on the honor device. |
|
@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 used an Honor device that had not been updated and a Huawei device that was updated before.
This was performed on my unupdated Honor device, which showed no changes and no warning dialogs. |
|
@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 |
I thought the debug apk will help verify if it works on unupdated honor phones or not |
|
AnkiDroid Version = 2.23.1 (3f3133b) |
7643e0e to
1b107a6
Compare
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
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/)
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
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.
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:
Learning (optional, can help others)
None
Checklist
Please, go through these checks before submitting the PR.