Skip to content

Commit 3a1c469

Browse files
[flutter_tools] Do not always wait for the full timeout when running Spotlight to locate Android Studio on macOS (flutter#189952)
flutter#189461 introduced a script in the flutter_tools AndroidStudio class that wraps the Spotlight mdfind command with a timeout. This script had been waiting for the full 3 second timeout even if the mdfind process exited before then. The extra wait showed up in performance benchmarks of tasks that invoke AndroidStudio such as app compilation. See flutter#189177
1 parent efe7ac6 commit 3a1c469

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎packages/flutter_tools/lib/src/android/android_studio.dart‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,14 @@ import '../ios/plist_parser.dart';
1919

2020
@visibleForTesting
2121
const String kSpotlightMdfindCommand =
22-
'mdfind \'kMDItemCFBundleIdentifier="com.google.android.studio*"\' & pid=\$!; (sleep 3; kill -9 \$pid 2>/dev/null) & killer=\$!; wait \$pid 2>/dev/null; status=\$?; kill \$killer 2>/dev/null; exit \$status';
22+
r'( '
23+
r' for ((i = 0; i < 30; i++)); do '
24+
r' sleep .1; '
25+
r' kill -0 $$ || exit 0; '
26+
r' done; '
27+
r' kill -9 $$; '
28+
r') 2>/dev/null & '
29+
'exec mdfind \'kMDItemCFBundleIdentifier="com.google.android.studio*"\'';
2330

2431
const _androidStudioTitle = 'Android Studio';
2532
const _androidStudioId = 'AndroidStudio';

0 commit comments

Comments
 (0)