Skip to content
Merged
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 @@ -208,7 +208,7 @@ class DevToolsScaffoldState extends State<DevToolsScaffold>
);

// Clear error count when navigating to a screen.
serviceConnection.errorBadgeManager.clearErrors(screen.screenId);
serviceConnection.errorBadgeManager.clearErrorCount(screen.screenId);

// Update routing with the change.
WidgetsBinding.instance.addPostFrameCallback((timeStamp) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class InspectorController extends DisposableController
// TODO(kenz): When this method is called outside createState(), this post
// frame callback can be removed.
WidgetsBinding.instance.addPostFrameCallback((_) {
serviceConnection.errorBadgeManager.clearErrors(InspectorScreen.id);
serviceConnection.errorBadgeManager.clearErrorCount(InspectorScreen.id);
});
filterErrors();
}
Expand Down Expand Up @@ -761,7 +761,7 @@ class InspectorController extends DisposableController
// the inspector was visible (normally they're cleared when visiting
// the screen) and visiting an errored node seems an appropriate
// acknowledgement of the errors.
serviceConnection.errorBadgeManager.clearErrors(InspectorScreen.id);
serviceConnection.errorBadgeManager.clearErrorCount(InspectorScreen.id);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class InspectorController extends DisposableController
// TODO(kenz): When this method is called outside createState(), this post
// frame callback can be removed.
WidgetsBinding.instance.addPostFrameCallback((_) {
serviceConnection.errorBadgeManager.clearErrors(InspectorScreen.id);
serviceConnection.errorBadgeManager.clearErrorCount(InspectorScreen.id);
});
filterErrors();
}
Expand Down Expand Up @@ -474,6 +474,7 @@ class InspectorController extends DisposableController
}

if (event.kind == EventKind.kIsolateReload) {
serviceConnection.errorBadgeManager.clearErrors(InspectorScreen.id);
_receivedIsolateReloadEvent = true;
}
}
Expand Down Expand Up @@ -989,7 +990,7 @@ class InspectorController extends DisposableController
// the inspector was visible (normally they're cleared when visiting
// the screen) and visiting an errored node seems an appropriate
// acknowledgement of the errors.
serviceConnection.errorBadgeManager.clearErrors(InspectorScreen.id);
serviceConnection.errorBadgeManager.clearErrorCount(InspectorScreen.id);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ class LoggingController extends DevToolsScreenController

void clear() {
_updateData([]);
serviceConnection.errorBadgeManager.clearErrors(LoggingScreen.id);
serviceConnection.errorBadgeManager.clearErrorCount(LoggingScreen.id);
}

void _handleConnectionStart(VmServiceWrapper service) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ class NetworkController extends DevToolsScreenController
@override
void filterData(Filter<NetworkRequest> filter) {
super.filterData(filter);
serviceConnection.errorBadgeManager.clearErrors(NetworkScreen.id);
serviceConnection.errorBadgeManager.clearErrorCount(NetworkScreen.id);
final queryFilter = filter.queryFilter;
if (queryFilter.isEmpty) {
_currentNetworkRequests.value.forEach(_checkForError);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class PerformanceController extends DevToolsScreenController
await serviceConnection.serviceManager.service!.clearVMTimeline();
}
offlinePerformanceData = null;
serviceConnection.errorBadgeManager.clearErrors(PerformanceScreen.id);
serviceConnection.errorBadgeManager.clearErrorCount(PerformanceScreen.id);
await _applyToFeatureControllersAsync((c) => c.clearData(partial: partial));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import '../primitives/query_parameters.dart';

class ErrorBadgeManager extends DisposableController
with AutoDisposeControllerMixin {
// TODO(https://github.com/flutter/devtools/issues/9105): Separate out
// Inspector-specific logic from this file.
final _activeErrorCounts = <String, ValueNotifier<int>>{
InspectorScreen.id: ValueNotifier<int>(0),
PerformanceScreen.id: ValueNotifier<int>(0),
Expand Down Expand Up @@ -71,8 +73,9 @@ class ErrorBadgeManager extends DisposableController
}

InspectableWidgetError? _extractInspectableError(Event error) {
// TODO(dantup): Switch to using the inspectorService from the serviceManager
// once Jacob's change to add it lands.
// TODO(https://github.com/flutter/devtools/issues/9105): Switch to using
// the inspectorService from the serviceManager once Jacob's change to add
// it lands.
final node = RemoteDiagnosticsNode(
error.extensionData!.data,
null,
Expand Down Expand Up @@ -146,10 +149,15 @@ class ErrorBadgeManager extends DisposableController
return _activeErrorCounts[screenId];
}

void clearErrors(String screenId) {
void clearErrorCount(String screenId) {
_activeErrorCounts[screenId]?.value = 0;
}

void clearErrors(String screenId) {
clearErrorCount(screenId);
_activeErrors[screenId]?.value = LinkedHashMap<String, DevToolsError>();
}

void filterErrors(String screenId, bool Function(String id) isValid) {
final errors = _activeErrors[screenId];
if (errors == null) return;
Expand Down
4 changes: 3 additions & 1 deletion packages/devtools_app/release_notes/NEXT_RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ pausing on breakpoint on connection. -

## Inspector updates

TODO: Remove this section if there are not any general updates.
* Fixed bug where errors in the inspector tree (e.g. RenderFlex overflow
errors) were not removed after a hot-reload. -
[#9106](https://github.com/flutter/devtools/pull/9106)

## Performance updates

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ void main() {
late ErrorBadgeManager errorBadgeManager;

group('ErrorBadgeManager', () {
int getActiveErrorCount(screenId) =>
errorBadgeManager.erroredItemsForPage(screenId).value.entries.length;

setUp(() {
errorBadgeManager = ErrorBadgeManager();
});
Expand All @@ -60,7 +63,7 @@ void main() {
}
});

test('clearErrors resets counts', () {
test('clearErrorCount resets counts', () {
allScreenIds.forEach(errorBadgeManager.incrementBadgeCount);

for (final id in allScreenIds) {
Expand All @@ -71,11 +74,55 @@ void main() {
}
}

allScreenIds.forEach(errorBadgeManager.clearErrors);
allScreenIds.forEach(errorBadgeManager.clearErrorCount);

for (final id in allScreenIds) {
expect(errorBadgeManager.errorCountNotifier(id).value, equals(0));
}
});

// TODO(https://github.com/flutter/devtools/issues/9105): This logic should
// be moved to the inspector.
test('appendError works for inspector screen only', () {
for (final id in allScreenIds) {
errorBadgeManager.appendError(id, DevToolsError('An error', id));
}

for (final id in allScreenIds) {
if (id == InspectorScreen.id) {
expect(getActiveErrorCount(id), equals(1));
} else {
expect(getActiveErrorCount(id), equals(0));
}
}
});

test('clearErrors resets counts and removes errors', () {
expect(getActiveErrorCount(InspectorScreen.id), equals(0));
expect(
errorBadgeManager.errorCountNotifier(InspectorScreen.id).value,
equals(0),
);

errorBadgeManager.appendError(
InspectorScreen.id,
DevToolsError('An error', InspectorScreen.id),
);
errorBadgeManager.incrementBadgeCount(InspectorScreen.id);

expect(getActiveErrorCount(InspectorScreen.id), equals(1));
expect(
errorBadgeManager.errorCountNotifier(InspectorScreen.id).value,
equals(1),
);

errorBadgeManager.clearErrors(InspectorScreen.id);

expect(getActiveErrorCount(InspectorScreen.id), equals(0));
expect(
errorBadgeManager.errorCountNotifier(InspectorScreen.id).value,
equals(0),
);
});
});
}