-
Notifications
You must be signed in to change notification settings - Fork 615
openStream should not be intercepted if Firebase Perf is not initialized #5885
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
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Release note changesThe following release notes were modified. Please ensure they look correct. Release Notesfirebase-perf### {{perfmon}} version 21.0.0 {: #performance_v21-0-0}
[fixed] Fixed an `ExceptionInInitializerError` where the `url.openStream()` causes a crash if
FirebasePerf is not yet initialized.
#### {{perfmon}} Kotlin extensions version 21.0.0 {: #performance-ktx_v21-0-0}
The Kotlin extensions library transitively includes the updated
`firebase-performance` library. The Kotlin extensions library has no additional
updates. |
Coverage Report 1Affected Products
Test Logs |
Size Report 1Affected ProductsTest Logs |
Startup Time Report 1Note: Layout is sometimes suboptimal due to limited formatting support on GitHub. Please check this report on GCS. Notes
Startup Times
|
visumickey
approved these changes
Apr 30, 2024
rlazo
pushed a commit
that referenced
this pull request
May 2, 2024
…zed (#5885) Proposed fix for #5584: ### Issue Crash happens if a URL connection is opened e.g. `url.openStream()` when `TransportManager` has not been initialized. If developer wants to programmatically enable Firebase using FirebaseOptions, but have included the Firebase Perf plugin, the app will crash after doing a network call. ### Steps to reproduce 1. Add Firebase perf plugin - Module `build.gradle` ``` plugins { alias(libs.plugins.android.application) apply false alias(libs.plugins.jetbrains.kotlin.android) apply false id("com.google.gms.google-services") version "4.4.1" apply false id("com.google.firebase.firebase-perf") version "1.4.2" apply false } ``` - App `build.gradle` ``` plugins { alias(libs.plugins.android.application) alias(libs.plugins.jetbrains.kotlin.android) id("com.google.gms.google-services") id("com.google.firebase.firebase-perf") } ``` 2. Disable Firebase ```xml <provider android:name="com.google.firebase.provider.FirebaseInitProvider" android:authorities="${applicationId}.firebaseinitprovider" tools:node="remove" /> ``` 3. Do a network call ``` val url = URL("https", "www.amazon.com", 443, "") val inputStream = url.openStream() ``` ### Investigation 1. `openStream` in `FirebasePerfUrlConnection` intercepts all urls that opens connections. 5. `openStream` requires `TransportManager` to be initialized 6. `TransportManager` is only initialized after `FirebasePerformance` has been initialized ### Solution If `TransportManager` is not initialized, we should simply return the URL openStream and not intercept the connection.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed fix for #5584:
Issue
Crash happens if a URL connection is opened e.g.
url.openStream()
whenTransportManager
has not been initialized. If developer wants to programmatically enable Firebase using FirebaseOptions, but have included the Firebase Perf plugin, the app will crash after doing a network call.Steps to reproduce
build.gradle
build.gradle
Investigation
openStream
inFirebasePerfUrlConnection
intercepts all urls that opens connections.openStream
requiresTransportManager
to be initializedTransportManager
is only initialized afterFirebasePerformance
has been initializedSolution
If
TransportManager
is not initialized, we should simply return the URL openStream and not intercept the connection.