Skip to content

Commit 09387f2

Browse files
authored
Filter out unexpected process logs on iOS with better regex matching. (flutter#175452)
This PR modifies the pattern matching on what logs to ignore from `devicectl`. Basically any log that starts with a timestamp/process prefix should be ignored unless it has the Flutter engine FML syntax or is prefixed with `flutter:`. See comment in code for examples. Fixes flutter#175438. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. **Note**: The Flutter team is currently trialing the use of [Gemini Code Assist for GitHub](https://developers.google.com/gemini-code-assist/docs/review-github-code). Comments from the `gemini-code-assist` bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md
1 parent 48d2277 commit 09387f2

2 files changed

Lines changed: 31 additions & 8 deletions

File tree

packages/flutter_tools/lib/src/ios/core_devices.dart

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,27 @@ class IOSCoreDeviceControl {
311311

312312
/// A list of log patterns to ignore.
313313
static final _ignorePatterns = <Pattern>[
314-
RegExp(r'\[PreviewsAgentExecutorLibrary\].*'),
315-
RegExp(r'\[UIKit App Config\].*'),
316-
RegExp(r'\[UIFocus\].*'),
314+
// Ignore process logs that don't contain Flutter or user logs.
315+
// Example:
316+
// * Ignore logs with prefix in brackets that doesn't match FML:
317+
// 2025-09-16 12:15:47.939171-0500 Runner[1230:133819] [UIKit App Config] ...
318+
// * Ignore logs with timestamp/process prefix:
319+
// 2025-09-16 12:15:47.939171-0500 Runner[1230:133819] CoreText note: ...
320+
// * Don't ignore FML logs:
321+
// 2025-09-16 12:05:54.162621-0500 Runner[1215:129795] [FATAL:flutter/runtime/service_protocol.cc(121)] ...
322+
// * Don't ignore logs with no timestamp/process prefix:
323+
// A log with no prefix (NSLog, print in Swift, and FlutterLogger)
324+
// * Don't ignore flutter logs:
325+
// 2025-09-16 12:50:07.953318-0500 Runner[1279:149305] flutter: ...
326+
RegExp(
327+
r'^\S* \S* \S*\[[0-9:]*] ((?!(\[INFO|\[WARNING|\[ERROR|\[IMPORTANT|\[FATAL):))(?!(flutter:)).*',
328+
),
329+
// Ignore iOS execution mode and potential error. This is not meaningful to the developer.
330+
// Example:
331+
// * Dart execution mode: JIT
332+
// * Dart execution mode: simulator
317333
RegExp(r'Dart execution mode: .*'),
334+
'Failed to execute code (error: EXC_BAD_ACCESS, debugger assist: not detected)',
318335
];
319336

320337
/// Executes `devicectl` command to get list of devices. The command will

packages/flutter_tools/test/general.shard/ios/core_devices_test.dart

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1881,8 +1881,11 @@ Waiting for the application to terminate...
18811881
This log happens before the application is launched and should not be sent to FakeIOSCoreDeviceLogForwarder
18821882
Launched application with com.example.my_app bundle identifier.
18831883
Waiting for the application to terminate...
1884-
[PreviewsAgentExecutorLibrary] This log happens after the application is launched but matches an ignore pattern and should be skipped
1884+
2025-09-16 12:15:47.939171-0500 Runner[1230:133819] [PreviewsAgentExecutorLibrary] This log happens after the application is launched but matches an ignore pattern and should be skipped
1885+
2025-09-16 12:15:47.939171-0500 Runner[1230:133819] This log happens after the application is launched but matches an ignore pattern and should be skipped
18851886
This log happens after the application is launched and should be sent to FakeIOSCoreDeviceLogForwarder
1887+
2025-09-16 12:15:47.939171-0500 Runner[1230:133819] flutter: This log happens after the application is launched and should be sent to FakeIOSCoreDeviceLogForwarder
1888+
2025-09-16 12:15:47.939171-0500 Runner[1230:133819] [INFO:flutter/runtime/service_protocol.cc(121)] This log happens after the application is launched and should be sent to FakeIOSCoreDeviceLogForwarder
18861889
''',
18871890
),
18881891
);
@@ -1896,12 +1899,14 @@ This log happens after the application is launched and should be sent to FakeIOS
18961899

18971900
expect(fakeProcessManager, hasNoRemainingExpectations);
18981901
expect(logger.errorText, isEmpty);
1899-
expect(logForwarder.logs.length, 1);
1902+
expect(logForwarder.logs.length, 3);
19001903
expect(
19011904
logForwarder.logs,
1902-
contains(
1905+
containsAll([
19031906
'This log happens after the application is launched and should be sent to FakeIOSCoreDeviceLogForwarder',
1904-
),
1907+
'2025-09-16 12:15:47.939171-0500 Runner[1230:133819] flutter: This log happens after the application is launched and should be sent to FakeIOSCoreDeviceLogForwarder',
1908+
'2025-09-16 12:15:47.939171-0500 Runner[1230:133819] [INFO:flutter/runtime/service_protocol.cc(121)] This log happens after the application is launched and should be sent to FakeIOSCoreDeviceLogForwarder',
1909+
]),
19051910
);
19061911
expect(
19071912
logger.traceText,
@@ -1912,7 +1917,8 @@ This log happens after the application is launched and should be sent to FakeIOS
19121917
This log happens before the application is launched and should not be sent to FakeIOSCoreDeviceLogForwarder
19131918
Launched application with com.example.my_app bundle identifier.
19141919
Waiting for the application to terminate...
1915-
[PreviewsAgentExecutorLibrary] This log happens after the application is launched but matches an ignore pattern and should be skipped
1920+
2025-09-16 12:15:47.939171-0500 Runner[1230:133819] [PreviewsAgentExecutorLibrary] This log happens after the application is launched but matches an ignore pattern and should be skipped
1921+
2025-09-16 12:15:47.939171-0500 Runner[1230:133819] This log happens after the application is launched but matches an ignore pattern and should be skipped
19161922
'''),
19171923
);
19181924
expect(result, isTrue);

0 commit comments

Comments
 (0)