flutter / devtools

Performance tools for Flutter
https://flutter.dev/docs/development/tools/devtools/
BSD 3-Clause "New" or "Revised" License
1.6k stars 329 forks source link

Flutter devtools could not preview http request when debug in remote android device #8305

Open StitchC opened 2 months ago

StitchC commented 2 months ago

Steps to reproduce

  1. Flutter run on a remote machine connect with usb
  2. Open devtool in Android Studio
  3. Select network tab and preview
  4. The network show all request type is socket not http request

Expected results

  1. show http requset header, body and response like use simulator

Actual results

all http request display type is "socket"

image

Code sample

Code sample ```dart [Paste your code here] ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs ```console [Paste your logs here] ```

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.24.1, on macOS 14.6 23G80 darwin-arm64 (Rosetta), locale zh-Hans-CN) • Flutter version 3.24.1 on channel stable at /Users/chenrunsheng/Documents/flutter_sdk_collection/versions/3.24.1 • Upstream repository https://github.com/flutter/flutter.git • Framework revision 5874a72aa4 (2 周前), 2024-08-20 16:46:00 -0500 • Engine revision c9b9d5780d • Dart version 3.5.1 • DevTools version 2.37.2 [✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0) • Android SDK at /Users/chenrunsheng/Library/Android/sdk • Platform android-34, build-tools 35.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314) • All Android licenses accepted. [!] Xcode - develop for iOS and macOS (Xcode 15.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15F31d ! CocoaPods 1.11.3 out of date (1.13.0 is recommended). CocoaPods is a package manager for iOS or macOS platform code. Without CocoaPods, plugins will not work on iOS or macOS. For more info, see https://flutter.dev/to/platform-plugins To update CocoaPods, see https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2024.1) • 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 17.0.11+0-17.0.11b1207.24-11852314) [✓] VS Code (version 1.76.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension can be installed from: 🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [!] Proxy Configuration • HTTP_PROXY is set ! NO_PROXY is not set [✓] Connected device (4 available) • TC26 (mobile) • 22185523023281 • android-arm64 • Android 11 (API 30) • macOS (desktop) • macos • darwin-arm64 • macOS 14.6 23G80 darwin-arm64 (Rosetta) • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin • macOS 14.6 23G80 darwin-arm64 (Rosetta) • Chrome (web) • chrome • web-javascript • Google Chrome 128.0.6613.120 [!] Network resources ✗ A network error occurred while checking "https://pub.dev/": Connection reset by peer ! Doctor found issues in 3 categories. ```
elliette commented 2 months ago

@bkonyi I know you recently made some fixes to the Network page. Is this what we expect to be seeing here? Thanks!

bkonyi commented 2 months ago

@darshankawar are you using package:http or dart:io's HttpClient to make your requests? If not, they're not available through the network profiler.

LiamMarega commented 1 month ago

I have the same problem, i am use 'package:dio/dio.dart' And i try using dart:io's HttpClient but the error persist

tuannvm2109 commented 1 month ago

Same issue using dio package, any help ?

StitchC commented 1 month ago

https://github.com/flutter/devtools/issues/8380#issuecomment-2393929155 @bkonyi I saw this reply, do you mean it's a dependency library issue rather than a devtool issue?

LiamMarega commented 1 month ago

I was trying both with package:http and dart:io and my problem is not solved

bkonyi commented 1 month ago

#8380 (comment) @bkonyi I saw this reply, do you mean it's a dependency library issue rather than a devtool issue?

Potentially. package:http definitely works, and so does dart:io, but I'm not sure about package:dio. All of the HTTP libraries listed here will also work.

All of the HTTP logging functionality is currently built on dart:io's HttpClient, so if you're using an HTTP library that doesn't use HttpClient as the HTTP client, you might only see SOCKET events in the profiler if the HTTP library is using dart:io's Socket to make the HTTP connect. If the HTTP library is using FFI and doesn't use package:http_profile to provide profiling details, those requests won't be available to DevTools either.

If you set HttpClient.enableTimelineLogging to true as the first line in main(), HTTP profiling will be enabled before any HTTP requests are made by your program and DevTools should be able to display them if they're being made through HttpClient. If you're still not seeing requests, we really need a small reproduction test case for us to be able to properly debug this.

mithun-itspe commented 1 month ago

@bkonyi tried with http package still its not working and HttpClient.enableTimelineLogging to true as the first line of main().

The testing was done in counter app please check screenshots. Screenshot from 2024-10-25 16-38-39 Screenshot from 2024-10-25 16-38-31 Screenshot from 2024-10-25 16-38-13 Screenshot from 2024-10-25 16-38-04