Skip to content

Diff heap statistics. #4501

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 171 commits into from
Sep 22, 2022
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
88e3c0d
r
polina-c Sep 9, 2022
40f96b4
-
polina-c Sep 9, 2022
4f35c1b
-
polina-c Sep 9, 2022
87794ef
Merge branch 'master' of github.com:flutter/devtools into size
polina-c Sep 9, 2022
070f797
Update model.dart
polina-c Sep 9, 2022
54a36a1
Update model.dart
polina-c Sep 9, 2022
bd4949c
Update model.dart
polina-c Sep 9, 2022
98f58ef
Merge branch 'master' of github.com:flutter/devtools into retained
polina-c Sep 9, 2022
19a7c37
-
polina-c Sep 9, 2022
86700a3
-
polina-c Sep 10, 2022
ef2d558
-
polina-c Sep 10, 2022
9991886
-
polina-c Sep 11, 2022
fd89707
-
polina-c Sep 11, 2022
4e3f5a0
Update heap_analyzer_test.dart
polina-c Sep 11, 2022
472625b
-
polina-c Sep 11, 2022
1931fea
-
polina-c Sep 11, 2022
0bab199
-
polina-c Sep 11, 2022
e51cd2a
-
polina-c Sep 11, 2022
78d65f6
-
polina-c Sep 11, 2022
9e2e970
-
polina-c Sep 11, 2022
93900af
Merge branch 'stager' into size2
polina-c Sep 11, 2022
5afdbfb
Update diff_pane_test.dart
polina-c Sep 11, 2022
da0c005
-
polina-c Sep 11, 2022
e57318c
-
polina-c Sep 11, 2022
f1d9623
Update diff_pane_test.dart
polina-c Sep 11, 2022
4115819
Update diff_pane_test.dart
polina-c Sep 11, 2022
ce85cdd
-
polina-c Sep 12, 2022
d489a31
-
polina-c Sep 12, 2022
7f7bae1
-
polina-c Sep 12, 2022
3df81f8
-
polina-c Sep 12, 2022
e470e4c
Merge branch 'size1' into size2
polina-c Sep 12, 2022
7a85608
-
polina-c Sep 12, 2022
13d2756
Update memory_hover_card.png
polina-c Sep 12, 2022
fbc3a6e
-
polina-c Sep 12, 2022
64b20f1
Update memory_diff_empty.png
polina-c Sep 12, 2022
362dd29
-
polina-c Sep 12, 2022
34d6f11
Update model.dart
polina-c Sep 12, 2022
a00e502
-
polina-c Sep 12, 2022
07eb2fe
Update mocks.dart
polina-c Sep 12, 2022
41a7553
Update pubspec.yaml
polina-c Sep 12, 2022
380be7f
Update generate_code.sh
polina-c Sep 12, 2022
45dc0e1
Update refresh.sh
polina-c Sep 12, 2022
002d7d5
Update bots.sh
polina-c Sep 12, 2022
6238161
Merge branch 'stager' into size1
polina-c Sep 13, 2022
15fe292
Merge branch 'size1' into size2
polina-c Sep 13, 2022
37230b1
Update diff_pane_test.dart
polina-c Sep 13, 2022
5f1186b
Update common_widgets.dart
polina-c Sep 13, 2022
f028530
-
polina-c Sep 13, 2022
91ca15d
-
polina-c Sep 13, 2022
688ba9b
-
polina-c Sep 13, 2022
dce7eb7
Merge branch 'master' of github.com:flutter/devtools into size2
polina-c Sep 13, 2022
b83af3c
-
polina-c Sep 13, 2022
5966ba6
-
polina-c Sep 13, 2022
97ba965
-
polina-c Sep 13, 2022
5478c00
-
polina-c Sep 13, 2022
25fb537
Update snapshot_view.dart
polina-c Sep 13, 2022
e50bf91
-
polina-c Sep 14, 2022
1ee043a
-
polina-c Sep 14, 2022
65dd972
-
polina-c Sep 14, 2022
087043b
-
polina-c Sep 14, 2022
94cbbf8
-
polina-c Sep 14, 2022
1ea913d
-
polina-c Sep 14, 2022
dc4e915
Update snapshot_view.dart
polina-c Sep 14, 2022
4fea4a7
-
polina-c Sep 14, 2022
57d8f5f
Update snapshot_control.dart
polina-c Sep 14, 2022
9e7ff13
Merge branch 'master' of github.com:flutter/devtools into size2
polina-c Sep 15, 2022
0f6ce0f
Update diff_pane.dart
polina-c Sep 15, 2022
8671ab4
-
polina-c Sep 15, 2022
5d14a5a
Merge branch 'size2' into diff3
polina-c Sep 15, 2022
95b5878
-
polina-c Sep 15, 2022
e6412a5
Update snapshot_control_pane.dart
polina-c Sep 15, 2022
9ab7569
Update model.dart
polina-c Sep 15, 2022
e4949de
Merge branch 'master' of github.com:flutter/devtools into size2
polina-c Sep 15, 2022
4c16c17
-
polina-c Sep 15, 2022
cd91650
Update diff_pane_controller.dart
polina-c Sep 15, 2022
f7fc09e
Update memory_controller.dart
polina-c Sep 15, 2022
a6e6743
Merge branch 'size2' into diff3
polina-c Sep 15, 2022
63dc0eb
Update model.dart
polina-c Sep 15, 2022
73d7096
-
polina-c Sep 15, 2022
75d3423
Merge branch 'refactor35' into diff3
polina-c Sep 15, 2022
3d1eda5
-
polina-c Sep 15, 2022
fc4dd57
-
polina-c Sep 15, 2022
16237aa
-
polina-c Sep 15, 2022
828970a
Update feature_flags.dart
polina-c Sep 15, 2022
ab3ec0a
Update feature_flags.dart
polina-c Sep 15, 2022
f357350
Merge branch 'feature_flags' into size2
polina-c Sep 15, 2022
e27a0d8
-
polina-c Sep 15, 2022
f7c70b3
Update snapshot_view.dart
polina-c Sep 16, 2022
9bb8a87
-
polina-c Sep 19, 2022
7ef3213
-
polina-c Sep 19, 2022
1961b34
-
polina-c Sep 19, 2022
afc095e
-
polina-c Sep 19, 2022
def70a3
-
polina-c Sep 19, 2022
7fd6469
Merge branch 'master' of github.com:flutter/devtools into size2
polina-c Sep 19, 2022
7ddb3a9
Update offline.dart
polina-c Sep 19, 2022
992008b
Delete offline.dart
polina-c Sep 19, 2022
600b508
Update feature_flags.dart
polina-c Sep 19, 2022
8b4a10f
Merge branch 'size2' into diff3
polina-c Sep 19, 2022
82eec49
-
polina-c Sep 19, 2022
4dbb5b7
Update table_test.dart
polina-c Sep 19, 2022
466c9b2
-
polina-c Sep 19, 2022
c3237db
-
polina-c Sep 19, 2022
a3f683a
Update common_widgets.dart
polina-c Sep 19, 2022
4a8c2e8
Update memory_diff_three_snapshots.png
polina-c Sep 19, 2022
8740e12
Merge branch 'size2' into diff3
polina-c Sep 19, 2022
6cffd19
Update memory_diff_three_snapshots.png
polina-c Sep 19, 2022
b7aca0c
Update memory_diff_three_snapshots.png
polina-c Sep 19, 2022
47d0bc7
Merge branch 'size2' into refactor25
polina-c Sep 19, 2022
ad372be
-
polina-c Sep 19, 2022
fe6f4e9
-
polina-c Sep 19, 2022
cd6d092
-
polina-c Sep 19, 2022
06ea6ba
-
polina-c Sep 19, 2022
4f87f3e
-
polina-c Sep 19, 2022
daa54c4
Update snapshot_view.dart
polina-c Sep 19, 2022
03b1888
-
polina-c Sep 19, 2022
6152a03
-
polina-c Sep 19, 2022
eadab87
Update snapshot_list.dart
polina-c Sep 19, 2022
de6b323
Update snapshot_list.dart
polina-c Sep 19, 2022
9303d1d
Update snapshot_list.dart
polina-c Sep 19, 2022
627fee3
Update snapshot_list.dart
polina-c Sep 19, 2022
203577a
Update memory_controller.dart
polina-c Sep 19, 2022
b715b69
Update diff_pane.dart
polina-c Sep 19, 2022
0eb648b
Update snapshot_list.dart
polina-c Sep 19, 2022
d932e1d
Update snapshot_list.dart
polina-c Sep 19, 2022
ffa4eb1
Update auto_dispose_mixin.dart
polina-c Sep 19, 2022
1d3fbbd
Update snapshot_list.dart
polina-c Sep 20, 2022
a7a7819
Update snapshot_list.dart
polina-c Sep 20, 2022
ba4d20a
-
polina-c Sep 20, 2022
e481ac8
-
polina-c Sep 20, 2022
2961a48
Merge branch 'size2' into refactor25
polina-c Sep 20, 2022
099e4e9
Merge branch 'refactor25' into diff3
polina-c Sep 20, 2022
17b7a4e
-
polina-c Sep 20, 2022
49c4c5c
-
polina-c Sep 20, 2022
75e1017
Merge branch 'master' of github.com:flutter/devtools into refactor25
polina-c Sep 20, 2022
d994ca7
-
polina-c Sep 20, 2022
befc361
Update model.dart
polina-c Sep 20, 2022
8753246
Merge branch 'refactor25' into diff3
polina-c Sep 20, 2022
af05352
-
polina-c Sep 20, 2022
c70a2ea
-
polina-c Sep 20, 2022
ec57489
-
polina-c Sep 20, 2022
3c26ddf
-
polina-c Sep 20, 2022
d7adc73
Merge branch 'refactor25' into diff3
polina-c Sep 20, 2022
fbc2334
Update model_test.dart
polina-c Sep 20, 2022
1bc7da9
-
polina-c Sep 20, 2022
66702a5
-
polina-c Sep 21, 2022
8d20b1a
-
polina-c Sep 21, 2022
bce22a6
-
polina-c Sep 21, 2022
94a652f
Merge branch 'refactor25' into diff3
polina-c Sep 21, 2022
ff510c0
-
polina-c Sep 21, 2022
f735e65
-
polina-c Sep 21, 2022
f598998
Update snapshot_view.dart
polina-c Sep 21, 2022
94f4b04
-
polina-c Sep 21, 2022
2b75990
Merge branch 'refactor25' into diff3
polina-c Sep 21, 2022
3647fdf
Merge branch 'diff3' into details4
polina-c Sep 21, 2022
c6a81a2
Update stats_table.dart
polina-c Sep 21, 2022
6b29f53
Merge branch 'master' of github.com:flutter/devtools into diff3
polina-c Sep 21, 2022
5163358
Merge branch 'diff3' into details4
polina-c Sep 21, 2022
86393ef
to-controller1
polina-c Sep 21, 2022
9ee2f4b
-
polina-c Sep 21, 2022
e64236a
Update table_test.dart
polina-c Sep 21, 2022
48dd684
-
polina-c Sep 21, 2022
60d024d
-
polina-c Sep 22, 2022
ee60ec8
Merge branch 'master' of github.com:flutter/devtools into details4
polina-c Sep 22, 2022
1b1b019
Update diff_pane_controller.dart
polina-c Sep 22, 2022
7f54c00
-
polina-c Sep 22, 2022
a704f48
Update model.dart
polina-c Sep 22, 2022
3ffb431
-
polina-c Sep 22, 2022
9739f90
-
polina-c Sep 22, 2022
63cf573
-
polina-c Sep 22, 2022
47e569f
-
polina-c Sep 22, 2022
7a1f04b
Update snapshot_control_pane.dart
polina-c Sep 22, 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ import '../../../shared/heap/model.dart';
import 'heap_diff.dart';

abstract class DiffListItem extends DisposableController {
/// Number, that, if shown in name, should be unique in the list.
/// Number, that if shown in name, should be unique in the list.
///
/// If the number is not shown, it should be 0.
/// If the number is not expected to be shown in UI, it should be 0.
int get displayNumber;

ValueListenable<bool> get isProcessing => _isProcessing;
final _isProcessing = ValueNotifier<bool>(false);
ValueListenable<bool> get isProcessing => _isProcessing;

/// If true, the item contains data, that can be compared and analyzed.
bool get hasData;
Expand All @@ -37,11 +37,16 @@ class SnapshotListItem extends DiffListItem with AutoDisposeControllerMixin {
this.displayNumber,
this._isolateName,
this.diffStore,
this.selectedClass,
) {
_isProcessing.value = true;
receiver.whenComplete(() async {
final data = await receiver;
if (data != null) heap = AdaptedHeap(data);
if (data != null) {
heap = AdaptedHeap(data);
updateSelectedRecord();
addAutoDisposeListener(selectedClass, () => updateSelectedRecord());
}
_isProcessing.value = false;
});
}
Expand All @@ -59,7 +64,17 @@ class SnapshotListItem extends DiffListItem with AutoDisposeControllerMixin {

var sorting = ColumnSorting();

final diffWith = ValueNotifier<SnapshotListItem?>(null);
final _diffWith = ValueNotifier<SnapshotListItem?>(null);
ValueListenable<SnapshotListItem?> get diffWith => _diffWith;
void setDiffWith(SnapshotListItem? value) {
Copy link
Member

Choose a reason for hiding this comment

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

same comment around ordering. Also, any reason we aren't using a formal setter here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed ordering
formal setter wants to have the same type as the formal getter with the same name

_diffWith.value = value;
updateSelectedRecord();
}

final ValueListenable<String?> selectedClass;

final _selectedRecord = ValueNotifier<HeapStatsRecord?>(null);
ValueListenable<HeapStatsRecord?> get selectedRecord => _selectedRecord;

@override
bool get hasData => heap != null;
Expand All @@ -70,6 +85,9 @@ class SnapshotListItem extends DiffListItem with AutoDisposeControllerMixin {
if (itemToDiffWith == null) return theHeap.stats;
return diffStore.compare(theHeap, itemToDiffWith.heap!).stats;
}

void updateSelectedRecord() =>
_selectedRecord.value = statsToShow.recordsByClass[selectedClass.value];
}

class ColumnSorting {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import 'package:flutter/foundation.dart';
import '../../../../../primitives/utils.dart';
import '../../../primitives/memory_utils.dart';
import '../../../shared/heap/model.dart';
import 'Item_controller.dart';
import 'heap_diff.dart';
import 'model.dart';

class DiffPaneController {
DiffPaneController(this.snapshotTaker);
Expand All @@ -35,7 +35,7 @@ class DiffPaneController {
DiffListItem get selectedItem => snapshots.value[selectedIndex.value];

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

Expand All @@ -52,6 +52,7 @@ class DiffPaneController {
_nextDisplayNumber(),
currentIsolateName ?? '<isolate-not-detected>',
diffStore,
selectedClass,
),
);
await future;
Expand All @@ -61,6 +62,9 @@ class DiffPaneController {
}

Future<void> clearSnapshots() async {
for (var i = 0; i < snapshots.value.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

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

nit: use for (final snapshot in snapshots) to make this less verbose

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The index should start with 1 here. Fixed.

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

void deleteCurrentSnapshot() {
assert(selectedItem is SnapshotListItem);
selectedItem.dispose();
_snapshots.removeRange(selectedIndex.value, selectedIndex.value + 1);
// We must change the selectedIndex, because otherwise the content will
// not be re-rendered.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ class HeapDiffStore {

HeapComparison compare(AdaptedHeap heap1, AdaptedHeap heap2) {
final couple = _HeapCouple(heap1, heap2);
if (!_store.containsKey(couple)) _store[couple] = HeapComparison(couple);
return _store[couple]!;
return _store.putIfAbsent(couple, () => HeapComparison(couple));
}
}

Expand Down Expand Up @@ -74,13 +73,16 @@ class HeapComparison {
final unionOfKeys = older.keys.toSet().union(younger.keys.toSet());

for (var key in unionOfKeys) {
if (older.containsKey(key) && younger.containsKey(key)) {
final diff = _diffStatsRecords(older[key]!, younger[key]!);
final olderRecord = older[key];
final youngerRecord = younger[key];

if (olderRecord != null && youngerRecord != null) {
final diff = _diffStatsRecords(olderRecord, youngerRecord);
if (!diff.isZero) result[key] = diff;
} else if (younger.containsKey(key)) {
result[key] = younger[key]!;
} else if (youngerRecord != null) {
result[key] = youngerRecord;
} else {
result[key] = older[key]!.negative();
result[key] = olderRecord!.negative();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:flutter/material.dart';
import '../../../../shared/common_widgets.dart';
import '../../../../shared/split.dart';
import '../../../../shared/theme.dart';
import 'controller/Item_controller.dart';
import 'controller/diff_pane_controller.dart';
import 'controller/model.dart';
import 'widgets/snapshot_control_pane.dart';
import 'widgets/snapshot_list.dart';
import 'widgets/snapshot_view.dart';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ import 'package:flutter/widgets.dart';

import '../../../shared/heap/model.dart';

class ClassDetails extends StatelessWidget {
const ClassDetails({Key? key, required this.heapClass}) : super(key: key);
class HeapClassDetails extends StatelessWidget {
const HeapClassDetails({Key? key, required this.heapClass}) : super(key: key);

final HeapClass? heapClass;

@override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:flutter/material.dart';

import '../../../../../shared/common_widgets.dart';
import '../../../../../shared/theme.dart';
import '../controller/Item_controller.dart';
import '../controller/diff_pane_controller.dart';
import '../controller/model.dart';

class SnapshotControlPane extends StatelessWidget {
const SnapshotControlPane({Key? key, required this.controller})
Expand Down Expand Up @@ -54,7 +54,7 @@ class _DiffDropdown extends StatelessWidget {
final diffWith = current.diffWith.value;
// Check if diffWith was deleted from list.
if (diffWith != null && !list.value.contains(diffWith)) {
current.diffWith.value = null;
current.setDiffWith(null);
}
}

Expand Down Expand Up @@ -85,9 +85,9 @@ class _DiffDropdown extends StatelessWidget {
value: current.diffWith.value ?? current,
onChanged: (SnapshotListItem? value) {
if ((value ?? current) == current) {
current.diffWith.value = null;
current.setDiffWith(null);
} else {
current.diffWith.value = value;
current.setDiffWith(value);
}
},
items: items(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import '../../../../../primitives/auto_dispose_mixin.dart';
import '../../../../../shared/common_widgets.dart';
import '../../../../../shared/table.dart';
import '../../../../../shared/theme.dart';
import '../controller/Item_controller.dart';
import '../controller/diff_pane_controller.dart';
import '../controller/model.dart';

class SnapshotList extends StatelessWidget {
const SnapshotList({Key? key, required this.controller}) : super(key: key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'package:flutter/material.dart';
import '../../../../../shared/common_widgets.dart';
import '../../../../../shared/split.dart';
import '../../../shared/heap/model.dart';
import '../controller/Item_controller.dart';
import '../controller/diff_pane_controller.dart';
import '../controller/model.dart';
import 'class_details.dart';
import 'stats_table.dart';

Expand All @@ -31,6 +31,8 @@ class SnapshotView extends StatelessWidget {
} else {
final heap1 = item.heap!;
final heap2 = item.diffWith.value!.heap!;

// TODO(polina-c): make comparison async.
stats = controller.diffStore.compare(heap1, heap2).stats;
Copy link
Member

Choose a reason for hiding this comment

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

if this can be expensive, we shouldn't do this in build. If it is expensive, we could do this in the controller before we set isProcessing to false (that way we still show a loading spinner while we are calculating this).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is ok for small applications.
And it may be ok for performance, but heavy for memory.
I need to experiment with Gallery.
Added to the issue so that we do not forget: #3949 (comment)

Copy link
Contributor

Choose a reason for hiding this comment

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

If this has the potential to slow down the UI at all, we should definitely ship it out to a future and have the UI with a future builder and a spinner or something :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

Added TODO and item to #3949 (comment)

}

Expand All @@ -54,7 +56,7 @@ class SnapshotView extends StatelessWidget {
),
),
const OutlineDecoration(
child: ClassDetails(heapClass: null),
child: HeapClassDetails(heapClass: null),
),
],
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import '../../../../../shared/table.dart';
import '../../../../../shared/table_data.dart';
import '../../../../../shared/utils.dart';
import '../../../shared/heap/model.dart';
import '../controller/Item_controller.dart';
import '../controller/diff_pane_controller.dart';
import '../controller/model.dart';

class _ClassNameColumn extends ColumnData<HeapStatsRecord> {
_ClassNameColumn()
Expand Down Expand Up @@ -125,7 +125,6 @@ class StatsTable extends StatefulWidget {
class _StatsTableState extends State<StatsTable> with AutoDisposeMixin {
late final List<ColumnData<HeapStatsRecord>> _columns;
late final SnapshotListItem _item;
final _selectionNotifier = ValueNotifier<HeapStatsRecord?>(null);

@override
void initState() {
Expand All @@ -150,20 +149,6 @@ class _StatsTableState extends State<StatsTable> with AutoDisposeMixin {
}
}

HeapStatsRecord? get _selectedRecord =>
_item.statsToShow.recordsByClass[widget.controller.selectedClass.value];

@override
void didChangeDependencies() {
super.didChangeDependencies();

_selectionNotifier.value = _selectedRecord;
addAutoDisposeListener(
widget.controller.selectedClass,
() => _selectionNotifier.value = _selectedRecord,
);
}

@override
Widget build(BuildContext context) {
return FlatTable<HeapStatsRecord>(
Expand All @@ -172,7 +157,7 @@ class _StatsTableState extends State<StatsTable> with AutoDisposeMixin {
keyFactory: (e) => Key(e.heapClass.fullName),
onItemSelected: (r) =>
widget.controller.setSelectedClass(r.heapClass.fullName),
selectionNotifier: _selectionNotifier,
selectionNotifier: _item.selectedRecord,
sortColumn: _columns[_item.sorting.columnIndex],
sortDirection: _item.sorting.direction,
onSortChanged: (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ class AdaptedHeapData {
this.created = created ?? DateTime.now();
}

factory AdaptedHeapData.fromJson(Map<String, dynamic> json) =>
AdaptedHeapData(
(json[_JsonFields.objects] as List<dynamic>)
.map((e) => AdaptedHeapObject.fromJson(e))
.toList(),
created: json[_JsonFields.created],
rootIndex: json[_JsonFields.rootIndex] ?? _defaultRootIndex,
);
factory AdaptedHeapData.fromJson(Map<String, dynamic> json) {
final createdJson = json[_JsonFields.created];

return AdaptedHeapData(
(json[_JsonFields.objects] as List<dynamic>)
.map((e) => AdaptedHeapObject.fromJson(e))
.toList(),
created: createdJson == null ? null : DateTime.parse(createdJson),
rootIndex: json[_JsonFields.rootIndex] ?? _defaultRootIndex,
);
}

factory AdaptedHeapData.fromHeapSnapshot(HeapSnapshotGraph graph) =>
AdaptedHeapData(
Expand Down Expand Up @@ -70,7 +73,7 @@ class AdaptedHeapData {
Map<String, dynamic> toJson() => {
_JsonFields.objects: objects.map((e) => e.toJson()).toList(),
_JsonFields.rootIndex: rootIndex,
_JsonFields.created: created,
_JsonFields.created: created.toIso8601String(),
};

HeapPath? _retainingPath(IdentityHashCode code) {
Expand Down