Skip to content

Commit a1b5917

Browse files
author
Jonah Williams
authored
[flutter_tools] ignore viewpost ime and samsung spam messages. (#161199)
Fixes flutter/flutter#160598
1 parent 593b40d commit a1b5917

File tree

2 files changed

+41
-7
lines changed

2 files changed

+41
-7
lines changed

packages/flutter_tools/lib/src/android/android_device.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,12 +1152,15 @@ class AdbLogReader extends DeviceLogReader {
11521152
RegExp(r'^[F]\/[\S^:]+:\s+'),
11531153
];
11541154

1155-
// E/SurfaceSyncer(22636): Failed to find sync for id=9
1156-
// Some versions of Android spew this out. It is inactionable to the end user
1157-
// and causes no problems for the application.
1158-
static final RegExp _surfaceSyncerSpam = RegExp(
1159-
r'^E/SurfaceSyncer\(\s*\d+\): Failed to find sync for id=\d+',
1160-
);
1155+
static final List<RegExp> _filteredMessagees = <RegExp>[
1156+
// E/SurfaceSyncer(22636): Failed to find sync for id=9
1157+
// Some versions of Android spew this out. It is inactionable to the end user
1158+
// and causes no problems for the application.
1159+
RegExp(r'^E/SurfaceSyncer\(\s*\d+\): Failed to find sync for id=\d+'),
1160+
// See https://github.com/flutter/flutter/issues/160598
1161+
RegExp(r'ViewPostIme pointer'),
1162+
RegExp(r'mali.instrumentation.graph.work'),
1163+
];
11611164

11621165
// 'F/libc(pid): Fatal signal 11'
11631166
static final RegExp _fatalLog = RegExp(r'^F\/libc\s*\(\s*\d+\):\sFatal signal (\d+)');
@@ -1213,7 +1216,7 @@ class AdbLogReader extends DeviceLogReader {
12131216
}
12141217
}
12151218
} else if (_appPid != null && int.parse(logMatch.group(1)!) == _appPid) {
1216-
acceptLine = !_surfaceSyncerSpam.hasMatch(line);
1219+
acceptLine = !_filteredMessagees.any((RegExp e) => e.hasMatch(line));
12171220

12181221
if (_fatalLog.hasMatch(line)) {
12191222
// Hit fatal signal, app is now crashing

packages/flutter_tools/test/general.shard/android/adb_log_reader_test.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,37 @@ void main() {
7070
expect(emittedLines, const <String>['W/flutter($appPid): Hello there!']);
7171
});
7272

73+
testWithoutContext('AdbLogReader ignores spam from Samsung/Mali', () async {
74+
const int appPid = 1;
75+
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
76+
FakeCommand(
77+
command: const <String>['adb', '-s', '1234', 'shell', '-x', 'logcat', '-v', 'time'],
78+
completer: Completer<void>.sync(),
79+
stdout:
80+
'$kDummyLine'
81+
'05-11 12:54:46.665 W/flutter($appPid): Hello there!\n'
82+
'05-11 12:54:46.665 I/ViewRootImpl@bd2a991[MainActivity]($appPid): ViewPostIme pointer 0\n'
83+
'05-11 12:54:46.665 I/ViewRootImpl@bd2a991[MainActivity]($appPid): ViewPostIme pointer 1\n'
84+
'05-11 12:54:46.665 D/mali.instrumentation.graph.work($appPid): key already added\n',
85+
),
86+
]);
87+
final AdbLogReader logReader = await AdbLogReader.createLogReader(
88+
createFakeDevice(null),
89+
processManager,
90+
BufferLogger.test(),
91+
);
92+
await logReader.provideVmService(_FakeFlutterVmService(appPid));
93+
final Completer<void> onDone = Completer<void>.sync();
94+
final List<String> emittedLines = <String>[];
95+
logReader.logLines.listen((String line) {
96+
emittedLines.add(line);
97+
}, onDone: onDone.complete);
98+
await null;
99+
logReader.dispose();
100+
await onDone.future;
101+
expect(emittedLines, const <String>['W/flutter($appPid): Hello there!']);
102+
});
103+
73104
testWithoutContext('AdbLogReader calls adb logcat with expected flags apiVersion 21', () async {
74105
final FakeProcessManager processManager = FakeProcessManager.list(<FakeCommand>[
75106
const FakeCommand(

0 commit comments

Comments
 (0)