Skip to content

Add details to diff. #4549

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 64 commits into from
Oct 6, 2022
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
0ce0fb5
-
polina-c Sep 29, 2022
619923f
-
polina-c Sep 29, 2022
2540916
-
polina-c Sep 29, 2022
01df4b2
Update memory_hover_card.png
polina-c Sep 29, 2022
111649e
Update memory_heap_android.png
polina-c Sep 29, 2022
91acf65
-
polina-c Sep 30, 2022
e5fe847
-
polina-c Sep 30, 2022
a24171d
-
polina-c Sep 30, 2022
4694120
-
polina-c Sep 30, 2022
dc0042f
-
polina-c Sep 30, 2022
c41b6a8
-
polina-c Sep 30, 2022
e10e68a
-
polina-c Sep 30, 2022
ab0b72f
Merge branch 'master' of github.com:flutter/devtools into details-1
polina-c Sep 30, 2022
1f8162a
-
polina-c Sep 30, 2022
ad67da0
-
polina-c Sep 30, 2022
7835150
Update pathes.dart
polina-c Sep 30, 2022
4ce9eaa
Update pathes.dart
polina-c Sep 30, 2022
180136d
Merge branch 'master' of github.com:flutter/devtools into details-1
polina-c Oct 1, 2022
ff93455
-
polina-c Oct 1, 2022
62f2813
Update pubspec.yaml
polina-c Oct 3, 2022
56ca3d9
Merge branch 'fix' into details-1
polina-c Oct 3, 2022
b03c4d6
Merge branch 'master' of github.com:flutter/devtools into details-1
polina-c Oct 3, 2022
cf47dd1
Update network_request_inspector_test.dart
polina-c Oct 3, 2022
2d52254
Update README.md
polina-c Oct 3, 2022
a925da2
-
polina-c Oct 3, 2022
60fd134
-
polina-c Oct 3, 2022
cae9f4e
-
polina-c Oct 3, 2022
d5c59f1
Merge branch 'details-1' of github.com:polina-c/devtools; branch 'mas…
polina-c Oct 4, 2022
42cd090
-
polina-c Oct 4, 2022
7e55239
1
polina-c Oct 4, 2022
7841329
-
polina-c Oct 4, 2022
c6e052c
-
polina-c Oct 4, 2022
8abe781
Update classes_table_diff.dart
polina-c Oct 4, 2022
c4116ff
-
polina-c Oct 4, 2022
53f9a11
-
polina-c Oct 4, 2022
b516ee4
-
polina-c Oct 4, 2022
e1b983d
-
polina-c Oct 4, 2022
f42f7d0
-
polina-c Oct 4, 2022
ce030c6
-
polina-c Oct 4, 2022
78ed4bd
Update diff_pane_controller.dart
polina-c Oct 5, 2022
5f99add
-
polina-c Oct 5, 2022
d4a7d0d
-
polina-c Oct 5, 2022
e10fe7e
Update diff_pane_controller.dart
polina-c Oct 5, 2022
49416bb
-
polina-c Oct 5, 2022
3e11144
Update enhance_tracing.dart
polina-c Oct 5, 2022
dfa65a3
-
polina-c Oct 5, 2022
054d49c
Merge remote-tracking branch 'upstream' into details-1
polina-c Oct 5, 2022
e57e774
Update heap.dart
polina-c Oct 5, 2022
33af7e2
-
polina-c Oct 5, 2022
e82f0fb
-
polina-c Oct 5, 2022
b0edb6b
Update snapshot_control_pane.dart
polina-c Oct 5, 2022
f361f95
-
polina-c Oct 5, 2022
3314ac2
Update snapshot_control_pane.dart
polina-c Oct 5, 2022
52e5089
Update heap.dart
polina-c Oct 5, 2022
dd60109
Update utils_test.dart
polina-c Oct 5, 2022
06c3189
-
polina-c Oct 5, 2022
d3066da
Update riverpod_error_logger_observer.dart
polina-c Oct 5, 2022
681a634
Update .gitignore
polina-c Oct 5, 2022
ee38e69
-
polina-c Oct 5, 2022
6527fce
-
polina-c Oct 5, 2022
0742aae
-
polina-c Oct 6, 2022
4044422
Update snapshot_control_pane.dart
polina-c Oct 6, 2022
5338a69
Update .gitignore
polina-c Oct 6, 2022
da127cb
Update memory_diff_three_snapshots.png
polina-c Oct 6, 2022
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
26 changes: 26 additions & 0 deletions packages/devtools_app/lib/src/primitives/utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1501,3 +1501,29 @@ bool isPrimativeInstanceKind(String? kind) {
/// Returns the file name from a URI or path string, by splitting the [uri] at
/// the directory separators '/', and returning the last element.
String? fileNameFromUri(String? uri) => uri?.split('/').last;

/// Calculates subtraction of two maps.
///
/// Result map keys is union of the imput maps' keys.
///
/// The function invokes:
/// - `subtract` for values if keys presented in both input maps
/// - `transform` for keys presented in just `minuend`
/// - `negate` for keys presented in just `subtrahend`
Map<K, V2> subtractMaps<K, V1, V2>({
required Map<K, V1>? minuend,
required Map<K, V1>? subtrahend,
required V2? Function(V1? minuend, V1? subtrahend) subtract,
}) {
minuend ??= <K, V1>{};
subtrahend ??= <K, V1>{};

final result = <K, V2>{};
final unionOfKeys = minuend.keys.toSet().union(subtrahend.keys.toSet());

for (var key in unionOfKeys) {
final diff = subtract(minuend[key], subtrahend[key]);
if (diff != null) result[key] = diff;
}
return result;
}
Original file line number Diff line number Diff line change
Expand Up @@ -454,69 +454,66 @@ class _HeapTreeViewState extends State<HeapTreeView>
snapshotDisplay = null;
}

return Padding(
padding: const EdgeInsets.only(top: denseRowSpacing),
child: Column(
children: [
const SizedBox(height: defaultSpacing),
ValueListenableBuilder<int>(
valueListenable: _currentTab,
builder: (context, index, _) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TabBar(
labelColor: themeData.textTheme.bodyLarge!.color,
isScrollable: true,
controller: _tabController,
tabs: _tabs,
),
if (_searchableTabs.contains(_tabs[index].key))
_buildSearchFilterControls(),
],
),
return Column(
children: [
const SizedBox(height: defaultSpacing),
ValueListenableBuilder<int>(
valueListenable: _currentTab,
builder: (context, index, _) => Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
TabBar(
labelColor: themeData.textTheme.bodyLarge!.color,
isScrollable: true,
controller: _tabController,
tabs: _tabs,
),
if (_searchableTabs.contains(_tabs[index].key))
_buildSearchFilterControls(),
],
),
const Divider(),
Expanded(
child: TabBarView(
physics: defaultTabBarViewPhysics,
controller: _tabController,
children: [
// Profile Tab
KeepAliveWrapper(
child: AllocationProfileTableView(
controller: controller.allocationProfileController,
),
),
const Divider(),
Expanded(
child: TabBarView(
physics: defaultTabBarViewPhysics,
controller: _tabController,
children: [
// Profile Tab
KeepAliveWrapper(
child: AllocationProfileTableView(
controller: controller.allocationProfileController,
),
const KeepAliveWrapper(
child: AllocationProfileTracingView(),
),
const KeepAliveWrapper(
child: AllocationProfileTracingView(),
),
// Analysis Tab
KeepAliveWrapper(
child: Column(
children: [
_buildSnapshotControls(themeData.textTheme),
const SizedBox(height: denseRowSpacing),
Expanded(
child: buildSnapshotTables(snapshotDisplay),
),
],
),
// Analysis Tab
),
// Diff tab.
if (FeatureFlags.memoryDiffing)
KeepAliveWrapper(
child: Column(
children: [
_buildSnapshotControls(themeData.textTheme),
const SizedBox(height: denseRowSpacing),
Expanded(
child: buildSnapshotTables(snapshotDisplay),
),
],
child: DiffPane(
controller: controller.diffPaneController,
),
),
// Diff tab.
if (FeatureFlags.memoryDiffing)
KeepAliveWrapper(
child: DiffPane(
controller: controller.diffPaneController,
),
),
// Leaks tab.
if (controller.shouldShowLeaksTab.value)
const KeepAliveWrapper(child: LeaksPane()),
],
),
// Leaks tab.
if (controller.shouldShowLeaksTab.value)
const KeepAliveWrapper(child: LeaksPane()),
],
),
],
),
),
],
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class AllocationProfileTracingViewController extends DisposableController

void updateClassFilter(String value, {bool force = false}) {
if (value.isEmpty && _currentFilter.isEmpty && !force) return;
final updatedFilter = (value.contains(_currentFilter) && !force
final updatedFilteredClassList = (value.contains(_currentFilter) && !force
? _filteredClassList.value
: _unfilteredClassList)
.where(
Expand All @@ -107,7 +107,7 @@ class AllocationProfileTracingViewController extends DisposableController
.map((e) => _tracedClasses[e.cls.id!]!)
.toList();

_filteredClassList.replaceAll(updatedFilter);
_filteredClassList.replaceAll(updatedFilteredClassList);
_currentFilter = value;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,6 @@ class _MemoryChartPaneState extends State<MemoryChartPane>
return ValueListenableBuilder<bool>(
valueListenable: preferences.memory.showChart,
builder: (_, showChart, __) {
// TODO(polina-c): animate the showing / hiding of this chart.

if (!showChart) return const SizedBox.shrink();

return RawKeyboardListener(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';

import '../../../../shared/common_widgets.dart';
import '../../../../shared/globals.dart';
import '../../primitives/ui.dart';

class ChartButton extends StatelessWidget {
const ChartButton({Key? key}) : super(key: key);

@override
Widget build(BuildContext context) {
return ValueListenableBuilder<bool>(
valueListenable: preferences.memory.showChart,
builder: (_, showChart, __) => IconLabelButton(
key: key,
tooltip: showChart ? 'Hide chart' : 'Show chart',
icon: showChart ? Icons.keyboard_arrow_up : Icons.keyboard_arrow_down,
label: 'Chart',
minScreenWidthForTextBeforeScaling: primaryControlsMinVerboseWidth,
onPressed: () => preferences.memory.showChart.value =
!preferences.memory.showChart.value,
),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,46 +23,75 @@ class DiffPaneController {

/// The list contains one item that show information and all others
/// are snapshots.
ValueListenable<List<DiffListItem>> get snapshots => _snapshots;
final _snapshots = ListValueNotifier(<DiffListItem>[InformationListItem()]);
ValueListenable<List<SnapshotItem>> get snapshots => _snapshots;
final _snapshots = ListValueNotifier(<SnapshotItem>[SnapshotDocItem()]);

ValueListenable<int> get selectedIndex => _selectedIndex;
final _selectedIndex = ValueNotifier<int>(0);
ValueListenable<int> get selectedSnapshotIndex => _selectedSnapshotIndex;
final _selectedSnapshotIndex = ValueNotifier<int>(0);
void setSelectedSnapshotIndex(int index) =>
_selectedSnapshotIndex.value = index;

/// If true, some process is going on.
ValueListenable<bool> get isProcessing => _isProcessing;
final _isProcessing = ValueNotifier<bool>(false);

DiffListItem get selectedItem => snapshots.value[selectedIndex.value];
SnapshotItem get selectedSnapshotItem =>
snapshots.value[selectedSnapshotIndex.value];

/// Full name for the selected class.
ValueListenable<String?> get selectedClass => _selectedClass;
final _selectedClass = ValueNotifier<String?>(null);
void setSelectedClass(String? value) => _selectedClass.value = value;
ValueListenable<HeapClassName?> get selectedClass => _selectedClass;
final _selectedClass = ValueNotifier<HeapClassName?>(null);
void setSelectedClass(HeapClassName? value) => _selectedClass.value = value;

/// Selected retaining path.
ValueListenable<ClassOnlyHeapPath?> get selectedPath => _selectedPath;
final _selectedPath = ValueNotifier<ClassOnlyHeapPath?>(null);
void setselectedPath(ClassOnlyHeapPath? value) => _selectedPath.value = value;

ValueListenable<String?> get classFilter => _classFilter;
final _classFilter = ValueNotifier<String?>(null);
void setClassFilter(String value) {
_classFilter.value = value;
throw UnimplementedError();
// if (value.isEmpty && _currentFilter.isEmpty) return;
// final updatedFilteredClassList = (value.contains(_currentFilter)
// ? _filteredClassList.value
// : _unfilteredClassList)
// .where(
// (e) => e.cls.name!.contains(value),
// )
// .map((e) => _tracedClasses[e.cls.id!]!)
// .toList();
//
// _filteredClassList.replaceAll(updatedFilteredClassList);
// _currentFilter = value;
}

/// True, if the list contains snapshots, i.e. items beyond the first
/// informational item.
bool get hasSnapshots => snapshots.value.length > 1;

final snapshotStatsSorting = ColumnSorting();
final classSorting = ColumnSorting();

final classDiffSorting = ColumnSorting();

final classStatsSorting = ColumnSorting();
final pathSorting = ColumnSorting();

Future<void> takeSnapshot() async {
_isProcessing.value = true;
final future = snapshotTaker.take();
_snapshots.add(
SnapshotListItem(
future,
_nextDisplayNumber(),
currentIsolateName ?? '<isolate-not-detected>',
diffStore,
selectedClass,
),
final newItem = SnapshotInstanceItem(
future,
_nextDisplayNumber(),
currentIsolateName ?? '<isolate-not-detected>',
diffStore,
selectedClass,
selectedPath,
);
_snapshots.add(newItem);
await future;
final newElementIndex = snapshots.value.length - 1;
_selectedIndex.value = newElementIndex;
_selectedSnapshotIndex.value = newElementIndex;
_isProcessing.value = false;
}

Expand All @@ -71,7 +100,7 @@ class DiffPaneController {
snapshots.value[i].dispose();
}
_snapshots.removeRange(1, snapshots.value.length);
_selectedIndex.value = 0;
_selectedSnapshotIndex.value = 0;
}

int _nextDisplayNumber() {
Expand All @@ -81,15 +110,14 @@ class DiffPaneController {
}

void deleteCurrentSnapshot() {
assert(selectedItem is SnapshotListItem);
selectedItem.dispose();
_snapshots.removeRange(selectedIndex.value, selectedIndex.value + 1);
assert(selectedSnapshotItem is SnapshotInstanceItem);
selectedSnapshotItem.dispose();
_snapshots.removeRange(
selectedSnapshotIndex.value,
selectedSnapshotIndex.value + 1,
);
// We must change the selectedIndex, because otherwise the content will
// not be re-rendered.
_selectedIndex.value = max(selectedIndex.value - 1, 0);
}

void select(int index) {
_selectedIndex.value = index;
_selectedSnapshotIndex.value = max(selectedSnapshotIndex.value - 1, 0);
}
}
Loading