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

Slow on web? #964

Closed
fischerscode opened this issue Oct 18, 2020 · 15 comments
Closed

Slow on web? #964

fischerscode opened this issue Oct 18, 2020 · 15 comments

Comments

@fischerscode
Copy link

I've noticed that dio seems to be about 9 times slower then http when fetching 1mb of data on web.
That seems weird to me. Am I doing something wrong?

// activate the download here: https://www.speedtestx.de/
import 'package:dio/dio.dart' as dio;
import 'package:http/http.dart' as http;

void main() async {

  await getHttp();
  await getDio();
}

Future<void> getDio() async {
  DateTime start = DateTime.now();
  try {
    await dio.Dio().get("https://www.speedtestx.de/testfiles/data_1mb.test");
    print("Dio: ${DateTime.now().difference(start)}");
  } catch (e) {
    print(e);
  }
}

Future<void> getHttp() async{
  DateTime start = DateTime.now();
  try {
    await http.get("https://www.speedtestx.de/testfiles/data_1mb.test");
    print("Http: ${DateTime.now().difference(start)}");
  } catch (e) {
    print(e);
  }
}

Output:

Http: 0:00:00.490000
Dio: 0:00:04.583000

I am using dio 3.0.10 and dart 2.11.0-213.1.beta (beta).

@peterlauri
Copy link

We also experience the same problem.

@LucaIaconelli
Copy link

Is there any news about it?

@peterlauri
Copy link

Is there any news about it?

We migrated away to use basic http.Client provided by Flutter/Dart.

@LucaIaconelli
Copy link

With http provided by Flutter/Dart, how do you set up withCredentials variable in BrowserClient?

@peterlauri
Copy link

With http provided by Flutter/Dart, how do you set up withCredentials variable in BrowserClient?

Our app uses JWT authentication, so we just use plain headers for doing that. 

http.get(url, headers={'Authorization': 'JWT $token'})

@LucaIaconelli
Copy link

But unfortunately, this doesn't solve my problem using Cookies

@LucaIaconelli
Copy link

There is no plan to update this library for solving this problem? @wendux

Thanks in advance

@stale
Copy link

stale bot commented Dec 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, please make sure it is up to date and if so, add a comment that this is still an issue to keep it open. Thank you for your contributions.

@stale stale bot added the stale label Dec 24, 2020
@stale stale bot closed this as completed Dec 31, 2020
@nstrelow
Copy link

nstrelow commented Apr 6, 2021

Is dio still slow on web?

@coduy96
Copy link

coduy96 commented May 19, 2021

Is dio still slow on web?

yes

@woprandi
Copy link

Few seconds before uploading a file...

@amirmhmdi
Copy link

I'm on flutter 2.2.2 and every thing okay on android and iOS ! but on web is so slow.
I used dio 3.0.0 and dio 4.0.0 but it took about 3 sec to fetch data but when I use http.get it take about 100ms .
any update ?

@intraector
Copy link

same problem

@jgoyvaerts
Copy link
Contributor

This issue has been fixed on our fork of dio, dio_http.

Package is available here: https://pub.dev/packages/dio_http

@tomekit
Copy link

tomekit commented Apr 9, 2024

Nowadays with Flutter: 3.19.5 and

http: ^1.2.1
dio: ^5.4.2+1

I find them both unacceptably slow on Web, however on desktop or mobile it is just fine.

flutter/flutter#146494

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants