Skip to content

Fix Android connectivity issues #937

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

Closed
wants to merge 15 commits into from
Closed

Fix Android connectivity issues #937

wants to merge 15 commits into from

Conversation

thebrianchen
Copy link

@thebrianchen thebrianchen commented Oct 23, 2019

Fixes b/141865469.

  • Moves the responsibility to retry the connection attempt from the onClose() handler to start().

Updated (11/12):

  • Use CONNECTIVITY_ATTEMPT_TIMEOUT and ONLINE_STATE_TIMEOUT to track transition vs. retry attempts.

@thebrianchen
Copy link
Author

/retest

@wilhuff wilhuff assigned thebrianchen and unassigned wilhuff Oct 24, 2019
@thebrianchen
Copy link
Author

/test check-changed

@thebrianchen
Copy link
Author

/test smoke-tests

@thebrianchen thebrianchen requested a review from wilhuff November 2, 2019 01:28
@thebrianchen thebrianchen assigned wilhuff and unassigned thebrianchen Nov 2, 2019
() -> {
// If the network has been explicitly disabled, make sure we don't accidentally
// re-enable it.
if (canUseNetwork()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Previously, in the case of an online state timeout we performed the following things:

                logClientOfflineWarningIfNecessary(	
                    String.format(	
                        Locale.ENGLISH,	
                        "Backend didn't respond within %d seconds\n",	
                        ONLINE_STATE_TIMEOUT_MS / 1000));	
                setAndBroadcastState(OnlineState.OFFLINE);	

This isn't calling handleWatchStreamFailure so how is the OnlineState supposed to get to OFFLINE after the first timeout?

Copy link
Author

Choose a reason for hiding this comment

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

handleWatchStreamFailure is still being called:

  1. attemptReconnect() results in calling AbstractStream.close()
  2. close() calls the onClose() listener passed in, which calls RemoteStore.handleWatchStreamClose()
  3. handleWatchStreamClose() calls handleWatchStreamFailure().

The problem I was running into by leaving a handleWatchStreamFailure() in the timeout logic was that handleWatchStreamFailure() would be called twice, once in the timer timeout, and once in handleWatchStreamClose(). Calling attemptReconnect() would call handleWatchStreamFailure() followed by a call to startWatchStream(). The subsequent call to handleWatchStreamFailure() in the timeout logic would then clear the connectivity timer set by attemptReconnect().

@wilhuff wilhuff assigned thebrianchen and unassigned wilhuff Nov 4, 2019
@thebrianchen
Copy link
Author

/retest

@thebrianchen
Copy link
Author

/test smoke-tests

1 similar comment
@thebrianchen
Copy link
Author

/test smoke-tests

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: no and removed cla: yes Override cla labels Dec 3, 2019
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

1 similar comment
@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@googlebot googlebot added cla: yes Override cla and removed cla: no labels Dec 3, 2019
@thebrianchen thebrianchen assigned thebrianchen and unassigned wilhuff Dec 5, 2019
@firebase firebase locked and limited conversation to collaborators Jan 10, 2020
@vkryachko vkryachko deleted the bc/reconnect branch December 2, 2022 16:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants