Skip to content
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

Reorganize chart pane controller code and prepare structure for offline mode. #7572

Merged
merged 107 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
107 commits
Select commit Hold shift + click to select a range
e522c7e
-
polina-c Apr 4, 2024
ebded8c
Update launch.json
polina-c Apr 4, 2024
7976e00
Merge branch 'master' of github.com:flutter/devtools into offline1
polina-c Apr 4, 2024
3c87709
-
polina-c Apr 4, 2024
ea47bc9
-
polina-c Apr 4, 2024
3bbed40
Update launch.json
polina-c Apr 4, 2024
215ed02
-
polina-c Apr 4, 2024
f5a0acc
Merge branch 'master' of github.com:flutter/devtools into offline2
polina-c Apr 4, 2024
dc0844f
-
polina-c Apr 4, 2024
94ad638
Merge branch 'master' of github.com:flutter/devtools into offline2
polina-c Apr 4, 2024
b6e8225
Update memory_controller.dart
polina-c Apr 4, 2024
b73eb28
Update memory_controller.dart
polina-c Apr 4, 2024
5067dbc
-
polina-c Apr 5, 2024
c31d051
Update memory_controller.dart
polina-c Apr 5, 2024
51a189a
-
polina-c Apr 5, 2024
63daf74
Update DEPENDENCIES.md
polina-c Apr 5, 2024
aeeba2d
-
polina-c Apr 5, 2024
08de780
-
polina-c Apr 5, 2024
372d822
Merge branch 'master' of github.com:flutter/devtools into offline2
polina-c Apr 5, 2024
3ca3cd1
Update memory_controller.dart
polina-c Apr 5, 2024
bcc0246
-
polina-c Apr 6, 2024
f8f29ce
-
polina-c Apr 6, 2024
39b5695
-
polina-c Apr 6, 2024
bcd2514
-
polina-c Apr 7, 2024
0724dba
Update memory_controller.dart
polina-c Apr 8, 2024
741f0c4
Update memory_controller.dart
polina-c Apr 8, 2024
3e28d5c
-
polina-c Apr 8, 2024
f01ced6
Update memory_controller.dart
polina-c Apr 8, 2024
7a29b65
-
polina-c Apr 8, 2024
4ebae9e
Update offline_data.dart
polina-c Apr 8, 2024
0771789
-
polina-c Apr 8, 2024
cf4b341
Update offline_data.dart
polina-c Apr 8, 2024
ba0e76d
Update simple_items.dart
polina-c Apr 8, 2024
2ceab20
Update simple_items.dart
polina-c Apr 8, 2024
b230792
Update memory_controller.dart
polina-c Apr 8, 2024
f64f826
Update memory_controller.dart
polina-c Apr 8, 2024
f1e7e5e
-
polina-c Apr 8, 2024
9601724
-
polina-c Apr 9, 2024
8193e9e
-
polina-c Apr 9, 2024
38bc77a
-
polina-c Apr 9, 2024
dbf826a
Update profile_pane_controller.dart
polina-c Apr 9, 2024
c58ce81
-
polina-c Apr 9, 2024
9ad3f28
-
polina-c Apr 9, 2024
ad3cb08
Update DEPENDENCIES.md
polina-c Apr 9, 2024
0da6798
-
polina-c Apr 9, 2024
9068996
Merge branch 'tracing-data' into offline2
polina-c Apr 9, 2024
d5633af
Update chart_controller.dart
polina-c Apr 9, 2024
0a91214
Merge branch 'master' of github.com:flutter/devtools into mode
polina-c Apr 9, 2024
cbd931f
-
polina-c Apr 9, 2024
ee7503f
Merge branch 'mode' into offline2
polina-c Apr 9, 2024
e9098b1
-
polina-c Apr 9, 2024
64f1961
Update chart_pane_controller.dart
polina-c Apr 9, 2024
c4dac54
Update chart_pane_controller.dart
polina-c Apr 9, 2024
10b62cf
Update chart_pane_controller.dart
polina-c Apr 9, 2024
bd0df00
Update chart_pane_controller.dart
polina-c Apr 9, 2024
b2d8f22
-
polina-c Apr 9, 2024
ce96556
Merge branch 'master' of github.com:flutter/devtools into offline2
polina-c Apr 9, 2024
b8c4f35
Update memory_controller.dart
polina-c Apr 9, 2024
d2a1254
Update memory_controller.dart
polina-c Apr 9, 2024
8f0010b
Update chart_pane_controller.dart
polina-c Apr 9, 2024
6ee54a2
Update chart_pane_controller.dart
polina-c Apr 9, 2024
9b2c45a
Update chart_pane_controller.dart
polina-c Apr 10, 2024
d58cc26
Update chart_pane_controller.dart
polina-c Apr 10, 2024
2aaa8dc
Update chart_pane_controller.dart
polina-c Apr 11, 2024
ef8ce6a
-
polina-c Apr 11, 2024
c91f7c2
-
polina-c Apr 11, 2024
a8eac4e
Merge branch 'clean1' into offline2
polina-c Apr 11, 2024
6b9510e
Update chart_pane_controller.dart
polina-c Apr 11, 2024
a5cfeef
Update chart_pane_controller.dart
polina-c Apr 11, 2024
575497b
-
polina-c Apr 11, 2024
8d4a249
Update memory_tracker.dart
polina-c Apr 11, 2024
fab3a2b
Update memory_tracker.dart
polina-c Apr 11, 2024
ce0ee73
Update memory_tracker.dart
polina-c Apr 11, 2024
3aea57c
-
polina-c Apr 11, 2024
815c66e
-
polina-c Apr 11, 2024
694a1df
Update chart_pane_controller.dart
polina-c Apr 11, 2024
7999d3c
Update chart_control_pane.dart
polina-c Apr 11, 2024
a56cc2e
Update chart_pane_controller.dart
polina-c Apr 11, 2024
f7e3c64
Update chart_pane_controller.dart
polina-c Apr 11, 2024
407fb59
-
polina-c Apr 11, 2024
74d0656
Update chart_pane_controller.dart
polina-c Apr 12, 2024
e869a70
Update chart_pane_controller.dart
polina-c Apr 12, 2024
c4993c5
-
polina-c Apr 12, 2024
e97047d
Update chart_pane_controller.dart
polina-c Apr 12, 2024
3b87715
Update chart_pane_controller.dart
polina-c Apr 12, 2024
a897a1f
-
polina-c Apr 12, 2024
8b35071
-
polina-c Apr 12, 2024
f592d2f
-
polina-c Apr 12, 2024
faab035
-
polina-c Apr 12, 2024
48a43b7
Update chart_pane_controller.dart
polina-c Apr 12, 2024
789c2f7
Update chart_pane_controller.dart
polina-c Apr 12, 2024
1caa0fe
-
polina-c Apr 12, 2024
8ea8e39
Update memory_tracker.dart
polina-c Apr 12, 2024
444fa53
-
polina-c Apr 12, 2024
fb1ffa8
Merge branch 'master' of github.com:flutter/devtools into offline
polina-c Apr 12, 2024
e0093a4
-
polina-c Apr 12, 2024
0ec2767
-
polina-c Apr 12, 2024
b96eb76
-
polina-c Apr 12, 2024
324d0d4
Update screen_body.dart
polina-c Apr 12, 2024
245fad1
Update memory_controller.dart
polina-c Apr 12, 2024
709f425
Update memory_controller.dart
polina-c Apr 12, 2024
b4a4166
Update scene_test_extensions.dart
polina-c Apr 13, 2024
9b8518b
Update memory_screen_test.dart
polina-c Apr 13, 2024
20ebec2
-
polina-c Apr 13, 2024
5fc768d
-
polina-c Apr 13, 2024
5d7d3a5
-
polina-c Apr 14, 2024
8938b89
-
polina-c Apr 15, 2024
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 @@ -100,6 +100,9 @@ class MemoryController extends DisposableController
createData: (json) => OfflineMemoryData.parse(json),
shouldLoad: (data) => true,
);
// [maybeLoadOfflineData] will be a noop if there is no offline data for the memory screen,
// so ensure we still call [_initializedData] if it has not been called.
if (!_initialized.isCompleted) _initializeData();
assert(_initialized.isCompleted);
polina-c marked this conversation as resolved.
Show resolved Hide resolved
}
assert(_initialized.isCompleted);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:devtools_app_shared/ui.dart';
import 'package:devtools_app_shared/utils.dart';
import 'package:flutter/material.dart';
Expand Down Expand Up @@ -33,19 +31,10 @@ class _ConnectedMemoryBodyState extends State<ConnectedMemoryBody>

final _focusNode = FocusNode(debugLabel: 'memory');

bool _initialized = false;

@override
void initState() {
super.initState();
autoDisposeFocusNode(_focusNode);
unawaited(_init());
}

Future<void> _init() async {
await memoryController.initialized;
_initialized = true;
setState(() {});
}

@override
Expand All @@ -63,27 +52,32 @@ class _ConnectedMemoryBodyState extends State<ConnectedMemoryBody>

@override
Widget build(BuildContext context) {
if (!_initialized) {
return const Center(
child: CircularProgressIndicator(),
);
}

return Column(
key: MemoryChartPane.hoverKey,
children: [
MemoryControlPane(
controller: controller.control,
),
const SizedBox(height: intermediateSpacing),
MemoryChartPane(
chart: controller.chart,
keyFocusNode: _focusNode,
),
Expanded(
child: MemoryTabView(memoryController),
),
],
return FutureBuilder<void>(
future: memoryController.initialized,
builder: (context, snapshot) {
if (snapshot.connectionState == ConnectionState.done) {
return Column(
key: MemoryChartPane.hoverKey,
children: [
MemoryControlPane(
controller: controller.control,
),
const SizedBox(height: intermediateSpacing),
MemoryChartPane(
chart: controller.chart,
keyFocusNode: _focusNode,
),
Expanded(
child: MemoryTabView(memoryController),
),
],
);
} else {
return const Center(
child: CircularProgressIndicator(),
);
polina-c marked this conversation as resolved.
Show resolved Hide resolved
}
},
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:devtools_app/src/screens/memory/framework/memory_screen.dart';
import 'package:devtools_app/src/screens/memory/panes/control/widgets/settings_dialog.dart';
import 'package:devtools_app/src/shared/common_widgets.dart';
import 'package:devtools_app/src/shared/globals.dart';
Expand All @@ -13,18 +12,10 @@ import 'package:flutter_test/flutter_test.dart';

import '../../test_infra/matchers/matchers.dart';
import '../../test_infra/scenes/memory/default.dart';
import '../../test_infra/scenes/scene_test_extensions.dart';

void main() {
late MemoryDefaultScene scene;

Future<void> pumpMemoryScreen(WidgetTester tester) async {
await tester.pumpScene(scene);
// Delay to ensure the memory profiler has collected data.
await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.byType(MemoryBody), findsOneWidget);
}

// Set a wide enough screen width that we do not run into overflow.
const windowSize = Size(2225.0, 1000.0);

Expand All @@ -41,7 +32,7 @@ void main() {
'settings update preferences',
windowSize,
(WidgetTester tester) async {
await pumpMemoryScreen(tester);
await scene.pump(tester);

// Open the dialog.
await tester.tap(find.byType(SettingsOutlinedButton));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,9 @@ import 'package:flutter_test/flutter_test.dart';

import '../../../test_infra/matchers/matchers.dart';
import '../../../test_infra/scenes/memory/default.dart';
import '../../../test_infra/scenes/scene_test_extensions.dart';

Future<void> pumpScene(WidgetTester tester, MemoryDefaultScene scene) async {
await tester.pumpScene(scene);
// Delay to ensure the memory profiler has collected data.
await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.byType(MemoryBody), findsOneWidget);
await scene.pump(tester);
await tester.tap(
find.byKey(MemoryScreenKeys.diffTab),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:devtools_app/devtools_app.dart';
import 'package:devtools_app/src/screens/memory/framework/memory_tabs.dart';
import 'package:devtools_app/src/screens/memory/shared/heap/class_filter.dart';
import 'package:devtools_test/helpers.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import '../../test_infra/scenes/memory/default.dart';
import '../../test_infra/scenes/scene_test_extensions.dart';

final _filter1 = ClassFilter(
except: 'filter1',
Expand All @@ -25,10 +23,8 @@ final _filter2 = ClassFilter(
);

Future<void> pumpScene(WidgetTester tester, MemoryDefaultScene scene) async {
await tester.pumpScene(scene);
// Delay to ensure the memory profiler has collected data.
await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.byType(MemoryBody), findsOneWidget);
await scene.pump(tester);

await tester.tap(
find.byKey(MemoryScreenKeys.diffTab),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ void main() {
);

// Delay to ensure the memory profiler has collected data.
await tester.pumpAndSettle(const Duration(seconds: 1));
await tester
.runAsync(() async => tester.pumpAndSettle(const Duration(seconds: 1)));
expect(find.byType(MemoryBody), findsOneWidget);
}

Expand Down Expand Up @@ -101,15 +102,6 @@ void main() {
expect(find.text('GC'), findsOneWidget);

expect(find.byType(MemoryVMChart), findsOneWidget);

expect(
controller.chart.memoryTimeline.liveData.isEmpty,
isTrue,
);
expect(
controller.chart.memoryTimeline.offlineData.isEmpty,
isTrue,
);
},
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:devtools_app/src/screens/memory/framework/memory_screen.dart';
import 'package:devtools_app/src/screens/memory/framework/memory_tabs.dart';
import 'package:devtools_app/src/screens/memory/panes/profile/model.dart';
import 'package:devtools_app/src/screens/memory/panes/profile/profile_pane_controller.dart';
Expand All @@ -17,7 +16,6 @@ import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';

import '../../test_infra/scenes/memory/default.dart';
import '../../test_infra/scenes/scene_test_extensions.dart';

void main() {
late MemoryDefaultScene scene;
Expand All @@ -27,13 +25,6 @@ void main() {
await scene.setUp();
});

Future<void> pumpMemoryScreen(WidgetTester tester) async {
await tester.pumpScene(scene);
// Delay to ensure the memory profiler has collected data.
await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.byType(MemoryBody), findsOneWidget);
}

// Set a wide enough screen width that we do not run into overflow.
const windowSize = Size(2225.0, 1200.0);
//setGlobal(NotificationService, NotificationService());
Expand All @@ -57,7 +48,7 @@ void main() {
'respects VM Developer Mode setting',
windowSize,
(WidgetTester tester) async {
await pumpMemoryScreen(tester);
await scene.pump(tester);

final allocationProfileController = scene.controller.profile;

Expand Down Expand Up @@ -156,7 +147,7 @@ void main() {
'manually refreshes',
windowSize,
(WidgetTester tester) async {
await pumpMemoryScreen(tester);
await scene.pump(tester);

final allocationProfileController = scene.controller.profile;
await navigateToAllocationProfile(tester, allocationProfileController);
Expand Down Expand Up @@ -185,7 +176,7 @@ void main() {
'refreshes on GC',
windowSize,
(WidgetTester tester) async {
await pumpMemoryScreen(tester);
await scene.pump(tester);

final allocationProfileController = scene.controller.profile;

Expand Down Expand Up @@ -227,7 +218,7 @@ void main() {
'sorts correctly',
windowSize,
(WidgetTester tester) async {
await pumpMemoryScreen(tester);
await scene.pump(tester);

final table = find.byType(FlatTable<ProfileRecord>);
expect(table, findsOneWidget);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import 'package:mockito/mockito.dart';
import 'package:vm_service/vm_service.dart';

import '../../test_infra/scenes/memory/default.dart';
import '../../test_infra/scenes/scene_test_extensions.dart';
import '../../test_infra/utils/test_utils.dart';

// TODO(bkonyi): add tests for multi-isolate support.
Expand Down Expand Up @@ -59,10 +58,7 @@ void main() {
late final CpuSamples allocationTracingProfile;

Future<void> pumpScene(WidgetTester tester) async {
await tester.pumpScene(scene);
// Delay to ensure the memory profiler has collected data.
await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.byType(MemoryBody), findsOneWidget);
await scene.pump(tester);
await tester.tap(
find.byKey(MemoryScreenKeys.dartHeapAllocationTracingTab),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import '../../../test_infra/test_data/memory.dart';
import '../../../test_infra/test_data/memory_allocation.dart';
import '../../test_data/memory/heap/heap_data.dart';
import '../../test_data/memory/heap/heap_graph_fakes.dart';
import '../scene_test_extensions.dart';

// To run:
// flutter run -t test/test_infra/scenes/memory/default.stager_app.g.dart -d macos
Expand Down Expand Up @@ -79,6 +80,13 @@ class MemoryDefaultScene extends Scene {
);
}

Future<void> pump(WidgetTester tester) async {
await tester.pumpSceneAsync(this);
// Delay to ensure the memory profiler has collected data.
await tester.pumpAndSettle(const Duration(seconds: 1));
expect(find.byType(MemoryBody), findsOneWidget);
}

@override

/// Sets up the scene.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,14 @@ extension StagerTestExtensions on WidgetTester {
),
);
}

Future<void> pumpSceneAsync(Scene scene) async {
await runAsync(() async {
await pumpWidget(
Builder(
builder: (BuildContext context) => scene.build(context),
),
);
});
}
}
Loading