Skip to content
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

Move GoogleApiClient.Builder to onStart/Stop methods #10523

Merged
merged 3 commits into from
Oct 3, 2019

Conversation

planarvoid
Copy link
Contributor

@planarvoid planarvoid commented Sep 25, 2019

Fixes #10357

I think (and I might be wrong) that there are 2 possible issues. One is that sometimes onDestroy and onDetach are not called. The other one is that in the SignupEmailFragment we were checking whether the client is connected before we called stopAutoManage and I don't think that's always the case (I was able to make that crash after moving the logic to onStart and onStop).

This PR is not really based on evidence so I might be very wrong :-).

To test:

  • Test Login and Signup
  • Try to move the app to the background in the middle of the process and come back

Update release notes:

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@planarvoid planarvoid added this to the 13.4 milestone Sep 25, 2019
@planarvoid planarvoid self-assigned this Sep 25, 2019
@peril-wordpress-mobile
Copy link

Messages
📖

This PR contains changes in the subtree libs/login/. It is your responsibility to ensure these changes are merged back into WordPress-Login-Flow-Android. Follow these handy steps!
WARNING: Make sure your git version is 2.19.x or lower - there is currently a bug in later versions that will corrupt the subtree history!

  1. cd WordPress-Android
  2. git checkout feature/move_api_client_builder_to_start_stop
  3. git subtree push --prefix=libs/login/ https://github.com/wordpress-mobile/WordPress-Login-Flow-Android.git merge/WordPress-Android/10523
  4. Browse to https://github.com/wordpress-mobile/WordPress-Login-Flow-Android/pull/new/merge/WordPress-Android/10523 and open a new PR.

Generated by 🚫 dangerJS

@peril-wordpress-mobile
Copy link

peril-wordpress-mobile bot commented Sep 25, 2019

You can test the changes on this Pull Request by downloading the APK here.

public void onStop() {
super.onStop();
mGoogleApiClient.stopAutoManage(getActivity());
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we can move the null check on mGoogleApiClient a level above so to protect also the access to stopAutoManage. wdyt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you're right. I've originally had the full check there but it was crashing. In this case we should split the check.

public void onStop() {
super.onStop();
mGoogleApiClient.stopAutoManage(getActivity());
if (mGoogleApiClient != null && mGoogleApiClient.isConnected()) {
Copy link
Contributor

@develric develric Sep 29, 2019

Choose a reason for hiding this comment

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

Same comment as here. Maybe I would also consider to add same null check logic at line 230 for consistency. Let me know what you think 😊.

Copy link
Contributor

@develric develric left a comment

Choose a reason for hiding this comment

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

I also was not able to reproduce the error, but moving the code to onStart/onStop as you did in your PR but leaving the stopAutoManage inside the isConnected check I was able to get (even if not in a reproducible and always consistent way) conditions in which the client was not connected and got the exception.

I tested both the login and signup flows as you suggested: I did not get errors and was able to complete the flows.

I left a couple of comments for your review, but I agree with your analysis and proposed solution (good catch! 😎).

Copy link
Contributor

@develric develric left a comment

Choose a reason for hiding this comment

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

LGTM! :shipit:

@develric develric merged commit fbf0c0b into develop Oct 3, 2019
@planarvoid planarvoid deleted the feature/move_api_client_builder_to_start_stop branch October 3, 2019 11:21
anitaa1990 added a commit that referenced this pull request Nov 13, 2019
4b8e83512d Added logic to redirect to discovery error if xmlrpc is blocked on site
2c3223bbe7 Reverted logic to check for Jetpack availability during discovery errors since it can return a false negative
846dc2ba99 Handle site not found discovery error which can occur even with Jetpack available
e1028df7f4 Modified logic to check for discovery errors first before checking for Jetpack
16c1bbe249 Modified error message for xmlrpc errors
732a0486e7 Modified logic to initiate discovery from LoginBaseDiscoveryFragment
fdfb9df9b7 Added logic to redirect to discovery error screen, even if Jetpack is available
0833d5ca77 Add flag to check if Jetpack is available if a discovery error takes place
aa7f8cc9d9 Added logic to port over changes from the LoginSiteAddressFragment to utilise LoginBaseDiscoveryFragment
e1f2ff2d37 Modified discovery error listener to handle the various error scenarios from the calling fragment
a1bc462454 Added option to verify email only if login is for self hosted credentials
c2f2bba7a8 Added new string labels for magic link sent label
b4b9dbcabb Merge branch 'feature/sign-in-with-self-hosted-credentials' into issue/1482-step2-magic-link-signin-changes
32d2c25fd9 Handle corner case in discovery process and redirect to email screen if site is wp.com
d96252d875 Fixed nitpicks in code/xml
9b227c817b Design changes for request magic link screen
a8712882c1 Hide keyboard before redirecting to the magic link/no jetpack screen
e4e8210da2 Added logic to initiate discovery process for xmlrpc endpoint
2c35450824 Added logic to pass the input site address to forgot password flow, if the xmlrpc url is empty
f9ff33ec87 Added separate method to redirect to username screen in LoginListener
f71a4065b0 Revert discovery initiation changes to the site fragment
1e3e9cf367 Added logic to fetch SiteModel based on the site url
71ec9bdaec Added logic to redirect to no Jetpack screen when site credentials are entered
ad42794306 Revert adding a new method to LoginListener, instead use an existing listener method
8f3649b4b5 Added logic to fetch jetpack user email from site credentials and redirect to magic link screen
aa0d39d792 Pass site xmlrpc url to email and jetpack required screen
360480c6ff Initiate discovery process even if jetpack is not installed/active/connected
39b0ee010f Added logic to redirect Woo users to email login or jetpack required screen
efd18a8cef Revert the connection info endpoint implementation and update error message when site is not found
96e0ff714f Added label to the top of the LoginUsernamePasswordFragment for Woo login only
082d1e1304 Display login with site credentials link button in login email fragment
27b07bf3e1 Merge commit 'f89f408ee83d29d59dfe5740b2ba26c51dcd00df' into issue/1446-login-lib-merge
2406304ffa Merge pull request #27 from wordpress-mobile/google_login_fix
18ddefd54b Merge pull request #10523 from wordpress-mobile/feature/move_api_client_builder_to_start_stop
a87f1ec203 Update Jitpack dependency urls to use the www subdomain
24bb535488 Implement PR comments
b63bb72af9 Remove api client cleanup from onDetach
bd3410e2ad Move GoogleApiClient.Builder to onStart/Stop methods
d70141070b Add commit message for jetpack validation fix
80b21579cf Use only the isJetpackConnected property for jetpack validation
c3f9b19157 Merge pull request #10321 from wordpress-mobile/login/fix-login-tracks
0b734cf390 Merge pull request #10270 from wordpress-mobile/issue/9720-login-subtree-update-squashed
eb90f72905 Merge pull request #1312 from woocommerce/merge-login-lib
bd6086802b Merge commit 'aec4a8317d3188866c02556c182cd8d09d9b0272' into merge-login-lib
378a45be3e Fix leak of anonymous OnCancelListener reference
71cfd27b21 Merge branch 'develop' into amanda/leak_canary
42cf2d56ec Merge pull request #1292 from woocommerce/release/2.3
67de44ca60 Merge branch 'release/2.3' into merge-release/2.2.1-release/2.3
227c48b323 Merge pull request #1277 from woocommerce/merge/WordPress-Login-Flow-Android/24
0123a10b6b Reverted changes to login build.gradle
ff16da7e70 Reverted back to SDK 28 (we can update to 29 once Android Q is out of beta)
d433fad0df Merge commit '9bb4617dddea713295ce4b53a60aa2a271f318a2' squashed
b0b4f17f8a Merge commit 'f6c4fbfadce780aaebc745154c29affe46978545' into issue/9720-login-subtree-update-squashed
66695843b0 Upgraded login library to SDK 29
ff4a69e142 Add leak canary and fix leaks

git-subtree-dir: libs/login
git-subtree-split: 4b8e83512da7628a11c4b075cf79ac6e3b9864ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Groundskeeping
  
Awaiting triage
Development

Successfully merging this pull request may close these issues.

Crash when trying to create a WordPress account
2 participants