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

Bad performance while using OData client vs using HttpClient on Android #23185

Closed
marcmognol opened this issue Jun 21, 2024 · 8 comments
Closed
Labels
platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working

Comments

@marcmognol
Copy link
Contributor

Description

I'm in the process to develop an application for my company. This application will connect to OData endpoints.
To achieve my goal, I followed the Microsoft documentation https://learn.microsoft.com/en-us/odata/client/getting-started to connect my project to our OData endpoint.

But, I'm experiencing very bad performance while using the application, even in Release mode.

I've got the idea to use classic HttpClient to compare the performance, and HttpClient is 2x faster than OData client.

Steps to Reproduce

  1. Clone the reproduction project repository
  2. Run the application with Android emulator
  3. Click on HttpClient button (multiple times)
  4. Click on ODATA button (multiple times)
  5. Compare request response time

See example :
image

The behavior is same on physical device.

Link to public reproduction project repository

https://github.com/marcmognol/Maui.OData.PerformanceIssue/

Version with bug

8.0.60 SR6

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Android

Affected platform versions

No response

Did you find any workaround?

Yes, by using HttpClient, but proxy generated class with OData generator seems to be easier as we manage thousands of entities.

Relevant log output

No response

@marcmognol marcmognol added the t/bug Something isn't working label Jun 21, 2024
@albyrock87
Copy link
Contributor

Try to use SocketsHttpHandler instead of the default handler.

@marcmognol
Copy link
Contributor Author

Hi @albyrock87

Thank you for your quick reply and your suggestion but I do have the same result.

Below the way I configured the handler:

        builder
            .UseMauiApp<App>()
            .ConfigureFonts(fonts =>
            {
                fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
            })
            .Services.AddODataClient("TripPin")
                     .ConfigureODataClient(dsc =>
                     {
                         dsc.BaseUri = new Uri("https://services.odata.org/V4/TripPinServiceRW/");
                     })
                     .AddHttpClient()
                     .ConfigurePrimaryHttpMessageHandler(sp =>
                     {
                         var handler = new SocketsHttpHandler();
                    
                         return handler;
                     })
                     .Services.AddTransient<MyODataRepository>();

@drasticactions
Copy link
Contributor

drasticactions commented Jun 23, 2024

I don't believe your issue has to do with the MAUI UI framework. It's either a dotnet runtime issue on Android, or an OData issue. The MAUI UI framework wouldn't affect the underlying connection like that. If you want to verify that, try running that code within a .NET Android app (dotnet new android) that doesn't implement the MAUI UI framework. If the performance is still bad, then it's highly unlikely the UI framework is at fault.

@jonathanpeppers Do you know where this should go?

@marcmognol
Copy link
Contributor Author

I even tried with Simple.OData.Client library and same bad performance.

image

@RoiChen001 RoiChen001 added s/verified Verified / Reproducible Issue ready for Engineering Triage s/triaged Issue has been reviewed labels Jun 24, 2024
@RoiChen001
Copy link
Collaborator

I can repro this issue at Android API 30 on the latest 17.11.0 Preview 2.1 (8.0.60).

@drasticactions
Copy link
Contributor

I even tried with Simple.OData.Client library and same bad performance.

Again, I don't doubt you have performance issues. The problem is that I don't believe your issue is specific to the MAUI UI project. This repo is for the cross-platform MAUI UI framework, and I think your issue is specific to the dotnet runtime or OData itself running on Android, both of which can't be addressed here. That's why verifying if it fails outside of the MAUI UI framework (Ex. Building a .NET Android app dotnet new android) is important.

@jonathanpeppers
Copy link
Member

If using HttpClient is fast, but using this library isn't:

^^ Seems like you should file an issue here instead? Doesn't seem like this is a .NET MAUI issue?

You could also profile and see exactly what method is responsible for the slowdown:

@PureWeen
Copy link
Member

If using HttpClient is fast, but using this library isn't:

^^ Seems like you should file an issue here instead? Doesn't seem like this is a .NET MAUI issue?

You could also profile and see exactly what method is responsible for the slowdown:

Closing based on recommendation here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform/android 🤖 s/triaged Issue has been reviewed s/verified Verified / Reproducible Issue ready for Engineering Triage t/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants