-
-
Notifications
You must be signed in to change notification settings - Fork 51
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
134 - Improve UX of crosswalk to webview migration #162
Conversation
- Remove redundant DEBUG check performed by MedicLog.* methods - Better and more homogeneous logging messages - Add caller reference to Medic.log
Upgrade due security concerns highlighted by Android Studio, though there is no release notes with the issues fixed in the library
src/webview/java/org/medicmobile/webapp/mobile/EmbeddedBrowserActivity.java
Show resolved
Hide resolved
@@ -78,6 +80,8 @@ public void onReceiveValue(String result) { | |||
private PhotoGrabber photoGrabber; | |||
private SmsSender smsSender; | |||
|
|||
private boolean isMigrationRunning = false; |
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.
With this as a boolean it'll reset to false on restart. This may be an issue if it crashes or the user closes it. Can we store it somewhere persistent instead?
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.
Yes, but solve that means make the migration process more resilient, with the ability to resume in the cases you mention, but it is out of scope I think for this ticket that only intent to improve the UI so users are not presented to the login page which cause many problems described in the ticket.
Currently, If the app crashes but the migration was finished, there won't be a problem, because the app will be restarted and with our without this patch the UI will load the CHT dashboard because a that point the cookies will be available again. If the crash happens during the migration, is likely the data will be corrupted and the user will need to reinstall the app losing the data, but again this PR cannot address that 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.
I'm worried about edge cases like... What if the user spawns a second instance of this Activity? What happens if two migrations run in parallel, or one after the other?
However adding some sort of persistent flag is also risky... what if it gets set to migrating = true
and then the migration fails? It may never recover.
This is going to have to be tested really thoroughly to avoid bricking or corrupting phones. Are you confident this is the safest approach?
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 know you hadn't marked this for review, but thought it might help to add my two cents earlier rather than later!
I've added a couple of suggestions inline.
Additionally, the if (DEBUG)
statements are there as a slight performance boost so in production the app doesn't have to initialise and format the parameters only for them to be GCed again almost immediately. This is best practice as far as I'm aware.
@garethbowen yes actually I removed it not just to make the code more readable without so many |
…gin page even if it is a fraction of seconds
38ba520
to
7c72508
Compare
Ready for review again, comments about the changes here: #134 (comment) |
Quick test instructionsNot yet in AT but here are some observations of how to test the PR. Because the XWalk version does not work in Android >= 10, and the Webview version is compiled to work only in Android >= 10 for now in the master branch and this branch, the way to test the PR would be install the XWalk version in an Android <10 phone, then upgrade the phone to Android >=10 and finally install the version on this PR, which is is too much for testing, and may not be an option because the device used for testing does not support Android upgrades to the version 10. What I do for test is:
|
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.
The video walkthrough looks awesome. Great work!
I've left some comments inline. Because of the risk of data loss or bricking phones I'm being even more pedantic than usual...
@@ -78,6 +80,8 @@ public void onReceiveValue(String result) { | |||
private PhotoGrabber photoGrabber; | |||
private SmsSender smsSender; | |||
|
|||
private boolean isMigrationRunning = false; |
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'm worried about edge cases like... What if the user spawns a second instance of this Activity? What happens if two migrations run in parallel, or one after the other?
However adding some sort of persistent flag is also risky... what if it gets set to migrating = true
and then the migration fails? It may never recover.
This is going to have to be tested really thoroughly to avoid bricking or corrupting phones. Are you confident this is the safest approach?
log(this, "onPageStarted() :: Migration process in progress, and " + | ||
"cookies were not loaded, restarting ..."); | ||
Context context = view.getContext(); | ||
Intent intent = new Intent(context, StartupActivity.class); | ||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); | ||
context.startActivity(intent); | ||
Runtime.getRuntime().exit(0); |
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 section is really important, and quite difficult to understand. Consider pulling out a private function that can be named clearly. In addition it probably needs some commenting about what this is doing and why it works.
isMigrationRunning = false; | ||
CookieManager cookieManager = CookieManager.getInstance(); | ||
String cookie = cookieManager.getCookie(appUrl); | ||
if (cookie == 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.
What happens if a user's cookies have expired (or be wiped manually)? I think it'll work... migration will pick up the IndexedDB, then on restart isMigrationRunning
will be false, and the user will go to the login page (as expected). Is that right? Have you tested this case?
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.
Yes, I tried to install this version over a XWalk installation that has loaded the webapp but logged out, and the migration runs and then the app display the login page as expected.
Also installed the app without previous installations of Xwalk to ensure the migration process is not started. Same if it was a XWalk installation but with no data previously loaded.
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.
Awesome!
Approved - the build is failing but I'll let you dig in to that.
Feel free to create a separate issue/PR for the service worker cache so we can start the AT process on this one.
Thanks @garethbowen ! Yes the build error is due an issue in the jCenter servers that are responding with a HTTP 403 error when CI tries to pull one of the dependencies. I'll try to rebuild in a few minutes.
Yes, going to do that to move forward with testing. |
Co-authored-by: Marc Abbyad <[email protected]>
Improve the UX after the migration restarting the app.
Issue: #134
TO DO:
Add also a better UI with activities / layout when the connection is lost→ Moved to Improve connection errors UX, especially for the XWalk-Webview migration process #163Other improvements
4.1.1→ 4.1.2, Android Studio marks the older version as insecure.