[native_assets_builder] Concurrent execution of NativeAssetsBuilder
#1319
Labels
P1
A high priority bug; for example, a single project is unusable or has many test failures
package:hooks_runner
Currently,
NativeAssetsBuilder
s methods can be called by the embedder as follows:BuildConfig
/LinkConfig
s is fine. Everything is happening in the.dart_tool/native_assets_builder/<hashed_config>/
.This is currently mostly fine.
The situation in which this breaks in Flutter is when
flutter run -d all
has overlapping devices. E.g. if there are two Android phones connected. (It works fine with MacOS, iOS Simuatlor, iOS device, and Android emulator together.)Flutter does not allow running more than one
flutter
command in the terminal concurrently. It has some kind of lock.Dart doesn't have any commands running multiple native asset builds.
However, Dart doesn't guard against concurrent invocations. So two concurrent
dart run
process runs will cause undefined behavior.Also there's no guard against running
dart
andflutter
concurrently.We should explore making the
NativeAssetsBuilder
re-entrant. It should support the following scenarios:multiple invocations in the same Dart processNot needed.Since multiple processes need to communicate, we'd likely want to use lock files on the file system.
dart:io
surfaces locks: https://api.dart.dev/stable/3.4.4/dart-io/RandomAccessFile/lock.htmlThe text was updated successfully, but these errors were encountered: