dio icon indicating copy to clipboard operation
dio copied to clipboard

Poor performance on download with `dio_http2_adapter`

Open Vovcharaa opened this issue 2 years ago • 6 comments

Package

dio_http2_adapter

Version

2.2.0

Output of flutter doctor -v

[✓] Flutter (Channel stable, 3.10.2, on macOS 13.4 22F66 darwin-arm64, locale en-UA)
    • Flutter version 3.10.2 on channel stable at /Users/vovchara/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 9cd3d0d9ff (8 days ago), 2023-05-23 20:57:28 -0700
    • Engine revision 90fa3ae28f
    • Dart version 3.0.2
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /Users/vovchara/Library/Android/sdk
    • Platform android-33, build-tools 33.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E222b
    • CocoaPods version 1.11.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.13+0-b1751.21-8125866)

[✓] VS Code (version 1.78.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.64.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 13.4 22F66 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 114.0.5735.90

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Dart Version

3.0.2

Steps to Reproduce

  1. Create a Dio client with Http2Adapter
  2. Try to download any file with this client. (in my case, I used the download method)

Expected Result

Download speed at least matches the client with IOHttpClientAdapter

Actual Result

Download speed is much lower than a client with IOHttpClientAdapter

Vovcharaa avatar Jun 01 '23 12:06 Vovcharaa

Http2Adapter: download() executed in 0:00:10.798213 on size 16256346 IOHttpClientAdapter: download() executed in 0:00:05.080164 on size 16256346 CupertinoAdapter: download() executed in 0:00:05.466801 on size 16256346

Vovcharaa avatar Jun 01 '23 12:06 Vovcharaa

Can you try with http2 standalone and see if it gets the same result? If so, that would be an upstream issue.

AlexV525 avatar Jul 16 '23 09:07 AlexV525

@Vovcharaa Got any results about the above suggestion?

AlexV525 avatar Aug 21 '23 07:08 AlexV525

Maybe relevant? => https://github.com/dart-lang/http2/issues/69#issuecomment-1205017038

mdmm13 avatar Oct 03 '23 15:10 mdmm13

Maybe relevant? => dart-lang/http2#69 (comment)

The comment referenced the code: https://github.com/cfug/dio/blob/bedcc54c91a800a3b1aac0092151ca401f716803/plugins/http2_adapter/lib/src/http2_adapter.dart#L75 I didn't find any relevant connection about "sending data messages with 1 byte inside". cc @Neronse Also, it's related to sending, not receiving.

If anyone has any ideas about buffers, bytes, and stream configurations, we'd love to hear about them and take investigations. We're also tracking the download buffer issue in #1990 and feedback is also welcomed.

AlexV525 avatar Nov 14 '23 14:11 AlexV525

~~Yea there is something wrong here. dio.download('/foo') takes twice as long as dio.get('/foo', options: Options(responseType: responseType: ResponseType.stream). I personally have not looked at the Http2Adapter before today or used it, but a lot of things look messy there.~~

Nvm, I am stupid.

kuhnroyal avatar Nov 14 '23 22:11 kuhnroyal

Could everyone meeting the issue try to verify again using the latest Flutter SDK?

AlexV525 avatar Mar 18 '24 07:03 AlexV525

Closing as the issue is likely solved from the Dart side. Please submit new issues with reproducible cases.

AlexV525 avatar May 02 '24 17:05 AlexV525