xamarin / GooglePlayServicesComponents

Other
315 stars 148 forks source link

xamarin.firebase.perf implementation is not showing network call from the app #172

Open akankshajain00 opened 5 years ago

akankshajain00 commented 5 years ago

Hey, I am using Xamarin.Firebase.Pref stable version 60.1142.1 in my app. So after the integration of this NuGet package firebase console is showing some default traces like app_start, app_foregroung and app_background, but it's not showing the other default traces like network calls and API calls.

I have also implemented the firebase performance monitoring NuGet package for my ios app and all the default traces for ios is working fine because I followed the instructions given in the readme for that package.

But for android as such, there are no instructions to follow and it's written on the firebase performance monitoring native integration that all the network calls will come up by default when we will integrate the SDK.

So I am not sure in the NuGet package for Android(Xamarin.Firebase.Pref)) includes the traces for network calls by default or not.

Can somebody please look into this and let me know how can I get network call traces for my android app. Any help will be highly appreciated.

VS bug #760354

akankshajain00 commented 5 years ago

Hey @Redth can you please provide me solution for this.

Redth commented 5 years ago

Make sure you're not using the default .NET managed HttpClient handler since Firebase would have no way to inspect network traffic through this handler.

See this doc for more information: https://docs.microsoft.com/en-us/xamarin/android/app-fundamentals/http-stack?tabs=windows

akankshajain00 commented 5 years ago

Hey @Redth thank you for your response. in our app we are using AndroidClientHandler for Android app and for ios we are using NSUrlSessionHandler for which network traffic is capturing fine.

moljac commented 5 years ago

@akankshajain00

Could you provide minimal sample, so I (we) can debug and investigate this issue. Namely without a sample it will take quite a lot of time to create it.

Moving this into LowPriority until the sample is created or obtained.

akankshajain00 commented 5 years ago

Okay, I will create a sample and will provide you.

moljac commented 5 years ago

Moving to low priority until sample is available.

jldubz commented 5 years ago

I am also encountering this issue. iOS firebase performance monitoring reports all of my network calls as expected, but I am receiving nothing on the Android side aside from UI draw times. I can tell you that we are using the Android HttpClient implementation.

I am happy to create a sample project to demonstrate this. What is the best way to provide you with access to the Firebase reports to show that nothing is being received from Android if they are connected to my Google account?

jldubz commented 5 years ago

I have uploaded a simple Xamarin.Android Firebase Performance Monitoring Test App for your reference. Please let me know if there is anything else that you need.

Thanks.

jldubz commented 5 years ago

I have spent the last day running the sample app to try and generate as many network calls as I can. I have snapped some screenshots of the relevant pages from Firebase and uploaded them to the GitHub repo.

Firebase Performance Dashboard Screenshot

This shows that the application is reporting to Firebase performance on the app start trace, but...

Firebase Performance Network Screenshot

This tells me that none of the network calls being made are tracked.

jldubz commented 5 years ago

I have noticed another inconsistency in the reports on another set of applications that I manage that has the Firebase Performance Monitoring package implemented in both the iOS and Android versions. The "Slow Rendering by Screen" metric is not being tracked as expected on Android, but it is tracked correctly on iOS. I have blurred the names of classes for this project for privacy reasons.

Android:

Slow Rendering by Screen - Android

iOS:

Slow Rendering by Screen - iOS

MatFillion commented 5 years ago

We're also facing this issue and our observations are exactly the same as described in this issue.

It is worth noting that Firebase's documentation states that the automatic network performance monitoring requires the application to use OkHttp3 (Reference)

Sample app with OkHttp3

If it can be of any help. I am attaching a Xamarin.Forms sample app using OkHttp3. Simply add your own googleservices json file to the project (I removed it) and make sure Build Action is googleservicesjson) To trigger the http call, click on the "Learn More" Button in the About tab. perf_okhttp.zip

Investigation steps / observations

I confirmed the SDK initialized properly via the Firebase console setup. Default startup traces are showing but network traces are not. (exactly same results as @jldubz via the dashboard screenshots) firebase_performance_logcat_enabled is set to true in debug via AssemblyInfo.cs and I don't see http logs in the logcat either. (On a native app I can see them instantly). Sample:

moljac commented 5 years ago

Related #228

moljac commented 5 years ago

used https://github.com/jldubz/Xamarin-Android-Firebase-Performance-Test/tree/master

in samples under s1 folder name (to shorten paths for windows)

DeVivres commented 3 years ago

Any update on the situation? Thank you.

GalaxiaGuy commented 3 years ago

After reading about it, I'm not sure this will work in Xamarin. It seems it uses byte code rewriting as part of the Gradle plugin to intercept calls, and I don't think that will be executed as part of a Xamarin build.

More info here: https://www.oliverbrown.me.uk/2021/09/07/solved-firebase-performance-monitoring-in-xamarin-android/