Repository navigation
Conversation
…er#188451) Xcode builds multi-target applications in parallel, invoking the Flutter build pipeline concurrently. This leads to a destructive race condition in `generatePluginsSwiftPackage` where one process deletes the ephemeral packages directory while another is writing to it, causing `FileSystemException` or `PathExistsException`. This change implements: 1. Process-safe file locking (`.swift_pm.lock`) with retry loops to serialize directory preparation across parallel builds. 2. Non-destructive, incremental cleanup of obsolete symlinks rather than deleting the entire directory. 3. Content-aware write skipping for `Package.swift` and placeholder source files to avoid redundant writes and prevent unnecessary Xcode project re-indexing. Fixes flutter#188446
|
This pull request was opened from and to a release candidate branch. This should only be done as part of the official Flutter release process. If you are attempting to make a regular contribution to the Flutter project, please close this PR and follow the instructions at Tree Hygiene for detailed instructions on contributing to Flutter. Reviewers: Use caution before merging pull requests to release branches. Ensure the proper procedure has been followed. |
There was a problem hiding this comment.
Code Review
This pull request introduces file-locking synchronization for Swift Package Manager operations to handle concurrent builds, cleans up stale plugin symlinks, and optimizes Package.swift and placeholder source generation by avoiding redundant writes. Feedback suggests adding a timeout to the retry loop in runLocked to prevent infinite hangs on persistent FileSystemExceptions.
This pull request is created by automatic cherry pick workflow
Please fill in the form below, and a flutter domain expert will evaluate this cherry pick request.
Issue Link:
What is the link to the issue this cherry-pick is addressing?
#188446
Impact Description:
What is the impact (ex. visual jank on Samsung phones, app crash, cannot ship an iOS app)?
Does it impact development (ex. flutter doctor crashes when Android Studio is installed),
or the shipping of production apps (the app crashes on launch).
This information is for domain experts and release engineers to understand the consequences of saying yes or no to the cherry pick.
The Flutter tool experiences a race condition when preparing the Swift Packages directory during parallel Xcode builds, leading to
FileSystemException(OS Error: Directory not empty, errno = 66) orPathExistsException. This is one of the top crashers identified in the Flutter 3.44.3 stable release. It impacts development when building multi-target iOS/macOS applications in parallel.Changelog Description:
Explain this cherry pick:
See best practices for examples.
[flutter/188446] When building multi-target applications in parallel on iOS and macOS, a race condition in SwiftPM integration causes FileSystemException.
Workaround:
Is there a workaround for this issue?
Run Xcode builds sequentially (disable parallel target builds) or build targets one by one.
Risk:
What is the risk level of this cherry-pick?
Test Coverage:
Are you confident that your fix is well-tested by automated tests?
Validation Steps:
What are the steps to validate that this fix works?
FileSystemExceptionorPathExistsExceptioninephemeral/Packages.