diff --git a/.ci.yaml b/.ci.yaml index 5bc7b140cc0..706f5519c92 100644 --- a/.ci.yaml +++ b/.ci.yaml @@ -2116,17 +2116,6 @@ targets: ["devicelab", "android", "linux", "pixel", "7pro"] task_name: android_semantics_integration_test - # linux mokey test - - name: Linux_mokey android_stack_size_test - recipe: devicelab/devicelab_drone - presubmit: false - bringup: true # https://github.com/flutter/flutter/issues/148085 - timeout: 60 - properties: - tags: > - ["devicelab", "android", "linux", "mokey"] - task_name: android_stack_size_test - # linux mokey benchmark - name: Linux_mokey android_view_scroll_perf__timeline_summary recipe: devicelab/devicelab_drone diff --git a/dev/benchmarks/macrobenchmarks/lib/common.dart b/dev/benchmarks/macrobenchmarks/lib/common.dart index 643ab264b2e..c8f6a64966c 100644 --- a/dev/benchmarks/macrobenchmarks/lib/common.dart +++ b/dev/benchmarks/macrobenchmarks/lib/common.dart @@ -27,7 +27,6 @@ const String kHeavyGridViewRouteName = '/heavy_gridview'; const String kRasterCacheUseMemory = '/raster_cache_use_memory'; const String kShaderMaskCacheRouteName = '/shader_mask_cache'; const String kSimpleScrollRouteName = '/simple_scroll'; -const String kStackSizeRouteName = '/stack_size'; const String kAnimationWithMicrotasksRouteName = '/animation_with_microtasks'; const String kAnimatedImageRouteName = '/animated_image'; const String kOpacityPeepholeRouteName = '/opacity_peephole'; @@ -62,5 +61,3 @@ const String kGradientPerfStaticConsistentRouteName = '$kGradientPerfRouteName/s const String kScrollableName = '/macrobenchmark_listview'; const String kOpacityScrollableName = '$kOpacityPeepholeRouteName/listview'; const String kGradientPerfScrollableName = '$kGradientPerfRouteName/listview'; - -const String kStackSizeKey = 'stack_size'; diff --git a/dev/benchmarks/macrobenchmarks/lib/main.dart b/dev/benchmarks/macrobenchmarks/lib/main.dart index 6d97d592fa8..cab6478fff3 100644 --- a/dev/benchmarks/macrobenchmarks/lib/main.dart +++ b/dev/benchmarks/macrobenchmarks/lib/main.dart @@ -41,7 +41,6 @@ import 'src/shader_mask_cache.dart'; import 'src/simple_animation.dart'; import 'src/simple_scroll.dart'; import 'src/sliders.dart'; -import 'src/stack_size.dart'; import 'src/text.dart'; import 'src/very_long_picture_scrolling.dart'; @@ -83,7 +82,6 @@ class MacrobenchmarksApp extends StatelessWidget { kRasterCacheUseMemory: (BuildContext context) => const RasterCacheUseMemory(), kShaderMaskCacheRouteName: (BuildContext context) => const ShaderMaskCachePage(), kSimpleScrollRouteName: (BuildContext context) => const SimpleScroll(), - kStackSizeRouteName: (BuildContext context) => const StackSizePage(), kAnimationWithMicrotasksRouteName: (BuildContext context) => const AnimationWithMicrotasks(), kAnimatedImageRouteName: (BuildContext context) => const AnimatedImagePage(), kOpacityPeepholeRouteName: (BuildContext context) => const OpacityPeepholePage(), @@ -279,13 +277,6 @@ class HomePage extends StatelessWidget { Navigator.pushNamed(context, kLargeImageChangerRouteName); }, ), - ElevatedButton( - key: const Key(kStackSizeRouteName), - child: const Text('Stack Size'), - onPressed: () { - Navigator.pushNamed(context, kStackSizeRouteName); - }, - ), ElevatedButton( key: const Key(kAnimationWithMicrotasksRouteName), child: const Text('Animation With Microtasks'), diff --git a/dev/benchmarks/macrobenchmarks/lib/src/stack_size.dart b/dev/benchmarks/macrobenchmarks/lib/src/stack_size.dart deleted file mode 100644 index fcbbe5c18dc..00000000000 --- a/dev/benchmarks/macrobenchmarks/lib/src/stack_size.dart +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright 2014 The Flutter 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 'dart:ffi' as ffi; -import 'dart:io' as io; - -import 'package:flutter/material.dart'; - -import '../common.dart'; - -typedef GetStackPointerCallback = int Function(); - -// c interop function: -// void* mmap(void* addr, size_t len, int prot, int flags, int fd, off_t offset); -typedef CMmap = ffi.Pointer Function( - ffi.Pointer, ffi.IntPtr, ffi.Int32, ffi.Int32, ffi.Int32, ffi.IntPtr); -typedef DartMmap = ffi.Pointer Function( - ffi.Pointer, int, int, int, int, int); -final DartMmap mmap = ffi.DynamicLibrary.process().lookupFunction('mmap'); - -// c interop function: -// int mprotect(void* addr, size_t len, int prot); -typedef CMprotect = ffi.Int32 Function(ffi.Pointer, ffi.IntPtr, ffi.Int32); -typedef DartMprotect = int Function(ffi.Pointer, int, int); -final DartMprotect mprotect = ffi.DynamicLibrary.process() - .lookupFunction('mprotect'); - -const int kProtRead = 1; -const int kProtWrite = 2; -const int kProtExec = 4; - -const int kMapPrivate = 0x02; -const int kMapJit = 0x0; -const int kMapAnon = 0x20; - -const int kMemorySize = 16; -const int kInvalidFileDescriptor = -1; -const int kkFileMappingOffset = 0; - -const int kMemoryStartingIndex = 0; - -const int kExitCodeSuccess = 0; - -final GetStackPointerCallback getStackPointer = () { - // Makes sure we are running on an Android arm64 device. - if (!io.Platform.isAndroid) { - throw 'This benchmark test can only be run on Android arm devices.'; - } - final io.ProcessResult result = io.Process.runSync('getprop', ['ro.product.cpu.abi']); - if (result.exitCode != 0) { - throw 'Failed to retrieve CPU information.'; - } - if (!result.stdout.toString().contains('armeabi')) { - throw 'This benchmark test can only be run on Android arm devices.'; - } - - // Creates a block of memory to store the assembly code. - final ffi.Pointer region = mmap(ffi.nullptr, kMemorySize, kProtRead | kProtWrite, - kMapPrivate | kMapAnon | kMapJit, kInvalidFileDescriptor, kkFileMappingOffset); - if (region == ffi.nullptr) { - throw 'Failed to acquire memory for the test.'; - } - - // Writes the assembly code into the memory block. This assembly code returns - // the memory address of the stack pointer. - region.cast().asTypedList(kMemorySize).setAll( - kMemoryStartingIndex, - [ - // "mov r0, sp" in machine code: 0D00A0E1. - 0x0d, 0x00, 0xa0, 0xe1, - // "bx lr" in machine code: 1EFF2FE1. - 0x1e, 0xff, 0x2f, 0xe1, - ] - ); - - // Makes sure the memory block is executable. - if (mprotect(region, kMemorySize, kProtRead | kProtExec) != kExitCodeSuccess) { - throw 'Failed to write executable code to the memory.'; - } - return region - .cast>() - .asFunction(); -}(); - -class StackSizePage extends StatelessWidget { - const StackSizePage({super.key}); - - @override - Widget build(BuildContext context) { - return const Material( - child: Column( - children: [ - SizedBox( - width: 200, - height: 100, - child: ParentWidget(), - ), - ], - ), - ); - } -} - -class ParentWidget extends StatelessWidget { - const ParentWidget({super.key}); - - @override - Widget build(BuildContext context) { - final int myStackSize = getStackPointer(); - return ChildWidget(parentStackSize: myStackSize); - } -} - -class ChildWidget extends StatelessWidget { - const ChildWidget({required this.parentStackSize, super.key}); - final int parentStackSize; - - @override - Widget build(BuildContext context) { - final int myStackSize = getStackPointer(); - // Captures the stack size difference between parent widget and child widget - // during the rendering pipeline, i.e. one layer of stateless widget. - return Text( - '${parentStackSize - myStackSize}', - key: const ValueKey(kStackSizeKey), - ); - } -} diff --git a/dev/benchmarks/macrobenchmarks/test_driver/stack_size_perf_test.dart b/dev/benchmarks/macrobenchmarks/test_driver/stack_size_perf_test.dart deleted file mode 100644 index 39899156949..00000000000 --- a/dev/benchmarks/macrobenchmarks/test_driver/stack_size_perf_test.dart +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright 2014 The Flutter 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 'dart:convert' show JsonEncoder; - -import 'package:file/file.dart'; -import 'package:flutter_driver/flutter_driver.dart'; -import 'package:macrobenchmarks/common.dart'; -import 'package:path/path.dart' as path; -import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; - -import 'util.dart'; - -const JsonEncoder _prettyEncoder = JsonEncoder.withIndent(' '); - -void main() { - test('stack_size', () async { - late int stackSizeInBytes; - await runDriverTestForRoute(kStackSizeRouteName, (FlutterDriver driver) async { - final String stackSize = await driver.getText(find.byValueKey(kStackSizeKey)); - expect(stackSize.isNotEmpty, isTrue); - stackSizeInBytes = int.parse(stackSize); - }); - - expect(stackSizeInBytes > 0, isTrue); - - await fs.directory(testOutputsDirectory).create(recursive: true); - final File file = fs.file(path.join(testOutputsDirectory, 'stack_size.json')); - await file.writeAsString(_encodeJson({ - 'stack_size': stackSizeInBytes, - })); - }, timeout: Timeout.none); -} - -String _encodeJson(Map jsonObject) { - return _prettyEncoder.convert(jsonObject); -} diff --git a/dev/devicelab/bin/tasks/android_stack_size_test.dart b/dev/devicelab/bin/tasks/android_stack_size_test.dart deleted file mode 100644 index 80341ffa246..00000000000 --- a/dev/devicelab/bin/tasks/android_stack_size_test.dart +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright 2014 The Flutter 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_devicelab/framework/devices.dart'; -import 'package:flutter_devicelab/framework/framework.dart'; -import 'package:flutter_devicelab/tasks/perf_tests.dart'; - -Future main() async { - deviceOperatingSystem = DeviceOperatingSystem.androidArm; - await task(createStackSizeTest()); -} diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index 6af145623c3..0e15fe70625 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -353,43 +353,6 @@ TaskFunction createSlidersPerfTest() { ).run; } -TaskFunction createStackSizeTest() { - final String testDirectory = - '${flutterDirectory.path}/dev/benchmarks/macrobenchmarks'; - const String testTarget = 'test_driver/run_app.dart'; - const String testDriver = 'test_driver/stack_size_perf_test.dart'; - return () { - return inDirectory(testDirectory, () async { - final Device device = await devices.workingDevice; - await device.unlock(); - final String deviceId = device.deviceId; - await flutter('packages', options: ['get']); - - await flutter('drive', options: [ - '--no-android-gradle-daemon', - '-v', - '--verbose-system-logs', - '--profile', - '-t', testTarget, - '--driver', testDriver, - '-d', - deviceId, - ]); - final Map data = json.decode( - file('${_testOutputDirectory(testDirectory)}/stack_size.json').readAsStringSync(), - ) as Map; - - final Map result = { - 'stack_size_per_nesting_level': data['stack_size'], - }; - return TaskResult.success( - result, - benchmarkScoreKeys: result.keys.toList(), - ); - }); - }; -} - TaskFunction createFullscreenTextfieldPerfTest() { return PerfTest( '${flutterDirectory.path}/dev/benchmarks/macrobenchmarks',