Skip to content

Fix Network tab not capturing requests after hot restart and clear#9856

Open
muhammadkamel wants to merge 4 commits into
flutter:masterfrom
muhammadkamel:fix/network-hot-restart
Open

Fix Network tab not capturing requests after hot restart and clear#9856
muhammadkamel wants to merge 4 commits into
flutter:masterfrom
muhammadkamel:fix/network-hot-restart

Conversation

@muhammadkamel

@muhammadkamel muhammadkamel commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Re-enable HTTP timeline logging and socket profiling on new isolates by listening to IsolateManager.onIsolateCreated, fixing the Network tab freeze after hot restart (#9783, #9839).
  • Reset HTTP and socket refresh timestamps using the VM timeline when Clear is pressed, so new requests continue to appear after clearing while recording.
  • Keep the Network tab search field enabled while recording or when requests are visible, including after Clear and while paused (#9853).
  • Expose IsolateManager.onIsolateCreated in devtools_app_shared for isolate lifecycle detection.
  • Add unit and widget tests covering hot restart, clear, and combined lifecycle scenarios.

Test plan

  • flutter test test/screens/network/network_hot_restart_test.dart
  • flutter test test/screens/network/network_clear_test.dart
  • flutter test test/screens/network/network_profiler_test.dart
  • ./tool/bin/dt presubmit --fix
  • Manually verified on Android emulator (Flutter App Project): reproduced with SDK DevTools, fixed with locally built DevTools from this branch

Re-enable HTTP logging and socket profiling when new isolates are spawned,
reset clear timestamps using the VM timeline, and keep the search field
enabled while recording.
@google-cla

google-cla Bot commented Jun 15, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses issues in the Network profiler where capturing stopped after a hot restart or after clearing recorded data, and introduces an onIsolateCreated stream to detect new isolates. The review feedback highlights a regression where the search field is disabled when recording is paused (even if requests exist), and suggests wrapping asynchronous VM service calls in error-handling blocks to prevent unhandled RPCErrors.

child: SearchField<NetworkController>(
searchController: controller,
searchFieldEnabled: hasRequests,
searchFieldEnabled: _recording,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

[MUST-FIX] Disabling the search field when _recording is false will prevent users from searching through captured requests when recording is paused. To fix this regression while still keeping the search field enabled when the list is cleared during active recording, the search field should be enabled if recording is active OR if there are existing requests in the list.

Suggested change
searchFieldEnabled: _recording,
searchFieldEnabled: _recording || controller.filteredData.value.isNotEmpty,
References
  1. Categorize Severity: Prefix every comment with a severity: [MUST-FIX] for logical bugs. (link)

_,
) async {
if (_recordingNotifier.value) {
await _enableNetworkTrafficRecordingOnAllIsolates();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

[CONCERN] Wrap the call to _enableNetworkTrafficRecordingOnAllIsolates() in allowedError to safely handle any potential RPCErrors that might occur if the newly created isolate is quickly destroyed or if the connection is lost during the asynchronous operation.

Suggested change
await _enableNetworkTrafficRecordingOnAllIsolates();
await allowedError(_enableNetworkTrafficRecordingOnAllIsolates());
References
  1. Categorize Severity: Prefix every comment with a severity: [CONCERN] for robustness/maintainability issues. (link)

Comment on lines 204 to 215
Future<void> clearData() async {
await updateLastSocketDataRefreshTime();
updateLastHttpDataRefreshTime();
final service = serviceConnection.serviceManager.service;
if (service == null) return;

final timestamp = (await service.getVMTimelineMicros()).timestamp!;
networkController.lastSocketDataRefreshMicros = timestamp;
await service.forEachIsolate((isolate) async {
lastHttpDataRefreshTimePerIsolate[isolate.id!] = timestamp;
});
await _clearSocketProfile();
await _clearHttpProfile();
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

[CONCERN] Wrap the VM service calls in clearData() in a try-catch block for RPCError to prevent unhandled exceptions (and potential UI crashes) if the connection is lost or the service is disposed while clearing data.

  Future<void> clearData() async {
    final service = serviceConnection.serviceManager.service;
    if (service == null) return;

    try {
      final timestamp = (await service.getVMTimelineMicros()).timestamp!;
      networkController.lastSocketDataRefreshMicros = timestamp;
      await service.forEachIsolate((isolate) async {
        lastHttpDataRefreshTimePerIsolate[isolate.id!] = timestamp;
      });
      await _clearSocketProfile();
      await _clearHttpProfile();
    } on RPCError catch (e) {
      if (!e.isServiceDisposedError) {
        rethrow;
      }
    }
  }
References
  1. Categorize Severity: Prefix every comment with a severity: [CONCERN] for robustness/maintainability issues. (link)

@muhammadkamel muhammadkamel force-pushed the fix/network-hot-restart branch from 19e96b7 to 043132a Compare June 15, 2026 07:59
@muhammadkamel muhammadkamel force-pushed the fix/network-hot-restart branch from 4a1a518 to a082ddb Compare June 15, 2026 08:06
Keep search enabled when paused with visible requests, handle RPC errors
during clear, and wrap isolate profiling re-enable in allowedError.
@muhammadkamel muhammadkamel force-pushed the fix/network-hot-restart branch 2 times, most recently from 74fc05b to 7d34604 Compare June 15, 2026 08:07
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

Successfully merging this pull request may close these issues.

1 participant