Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,15 @@ class NetworkController extends DevToolsScreenController
_currentNetworkRequests,
_filterAndRefreshSearchMatches,
);
autoDisposeStreamSubscription(
serviceConnection.serviceManager.isolateManager.onIsolateCreated.listen((
_,
) async {
if (_recordingNotifier.value) {
await allowedError(_enableNetworkTrafficRecordingOnAllIsolates());
}
}),
);
}

@override
Expand Down Expand Up @@ -346,13 +355,16 @@ class NetworkController extends DevToolsScreenController
]),
);

// TODO(kenz): only call these if http logging and socket profiling are not
// already enabled. Listen to service manager streams for this info.
await _enableNetworkTrafficRecordingOnAllIsolates();
await togglePolling(true);
}

/// Enables HTTP timeline logging and socket profiling on all isolates.
Future<void> _enableNetworkTrafficRecordingOnAllIsolates() async {
await [
http_service.toggleHttpRequestLogging(true),
networkService.toggleSocketProfiling(true),
].wait;
await togglePolling(true);
}

Future<void> stopRecording() async {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ class _NetworkProfilerControlsState extends State<_NetworkProfilerControls>
Expanded(
child: SearchField<NetworkController>(
searchController: controller,
searchFieldEnabled: hasRequests,
searchFieldEnabled: _recording || hasRequests,
searchFieldWidth: screenWidth <= MediaSize.xs
? defaultSearchFieldWidth
: wideSearchFieldWidth,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,21 @@ class NetworkService {
}

Future<void> clearData() async {
await updateLastSocketDataRefreshTime();
updateLastHttpDataRefreshTime();
await _clearSocketProfile();
await _clearHttpProfile();
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;
}
}
}
Comment on lines 204 to 221

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)

}
10 changes: 9 additions & 1 deletion packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ TODO: Remove this section if there are not any updates.

## Network profiler updates

TODO: Remove this section if there are not any updates.
* Fixed an issue where the Network tab would stop capturing HTTP requests after
a hot restart. -
[#9856](https://github.com/flutter/devtools/pull/9856)
* Fixed an issue where the Network tab would stop capturing new HTTP requests
after pressing Clear while recording. -
[#9856](https://github.com/flutter/devtools/pull/9856)
* Fixed an issue where the Network tab search field was disabled after pressing
Clear while recording. -
[#9856](https://github.com/flutter/devtools/pull/9856)

## Logging updates

Expand Down
Loading