From a1b5917c28aa6c4414a6a0707a146787c741d5c0 Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 8 Jan 2025 17:14:47 -0800 Subject: [PATCH] [flutter_tools] ignore viewpost ime and samsung spam messages. (#161199) Fixes https://github.com/flutter/flutter/issues/160598 --- .../lib/src/android/android_device.dart | 17 +++++----- .../android/adb_log_reader_test.dart | 31 +++++++++++++++++++ 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index 527e9e2268..b48f05d5ba 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -1152,12 +1152,15 @@ class AdbLogReader extends DeviceLogReader { RegExp(r'^[F]\/[\S^:]+:\s+'), ]; - // E/SurfaceSyncer(22636): Failed to find sync for id=9 - // Some versions of Android spew this out. It is inactionable to the end user - // and causes no problems for the application. - static final RegExp _surfaceSyncerSpam = RegExp( - r'^E/SurfaceSyncer\(\s*\d+\): Failed to find sync for id=\d+', - ); + static final List _filteredMessagees = [ + // E/SurfaceSyncer(22636): Failed to find sync for id=9 + // Some versions of Android spew this out. It is inactionable to the end user + // and causes no problems for the application. + RegExp(r'^E/SurfaceSyncer\(\s*\d+\): Failed to find sync for id=\d+'), + // See https://github.com/flutter/flutter/issues/160598 + RegExp(r'ViewPostIme pointer'), + RegExp(r'mali.instrumentation.graph.work'), + ]; // 'F/libc(pid): Fatal signal 11' static final RegExp _fatalLog = RegExp(r'^F\/libc\s*\(\s*\d+\):\sFatal signal (\d+)'); @@ -1213,7 +1216,7 @@ class AdbLogReader extends DeviceLogReader { } } } else if (_appPid != null && int.parse(logMatch.group(1)!) == _appPid) { - acceptLine = !_surfaceSyncerSpam.hasMatch(line); + acceptLine = !_filteredMessagees.any((RegExp e) => e.hasMatch(line)); if (_fatalLog.hasMatch(line)) { // Hit fatal signal, app is now crashing diff --git a/packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart b/packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart index 691e88771a..a00ff36bd7 100644 --- a/packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart +++ b/packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart @@ -70,6 +70,37 @@ void main() { expect(emittedLines, const ['W/flutter($appPid): Hello there!']); }); + testWithoutContext('AdbLogReader ignores spam from Samsung/Mali', () async { + const int appPid = 1; + final FakeProcessManager processManager = FakeProcessManager.list([ + FakeCommand( + command: const ['adb', '-s', '1234', 'shell', '-x', 'logcat', '-v', 'time'], + completer: Completer.sync(), + stdout: + '$kDummyLine' + '05-11 12:54:46.665 W/flutter($appPid): Hello there!\n' + '05-11 12:54:46.665 I/ViewRootImpl@bd2a991[MainActivity]($appPid): ViewPostIme pointer 0\n' + '05-11 12:54:46.665 I/ViewRootImpl@bd2a991[MainActivity]($appPid): ViewPostIme pointer 1\n' + '05-11 12:54:46.665 D/mali.instrumentation.graph.work($appPid): key already added\n', + ), + ]); + final AdbLogReader logReader = await AdbLogReader.createLogReader( + createFakeDevice(null), + processManager, + BufferLogger.test(), + ); + await logReader.provideVmService(_FakeFlutterVmService(appPid)); + final Completer onDone = Completer.sync(); + final List emittedLines = []; + logReader.logLines.listen((String line) { + emittedLines.add(line); + }, onDone: onDone.complete); + await null; + logReader.dispose(); + await onDone.future; + expect(emittedLines, const ['W/flutter($appPid): Hello there!']); + }); + testWithoutContext('AdbLogReader calls adb logcat with expected flags apiVersion 21', () async { final FakeProcessManager processManager = FakeProcessManager.list([ const FakeCommand(