-
Notifications
You must be signed in to change notification settings - Fork 578
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
Initializing the SDK programmatically by using FirebaseOptions cause crash when call URLConnection.getInputStream() #5584
Comments
I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight. |
Hi @argzdev, could you see this issue please. |
Hey @yin-haoran, thanks for bringing this up. I was also able to exhibit the same behavior. I tried following our documentation on disabling the performance monitoring library, but this doesn't seem to work when Firebase is initialized programmatically. <meta-data
android:name="firebase_performance_collection_enabled"
android:value="false" /> Let me reach out to our engineering team and see what we can do here. |
Hi @argzdev , is there any progress now? |
…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.
…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.
Hi @yin-haoran, the fix for this issue has been released in BOM version 33.1.0. I'll be closing this issue now. If you run into any other problems please open a new issue. Thank you for patience! |
Calling
URLConnection.getInputStream()
beforeFirebaseApp.initializeApp()
will lead crash. Maybe due to theBytecode instrumented functions
com.google.firebase.perf.network.FirebasePerfUrlConnection#openStream(java.net.URL)
.stack info as follow:
I provide a example of this issue.
The text was updated successfully, but these errors were encountered: