-
Notifications
You must be signed in to change notification settings - Fork 642
Disconnect from Remote Config real-time server when app is backgrounded. #6816
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
Conversation
📝 PRs merging into main branchOur main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released. |
Coverage Report 1Affected Products
Test Logs |
Test Results 42 files - 992 42 suites - 992 1m 23s ⏱️ - 32m 55s Results for commit 3c879c7. ± Comparison against base commit 58b9da4. This pull request removes 5550 and adds 2 tests. Note that renamed tests count towards both.
♻️ This comment has been updated with latest results. |
Size Report 1Affected Products
Test Logs |
firebase-config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigAutoFetch.java
Outdated
Show resolved
Hide resolved
...config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigRealtimeHttpClient.java
Outdated
Show resolved
Hide resolved
...config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigRealtimeHttpClient.java
Outdated
Show resolved
Hide resolved
Startup Time Report 1Note: Layout is sometimes suboptimal due to limited formatting support on GitHub. Please check this report on GCS. Notes
Startup Times
|
firebase-config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigAutoFetch.java
Outdated
Show resolved
Hide resolved
firebase-config/src/test/java/com/google/firebase/remoteconfig/FirebaseRemoteConfigTest.java
Show resolved
Hide resolved
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.
LGTM, minor feedback on a code comment.
This PR focuses on enhancing the reliability and efficiency of the Remote Config real-time stream, particularly concerning background app states. We've refined the
ConfigRealtimeHttpClient
to retrieve and manage the underlying input and error streams more effectively, ensuring proper closure even in error scenarios. Additionally, thecloseRealtimeHttpStream
method now explicitly closes these streams using the acquired references.A key improvement is the robust handling of the app's background state. The
setRealtimeBackgroundState
method is now synchronized to guarantee thread-safe updates and will immediately close the real-time HTTP connection when the app transitions to the background. This background state is also reflected inConfigAutoFetch
, allowing for conditional exception logging during real-time stream listening, ensuring logs are only generated when the app is actively in the foreground. Furthermore,ConfigAutoFetch
now maintains a dedicatedInputStream
reference to ensure proper stream closure, and a separate reference is kept inbeginRealtimeHttpStream
to handle potential early closure scenarios beforeConfigAutoFetch
is reached.