-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Added additional debug info (WebView/Hardware) #8250
Conversation
Codecov Report
@@ Coverage Diff @@
## master #8250 +/- ##
============================================
+ Coverage 36.88% 37.00% +0.12%
- Complexity 3736 3788 +52
============================================
Files 347 355 +8
Lines 35676 35843 +167
Branches 4724 4744 +20
============================================
+ Hits 13158 13263 +105
- Misses 21010 21069 +59
- Partials 1508 1511 +3
Continue to review full report at Codecov.
|
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.
Thanks! 2 minor changes, then good to go
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.
Looks good to me, thanks!
some JUnit test is failing,why is that? |
Likely flakiness/nondeterminism in our unit tests - I haven't been through to fix them, and I think the migration from TravisCI to GitHub actions brought out a few issues Arthur has a PR waiting which should fix the issue once and for all, and I haven't had the time to truly think through the design |
Any updates regarding this ?Is everything fine? |
I have updated the PR description to include |
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.
one control flow issue, two spacing nits, excited to get this expanded info from users though!
webviewUserAgent = getWebviewUserAgent(); | ||
} catch (Throwable e) { | ||
AnkiDroidApp.sendExceptionReport(e, "Info::copyDebugInfo()", "some issue occured while extracting webview user agent"); | ||
return null; |
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.
why would we return in this case, without returning the rest of the information ?
None of the other try/catch blocks return and so in no other case will this method return null, meaning that now consumers have to null check it whereas before it was safe.
This catch block should not return, and definitely should not return null
"Manufacturer = " + Build.MANUFACTURER + "\n\n" + | ||
"Model = " + Build.MODEL + "\n\n" + | ||
"Hardware = " + Build.HARDWARE+"\n\n" + | ||
"Webview User Agent = "+ webviewUserAgent + |
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.
"Webview User Agent = "+ webviewUserAgent + | |
"Webview User Agent = " + webviewUserAgent + |
spacing nit: https://github.com/ankidroid/Anki-Android/wiki/Code-style#white-space-should-be-used-in-the-following-cases -> "after and before operators"
@@ -236,6 +247,9 @@ public String copyDebugInfo() { | |||
return debugInfo; | |||
} | |||
|
|||
private String getWebviewUserAgent() { | |||
return new WebView(this).getSettings().getUserAgentString()+ "\n\n"; |
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.
return new WebView(this).getSettings().getUserAgentString()+ "\n\n"; | |
return new WebView(this).getSettings().getUserAgentString() + "\n\n"; |
Will get it done as soon as possible sir✌️ |
done @mikehardy sir! |
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.
As discussed on Discord - needs rebasing onto master and removing the merge commit
22338fe
to
e8141a2
Compare
Yeah, sorry - the commit history is non-reviewable at the moment. Once cleaned up I can re-check |
sir it is the same code as from the PR ,just except that due to the rebase it has other commits with it 😅,I can squash all the commits into one but would that help? |
When I open the "Commits" tab on the PR I should see nothing but clean commits that implement your changes only, no unrelated commits When I open the "Files Changed" tab on the PR I should see nothing but an easily readable diff containing nothing but the actual changes you needed to make to implement the improvement There are many ways to do this with git, I don't have the time to lead you through them, but choose one that meets my expectations of a clean diff as described here, and I can review it |
That is sometimes the best option, although I think there is value for you - as a person learning git - in figuring out how to actually fix this using |
Yes I get that! |
e8141a2
to
8213854
Compare
Now let me know if I've got it right this time :) |
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.
Thanks! Tiny nitpick.
Almost there.
- Could you squash the 3 commits into one
I feel the commit message would be better as:
Added additional debug info (WebView/Hardware)
Fixes #8234
This provides more context for the commit, the issue number isn't too relevant when looking for context in a long list of issues.
|
||
String debugInfo = "AnkiDroid Version = " + VersionUtils.getPkgVersionName() + "\n\n" + | ||
"Android Version = " + Build.VERSION.RELEASE + "\n\n" + | ||
"Manufacturer = " + Build.MANUFACTURER + "\n\n" + | ||
"Model = " + Build.MODEL + "\n\n" + | ||
"Hardware = " + Build.HARDWARE+"\n\n" + |
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.
"Hardware = " + Build.HARDWARE+"\n\n" + | |
"Hardware = " + Build.HARDWARE+ "\n\n" + |
@@ -236,6 +246,9 @@ public String copyDebugInfo() { | |||
return debugInfo; | |||
} | |||
|
|||
private String getWebviewUserAgent() { | |||
return new WebView(this).getSettings().getUserAgentString() + "\n\n"; |
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.
Nitpick/Implementer's choice: code style
I feel that the try/catch would be better inside this method, this allows us to reduce code in the copyDebugInfo
method, and move the method call inline to where it's used
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.
Yeah thats what I really wanted to do but it gives a compile time error (Java doesn't risk return in non-void functions) and hence I will have to return something else (probably null) if the try block throws an exception which makes the code unsafe again.
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 will squash the commits for now
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.
You can return null, that's what we're doing implicitly here anyway
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.
ok did that
8213854
to
e1f0735
Compare
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.
28a7588
to
ed2fd93
Compare
I think all is taken care of ,can you check @david-allison-1 |
ed2fd93
to
710728d
Compare
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.
Looks good to me, thanks!
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.
good to go! Thanks
Hi there! Just a friendly notice (one per person for PRs merged in March, regardless of PR quantity) that we try to process OpenCollective payments monthly - it's time for March 2021 submissions If you are interested in compensation for this work, the process with details is here: Thanks! |
@2tanayk I was able to just immediately diagnose a user problem as an out-of-date webview based on this extra debugging information, and it fixed the user immediately when they updated. I love seeing things like this pay off! Thanks again |
Thanks @mikehardy means a lot to me and my semester almost over,look to start contributing again! |
Pull Request template
Purpose / Description
Added additional and useful debug info -device manufacturer, model, hardware and webview user agent.
Fixes
Fixes #8234
Approach
Used the android os class
Build.
to extract manufacturer, model and hardware informationUsed an anonymous instance of the
Webview
class which isnew WebView(this).getSettings().getUserAgentString()
to extract the webview user agentHow Has This Been Tested?
Tested on an actual android device which runs on Android 10(API 29)
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration (SDK version(s), emulator or physical, etc)
Checklist
Please, go through these checks before submitting the PR.
if
statements)