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

Android SDK is making background requests when the app is closed observed up to 9 minutes #104

Open
rubixhacker opened this issue Feb 8, 2023 · 3 comments

Comments

@rubixhacker
Copy link

Expected Behavior

After the initial flush on close, the Amplitude SDK should not make additional background requests.

Current Behavior

Background network requests are made every 30 seconds, depending on the device, for one minute to nine minutes. Even with flushEventsOnClose set as false and flushMaxRetries set as zero.

Possible Solution

The issue appears to lie in amplitudeScope, AndroidLifecyclePlugin should cancel all children scopes and then restart all the children scopes when the app returns to the foreground

Steps to Reproduce

  1. Implement the Amplitude SDK in an Android app
  2. With the app running open the App Inspection tab in Android Studio
  3. Go to the Network Inspector tab
  4. Background the app (close or hit the home button)
  5. Notice that network calls are made every 30 seconds to https://api2.amplitude.com/2/httpapi

Environment

  • Android Plugin Version: 1.6.1
  • Device: Samsung Fold 3, Surface Duo, Pixel 6a and Android Emulator
  • Device OS and Version: Android, multiple versions
@qingzhuozhen
Copy link
Contributor

Thanks for reporting this! This is potentially for background requests and retries. We would dive more into this behavior.

@rubixhacker
Copy link
Author

Hi @qingzhuozhen,

Were you able to investigate this issue further? This past weekend we had a user report that our app used over 45GB of data in the background, and the only thing we can identify as using the data is the Amplitude SDK. We have been instructing users facing this issue to restrict background access of the app, and that stops the background requests from the Amplitude SDK.

@qingzhuozhen
Copy link
Contributor

Hi @rubixhacker, the 30s interval is already updated in the newer versions, so if you upgrade the SDK version this should be resolved. I am also adding more enforcement on retries to prevent it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants