Skip to content

Commit

Permalink
Enable Objects tab and cleanup VM Tools screens (#4514)
Browse files Browse the repository at this point in the history
This change enables the object inspector / program explorer view under
the VM Tools tab.

This change also updates `VMInfoCard` to not use a backing `Card` to
make the UI of VM Tools views more consistent with the rest of DevTools.
  • Loading branch information
bkonyi committed Sep 26, 2022
1 parent 80f80db commit b8672b0
Show file tree
Hide file tree
Showing 7 changed files with 213 additions and 188 deletions.
Expand Up @@ -11,6 +11,7 @@ import '../../shared/common_widgets.dart';
import '../../shared/split.dart';
import '../../shared/table.dart';
import '../../shared/table_data.dart';
import '../../shared/theme.dart';
import '../profiler/cpu_profiler.dart';
import 'isolate_statistics_view_controller.dart';
import 'vm_developer_common_widgets.dart';
Expand Down Expand Up @@ -44,14 +45,12 @@ class IsolateStatisticsViewBody extends StatelessWidget {
valueListenable: controller.refreshing,
builder: (context, refreshing, _) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
RefreshButton(
onPressed: controller.refresh,
),
],
RefreshButton(
onPressed: controller.refresh,
),
const SizedBox(height: denseRowSpacing),
Flexible(
child: Column(
children: [
Expand Down Expand Up @@ -145,15 +144,19 @@ class GeneralIsolateStatisticsWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final isolate = controller.isolate;
return VMInfoCard(
title: 'General',
rowKeyValues: [
selectableTextBuilderMapEntry('Name', isolate?.name),
selectableTextBuilderMapEntry('Started at', _startTime(isolate)),
selectableTextBuilderMapEntry('Uptime', _uptime(isolate)),
selectableTextBuilderMapEntry('Root Library', isolate?.rootLib?.uri),
selectableTextBuilderMapEntry('ID', isolate?.id),
],
return OutlineDecoration(
showRight: false,
showBottom: false,
child: VMInfoCard(
title: 'General',
rowKeyValues: [
selectableTextBuilderMapEntry('Name', isolate?.name),
selectableTextBuilderMapEntry('Started at', _startTime(isolate)),
selectableTextBuilderMapEntry('Uptime', _uptime(isolate)),
selectableTextBuilderMapEntry('Root Library', isolate?.rootLib?.uri),
selectableTextBuilderMapEntry('ID', isolate?.id),
],
),
);
}
}
Expand All @@ -177,31 +180,35 @@ class IsolateMemoryStatisticsWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final isolate = controller.isolate;
return VMInfoCard(
title: 'Memory',
rowKeyValues: [
selectableTextBuilderMapEntry(
'Dart Heap',
_buildMemoryString(
isolate?.dartHeapSize,
isolate?.dartHeapCapacity,
return OutlineDecoration(
showRight: false,
showBottom: false,
child: VMInfoCard(
title: 'Memory',
rowKeyValues: [
selectableTextBuilderMapEntry(
'Dart Heap',
_buildMemoryString(
isolate?.dartHeapSize,
isolate?.dartHeapCapacity,
),
),
),
selectableTextBuilderMapEntry(
'New Space',
_buildMemoryString(
isolate?.newSpaceUsage,
isolate?.newSpaceUsage,
selectableTextBuilderMapEntry(
'New Space',
_buildMemoryString(
isolate?.newSpaceUsage,
isolate?.newSpaceUsage,
),
),
),
selectableTextBuilderMapEntry(
'Old Space',
_buildMemoryString(
isolate?.oldSpaceUsage,
isolate?.oldSpaceCapacity,
selectableTextBuilderMapEntry(
'Old Space',
_buildMemoryString(
isolate?.oldSpaceUsage,
isolate?.oldSpaceCapacity,
),
),
),
],
],
),
);
}
}
Expand All @@ -219,21 +226,24 @@ class TagStatisticsWidget extends StatelessWidget {

@override
Widget build(BuildContext context) {
return VMInfoCard(
title: 'Execution Time',
table: Flexible(
child: controller.cpuProfilerController.profilerEnabled
? FlatTable<VMTag>(
columns: columns,
data: controller.tags,
keyFactory: (VMTag tag) => ValueKey<String>(tag.name),
sortColumn: percentage,
sortDirection: SortDirection.descending,
onItemSelected: (_) => null,
)
: CpuProfilerDisabled(
controller.cpuProfilerController,
),
return OutlineDecoration(
showBottom: false,
child: VMInfoCard(
title: 'Execution Time',
table: Flexible(
child: controller.cpuProfilerController.profilerEnabled
? FlatTable<VMTag>(
columns: columns,
data: controller.tags,
keyFactory: (VMTag tag) => ValueKey<String>(tag.name),
sortColumn: percentage,
sortDirection: SortDirection.descending,
onItemSelected: (_) => null,
)
: CpuProfilerDisabled(
controller.cpuProfilerController,
),
),
),
);
}
Expand Down Expand Up @@ -356,20 +366,25 @@ class _IsolatePortsWidgetState extends State<IsolatePortsWidget> {
@override
Widget build(BuildContext context) {
final ports = widget.controller.ports;
return Column(
children: [
Flexible(
child: VMInfoCard(
title: 'Open Ports (${ports.length})',
table: Flexible(
child: Split(
axis: Axis.horizontal,
initialFractions: const [
0.3,
0.7,
],
children: [
FlatTable<InstanceRef?>(
return OutlineDecoration(
child: Split(
axis: Axis.horizontal,
initialFractions: const [
0.3,
0.7,
],
children: [
OutlineDecoration.onlyRight(
child: Column(
children: [
AreaPaneHeader(
needsTopBorder: false,
title: Text(
'Open Ports (${ports.length})',
),
),
Flexible(
child: FlatTable<InstanceRef?>(
columns: columns,
data: ports,
keyFactory: (InstanceRef? port) =>
Expand All @@ -387,15 +402,17 @@ class _IsolatePortsWidgetState extends State<IsolatePortsWidget> {
},
),
),
StackTraceViewerWidget(
stackTrace: selectedPort.value,
),
],
),
),
],
),
),
),
],
OutlineDecoration.onlyLeft(
child: StackTraceViewerWidget(
stackTrace: selectedPort.value,
),
),
],
),
);
}
}
Expand Down Expand Up @@ -423,16 +440,20 @@ class ServiceExtensionsWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
final extensions = controller.isolate?.extensionRPCs ?? [];
return VMInfoCard(
title: 'Service Extensions (${extensions.length})',
table: Flexible(
child: FlatTable<String>(
columns: columns,
data: extensions,
keyFactory: (String extension) => ValueKey<String>(extension),
sortColumn: name,
sortDirection: SortDirection.ascending,
onItemSelected: (_) => null,
return OutlineDecoration(
showBottom: false,
showLeft: false,
child: VMInfoCard(
title: 'Service Extensions (${extensions.length})',
table: Flexible(
child: FlatTable<String>(
columns: columns,
data: extensions,
keyFactory: (String extension) => ValueKey<String>(extension),
sortColumn: name,
sortDirection: SortDirection.ascending,
onItemSelected: (_) => null,
),
),
),
);
Expand Down
Expand Up @@ -44,7 +44,7 @@ class _ObjectInspectorViewState extends State<_ObjectInspectorView> {
super.didChangeDependencies();
final vmDeveloperToolsController =
Provider.of<VMDeveloperToolsController>(context);
controller = vmDeveloperToolsController.objectInspectorViewController!
controller = vmDeveloperToolsController.objectInspectorViewController
..init();
}

Expand Down
Expand Up @@ -46,12 +46,10 @@ class VMInfoCard extends StatelessWidget implements PreferredSizeWidget {
Widget build(BuildContext context) {
return SizedBox.fromSize(
size: preferredSize,
child: Card(
child: VMInfoList(
title: title,
rowKeyValues: rowKeyValues,
table: table,
),
child: VMInfoList(
title: title,
rowKeyValues: rowKeyValues,
table: table,
),
);
}
Expand Down Expand Up @@ -700,16 +698,23 @@ class VmObjectDisplayBasicLayout extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
Flexible(
child: VMInfoCard(
title: generalInfoTitle,
rowKeyValues: generalDataRows,
child: OutlineDecoration(
showLeft: false,
showTop: false,
showRight: sideCardDataRows != null,
child: VMInfoCard(
title: generalInfoTitle,
rowKeyValues: generalDataRows,
),
),
),
if (sideCardDataRows != null)
Flexible(
child: VMInfoCard(
title: sideCardTitle,
rowKeyValues: sideCardDataRows,
child: OutlineDecoration.onlyBottom(
child: VMInfoCard(
title: sideCardTitle,
rowKeyValues: sideCardDataRows,
),
),
),
],
Expand Down
Expand Up @@ -11,8 +11,7 @@ class VMDeveloperToolsController {
ValueListenable<int> get selectedIndex => _selectedIndex;
final _selectedIndex = ValueNotifier<int>(0);

final objectInspectorViewController =
displayObjectInspector ? ObjectInspectorViewController() : null;
final objectInspectorViewController = ObjectInspectorViewController();

void selectIndex(int index) {
_selectedIndex.value = index;
Expand Down
Expand Up @@ -14,8 +14,6 @@ import 'object_inspector_view.dart';
import 'vm_developer_tools_controller.dart';
import 'vm_statistics_view.dart';

bool displayObjectInspector = false;

abstract class VMDeveloperView {
const VMDeveloperView(
this.screenId, {
Expand Down Expand Up @@ -65,7 +63,7 @@ class VMDeveloperToolsScreenBody extends StatefulWidget {
static List<VMDeveloperView> views = [
const VMStatisticsView(),
const IsolateStatisticsView(),
if (displayObjectInspector) ObjectInspectorView(),
ObjectInspectorView(),
];

@override
Expand Down

0 comments on commit b8672b0

Please sign in to comment.