flutter / devtools

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

When you start DevTools, Network can't listen to network requests #8010

Closed laterdayi closed 1 week ago

laterdayi commented 3 weeks ago

When you start DevTools, Network can't listen to network requests

https://github.com/flutter/devtools/assets/122137647/34d8dbdc-deda-40e9-abc5-95a46b29a8db

InternetAddress is always displayed with no network requests

image


version: 1.0.41+41

environment:
  sdk: ">=3.2.3 <4.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter
  flex_color_scheme: ^7.3.1
  bot_toast: ^4.1.3
  get: ^4.6.6
  shared_preferences: ^2.2.3
  dio: ^5.4.3+1
  path_provider: ^2.1.3
  easy_refresh: ^3.3.5
  package_info_plus: ^7.0.0
  url_launcher: ^6.2.6
  flutter_native_splash: ^2.4.0
  logger: ^2.2.0
  open_filex: ^4.4.0
  android_id: ^0.3.6
  barcode_widget: ^2.0.4
  device_info_plus: ^10.1.0
  jiffy: ^6.2.1
  camera: ^0.10.5+9
  path: ^1.9.0
  cupertino_icons: ^1.0.8

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^3.0.2
  flutter_launcher_icons: ^0.13.1
  pubspec_manager: ^1.0.0
Doctor summary (to see all details, run flutter doctor -v):
[!] Flutter (Channel stable, 3.22.2, on Microsoft Windows [版本 10.0.19045.2965], locale zh-CN)
    ! Warning: `flutter` on your path resolves to E:\flutter\versions\stable\bin\flutter, which is not inside your
      current Flutter SDK checkout at E:\flutter\default. Consider adding E:\flutter\default\bin to the front of your
      path.
    ! Warning: `dart` on your path resolves to E:\flutter\versions\stable\bin\dart, which is not inside your current
      Flutter SDK checkout at E:\flutter\default. Consider adding E:\flutter\default\bin to the front of your path.
[√] Windows Version (Installed version of Windows is version 10 or higher)
[√] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.10.3)
[√] Android Studio (version 2024.1)
[√] Connected device (4 available)
[!] Network resources
    X A network error occurred while checking "https://maven.google.com/"

! Doctor found issues in 2 categories.
laterdayi commented 3 weeks ago

@CoderDake @polina-c @kenzieschmoll any update ?

kenzieschmoll commented 2 weeks ago

Can you provide a small repro that mimics how you are sending your network request? This would allow us to easily reproduce the behavior you are seeing. Thanks.

julemand101 commented 2 weeks ago

@kenzieschmoll I can reproduce the issue with a simple request like this:

import 'dart:convert';
import 'dart:io';

void main() async {
  HttpClient client = HttpClient();
  HttpClientRequest request = await client.getUrl(
    Uri.parse('https://home.archlinux.dk'),
  );
  HttpClientResponse response = await request.close();
  print(await response.transform(utf8.decoder).join());
}

And starting the program with dart run --pause-isolates-on-start --observe, go to the network tab and then click run. By doing so I get the issue where we only see the socket itself (websocket is an issue by itself as #3033) and not what we did inside the socket: image

Using DevTools version 2.34.3 with Dart SDK version: 3.4.4 (stable) (Wed Jun 12 15:54:31 2024 +0000) on "windows_x64"

julemand101 commented 2 weeks ago

Ok, something interesting to observe is that I think the HTTP logging are not immediately available but VM Service needs some time before it gets running. If I add some arbitrary delay before making the first HTTP request:

import 'dart:convert';
import 'dart:io';

void main() async {
  await Future<void>.delayed(Duration(seconds: 5)); // <-- this got added
  HttpClient client = HttpClient();

  HttpClientRequest request = await client.getUrl(
    Uri.parse('https://home.archlinux.dk'),
  );
  HttpClientResponse response = await request.close();
  print(await response.transform(utf8.decoder).join());
}

It starts working as expected: billede

EDIT 1: Talked to somebody about this and they do still have the issue even with the delay so there are definitely more to this issue.

CarLKnight6 commented 2 weeks ago

im using retrofit and im having the same issues as above. it only shows InternetAddress('some ip addreess', IPv4) instead of the exact api uri . before upgrading my flutter to the latest version, it was showing the network requests fine.

jahnli commented 2 weeks ago

same

laterdayi commented 1 week ago

Looking forward to solving it, the problem right now is very difficult for development debugging

kenzieschmoll commented 1 week ago

This is a duplicate of https://github.com/flutter/devtools/issues/3033, which is now fixed.