mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
This PR fixes a race condition that causes intermittent build failures on iOS with errors like no such file or directory. These failures were frequently observed in CI tests running on macOS. The root cause is that the background wireless device discovery process, which uses `devicectl`, was not being terminated after a target device was selected. This background process could then delete Xcode's module caches while `xcodebuild` was actively using them, leading to a build failure. The fix ensures that the wireless device discovery process is explicitly stopped at all logical exit points of the device discovery flow. This is achieved by calling stopExtendedWirelessDeviceDiscovery() as soon as: - A single specified device is found and validated. - An ephemeral device is chosen. - A user interactively selects a device from a list. - The discovery process concludes in a non-interactive environment (like CI). This change prevents the devicectl process from running concurrently with the app build, thus resolving the race condition and improving the reliability of iOS builds. ### Testing: - This is tested by checking the bringup to make sure the following tests are passing: * [Mac_arm64_ios integration_test_test_ios](https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_arm64_ios%20integration_test_test_ios?limit=200) * [Mac_ios wide_gamut_ios](https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_ios%20wide_gamut_ios?limit=200) * [Mac_ios native_assets_ios](https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_ios%20native_assets_ios?limit=200) * [Mac_ios spell_check_test](https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_ios%20spell_check_test?limit=200) * [Mac_ios channels_integration_test_ios](https://ci.chromium.org/ui/p/flutter/builders/prod/Mac_ios%20channels_integration_test_ios?limit=200) fixes #174444 ## 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. - [ ] 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]. - [ ] 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
135 lines
3.6 KiB
Dart
135 lines
3.6 KiB
Dart
// 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:process/process.dart';
|
|
|
|
import '../base/file_system.dart';
|
|
import '../base/logger.dart';
|
|
import '../base/os.dart';
|
|
import '../base/platform.dart';
|
|
import '../build_info.dart';
|
|
import '../desktop_device.dart';
|
|
import '../device.dart';
|
|
import '../features.dart';
|
|
import '../project.dart';
|
|
import 'application_package.dart';
|
|
import 'build_linux.dart';
|
|
import 'linux_workflow.dart';
|
|
|
|
/// A device that represents a desktop Linux target.
|
|
class LinuxDevice extends DesktopDevice {
|
|
LinuxDevice({
|
|
required ProcessManager processManager,
|
|
required Logger logger,
|
|
required FileSystem fileSystem,
|
|
required OperatingSystemUtils operatingSystemUtils,
|
|
}) : _operatingSystemUtils = operatingSystemUtils,
|
|
_logger = logger,
|
|
super(
|
|
'linux',
|
|
platformType: PlatformType.linux,
|
|
ephemeral: false,
|
|
logger: logger,
|
|
processManager: processManager,
|
|
fileSystem: fileSystem,
|
|
operatingSystemUtils: operatingSystemUtils,
|
|
);
|
|
|
|
final OperatingSystemUtils _operatingSystemUtils;
|
|
final Logger _logger;
|
|
|
|
@override
|
|
Future<bool> isSupported() async => true;
|
|
|
|
@override
|
|
String get name => 'Linux';
|
|
|
|
@override
|
|
late final Future<TargetPlatform> targetPlatform = () async {
|
|
if (_operatingSystemUtils.hostPlatform == HostPlatform.linux_x64) {
|
|
return TargetPlatform.linux_x64;
|
|
}
|
|
return TargetPlatform.linux_arm64;
|
|
}();
|
|
|
|
@override
|
|
bool isSupportedForProject(FlutterProject flutterProject) {
|
|
return flutterProject.linux.existsSync();
|
|
}
|
|
|
|
@override
|
|
Future<void> buildForDevice({
|
|
String? mainPath,
|
|
required BuildInfo buildInfo,
|
|
bool usingCISystem = false,
|
|
}) async {
|
|
await buildLinux(
|
|
FlutterProject.current().linux,
|
|
buildInfo,
|
|
target: mainPath,
|
|
targetPlatform: await targetPlatform,
|
|
logger: _logger,
|
|
);
|
|
}
|
|
|
|
@override
|
|
String executablePathForDevice(covariant LinuxApp package, BuildInfo buildInfo) {
|
|
return package.executable(buildInfo.mode);
|
|
}
|
|
}
|
|
|
|
class LinuxDevices extends PollingDeviceDiscovery {
|
|
LinuxDevices({
|
|
required Platform platform,
|
|
required FeatureFlags featureFlags,
|
|
required OperatingSystemUtils operatingSystemUtils,
|
|
required FileSystem fileSystem,
|
|
required ProcessManager processManager,
|
|
required Logger logger,
|
|
}) : _platform = platform,
|
|
_linuxWorkflow = LinuxWorkflow(platform: platform, featureFlags: featureFlags),
|
|
_fileSystem = fileSystem,
|
|
_logger = logger,
|
|
_processManager = processManager,
|
|
_operatingSystemUtils = operatingSystemUtils,
|
|
super('linux devices');
|
|
|
|
final Platform _platform;
|
|
final LinuxWorkflow _linuxWorkflow;
|
|
final ProcessManager _processManager;
|
|
final Logger _logger;
|
|
final FileSystem _fileSystem;
|
|
final OperatingSystemUtils _operatingSystemUtils;
|
|
|
|
@override
|
|
bool get supportsPlatform => _platform.isLinux;
|
|
|
|
@override
|
|
bool get canListAnything => _linuxWorkflow.canListDevices;
|
|
|
|
@override
|
|
Future<List<Device>> pollingGetDevices({
|
|
Duration? timeout,
|
|
bool forWirelessDiscovery = false,
|
|
}) async {
|
|
if (!canListAnything) {
|
|
return const <Device>[];
|
|
}
|
|
return <Device>[
|
|
LinuxDevice(
|
|
logger: _logger,
|
|
processManager: _processManager,
|
|
fileSystem: _fileSystem,
|
|
operatingSystemUtils: _operatingSystemUtils,
|
|
),
|
|
];
|
|
}
|
|
|
|
@override
|
|
Future<List<String>> getDiagnostics() async => const <String>[];
|
|
|
|
@override
|
|
List<String> get wellKnownIds => const <String>['linux'];
|
|
}
|