Skip to content

Skip backoff when App enters Foreground #2693

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

Merged
merged 1 commit into from
May 26, 2021

Conversation

schmidt-sebastian
Copy link
Contributor

@schmidt-sebastian schmidt-sebastian commented May 25, 2021

We might lose network connectivity when a Firestore app is backgrounded. This PR changes our network monitor to skip the backoff when an app goes back in the foreground, which causes the SDK to immediately try to reconnect.

Tested manually.

Fixes #2637

@google-cla google-cla bot added the cla: yes Override cla label May 25, 2021
@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 25, 2021

Binary Size Report

Affected SDKs

  • firebase-firestore

    Type Base (b5d06cd) Head (fe634292) Diff
    aar 1.03 MB 1.03 MB -246 B (-0.0%)
    apk (release) 3.19 MB 3.19 MB +384 B (+0.0%)

Test Logs

Notes

Head commit (fe634292) is created by Prow via merging commits: b5d06cd dca9259.

@google-oss-bot
Copy link
Contributor

google-oss-bot commented May 25, 2021

Macrobenchmark Report

Affected SDKs

Measurements are for head commit (dca9259). Diffing against base commit (b5d06cd) is working in progress.

  • baseline

    NameDeviceMinMaxP50P90P99
    BenchmarkTest.startup[mode=COLD]flame-30-en-portrait127.0 ms161.0 ms137.0 ms149.4 ms159.5 ms
    BenchmarkTest.startup[mode=HOT]flame-30-en-portrait42.0 ms73.0 ms56.5 ms61.3 ms71.3 ms
    BenchmarkTest.startup[mode=WARM]flame-30-en-portrait54.0 ms89.0 ms69.5 ms86.2 ms88.8 ms
  • firebase-common

    NameDeviceMinMaxP50P90P99
    BenchmarkTest.startup[mode=COLD]flame-30-en-portrait124.0 ms166.0 ms141.0 ms158.5 ms165.4 ms
    BenchmarkTest.startup[mode=HOT]flame-30-en-portrait43.0 ms67.0 ms50.0 ms66.0 ms66.8 ms
    BenchmarkTest.startup[mode=WARM]flame-30-en-portrait63.0 ms89.0 ms79.0 ms87.1 ms88.8 ms
  • firebase-config

    NameDeviceMinMaxP50P90P99
    BenchmarkTest.startup[mode=COLD]flame-30-en-portrait124.0 ms174.0 ms149.5 ms165.2 ms172.7 ms
    BenchmarkTest.startup[mode=HOT]flame-30-en-portrait38.0 ms66.0 ms47.0 ms59.3 ms65.2 ms
    BenchmarkTest.startup[mode=WARM]flame-30-en-portrait60.0 ms87.0 ms73.5 ms81.1 ms86.0 ms
  • firebase-crashlytics

    NameDeviceMinMaxP50P90P99
    BenchmarkTest.startup[mode=COLD]flame-30-en-portrait138.0 ms183.0 ms155.5 ms169.1 ms182.2 ms
    BenchmarkTest.startup[mode=HOT]flame-30-en-portrait41.0 ms68.0 ms50.0 ms60.7 ms67.8 ms
    BenchmarkTest.startup[mode=WARM]flame-30-en-portrait50.0 ms85.0 ms67.5 ms82.0 ms84.4 ms
  • firebase-database

    NameDeviceMinMaxP50P90P99
    BenchmarkTest.startup[mode=COLD]flame-30-en-portrait121.0 ms149.0 ms140.0 ms147.0 ms148.6 ms
    BenchmarkTest.startup[mode=HOT]flame-30-en-portrait33.0 ms69.0 ms45.5 ms63.1 ms68.1 ms
    BenchmarkTest.startup[mode=WARM]flame-30-en-portrait56.0 ms81.0 ms74.0 ms80.0 ms80.8 ms
  • firebase-dynamic-links

    NameDeviceMinMaxP50P90P99
    BenchmarkTest.startup[mode=COLD]flame-30-en-portrait118.0 ms168.0 ms144.0 ms149.0 ms164.4 ms
    BenchmarkTest.startup[mode=HOT]flame-30-en-portrait33.0 ms63.0 ms51.5 ms58.5 ms63.0 ms
    BenchmarkTest.startup[mode=WARM]flame-30-en-portrait57.0 ms91.0 ms71.5 ms80.2 ms89.3 ms
  • firebase-firestore

    NameDeviceMinMaxP50P90P99
    BenchmarkTest.startup[mode=COLD]flame-30-en-portrait129.0 ms160.0 ms144.5 ms150.0 ms158.1 ms
    BenchmarkTest.startup[mode=HOT]flame-30-en-portrait37.0 ms69.0 ms51.0 ms59.4 ms67.9 ms
    BenchmarkTest.startup[mode=WARM]flame-30-en-portrait55.0 ms84.0 ms71.5 ms79.2 ms83.4 ms
  • firebase-functions

    NameDeviceMinMaxP50P90P99
    BenchmarkTest.startup[mode=COLD]flame-30-en-portrait129.0 ms173.0 ms136.0 ms148.5 ms170.9 ms
    BenchmarkTest.startup[mode=HOT]flame-30-en-portrait38.0 ms66.0 ms57.5 ms61.3 ms65.6 ms
    BenchmarkTest.startup[mode=WARM]flame-30-en-portrait57.0 ms85.0 ms73.0 ms83.0 ms84.6 ms
  • firebase-inappmessaging-display

    NameDeviceMinMaxP50P90P99
    BenchmarkTest.startup[mode=COLD]flame-30-en-portrait163.0 ms206.0 ms183.0 ms196.9 ms205.8 ms
    BenchmarkTest.startup[mode=HOT]flame-30-en-portrait36.0 ms63.0 ms47.5 ms58.4 ms62.8 ms
    BenchmarkTest.startup[mode=WARM]flame-30-en-portrait50.0 ms85.0 ms73.0 ms84.0 ms84.8 ms
  • firebase-messaging

    NameDeviceMinMaxP50P90P99
    BenchmarkTest.startup[mode=COLD]flame-30-en-portrait129.0 ms175.0 ms146.0 ms156.4 ms172.1 ms
    BenchmarkTest.startup[mode=HOT]flame-30-en-portrait37.0 ms69.0 ms54.0 ms64.1 ms68.2 ms
    BenchmarkTest.startup[mode=WARM]flame-30-en-portrait48.0 ms84.0 ms71.5 ms78.1 ms83.1 ms
  • firebase-perf

    NameDeviceMinMaxP50P90P99
    BenchmarkTest.startup[mode=COLD]flame-30-en-portrait135.0 ms183.0 ms152.5 ms169.7 ms181.7 ms
    BenchmarkTest.startup[mode=HOT]flame-30-en-portrait42.0 ms70.0 ms50.5 ms66.1 ms69.4 ms
    BenchmarkTest.startup[mode=WARM]flame-30-en-portrait61.0 ms88.0 ms77.5 ms84.3 ms87.8 ms
  • firebase-storage

    NameDeviceMinMaxP50P90P99
    BenchmarkTest.startup[mode=COLD]flame-30-en-portrait131.0 ms159.0 ms147.5 ms155.3 ms158.8 ms
    BenchmarkTest.startup[mode=HOT]flame-30-en-portrait36.0 ms74.0 ms56.0 ms68.4 ms73.6 ms
    BenchmarkTest.startup[mode=WARM]flame-30-en-portrait51.0 ms98.0 ms75.0 ms83.1 ms95.3 ms

@Override
public void onBackgroundStateChanged(boolean background) {
if (!background && isConnected()) {
raiseCallbacks(/* connected= */ true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Is invoking the callbacks enough to reset the backoff? (I presume it is, just checking)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, they already call inhibitBackoff.

@schmidt-sebastian schmidt-sebastian merged commit 3145da7 into master May 26, 2021
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/lifecyclehooks branch May 26, 2021 03:21
@firebase firebase locked and limited conversation to collaborators Jun 26, 2021
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.

Firestore takes up to 90 seconds to get new data after app returns to the foreground
4 participants