|
| 1 | +# Flutter's fix for a simulator's log stream |
| 2 | + |
| 3 | +`simulator_log_stream.patch` is Flutter's fix for |
| 4 | +[flutter/flutter#181771](https://github.com/flutter/flutter/issues/181771), |
| 5 | +from [flutter/flutter#193142](https://github.com/flutter/flutter/pull/193142), |
| 6 | +merged to Flutter's master branch as |
| 7 | +`c3ed85ef987759ee54a6bce275490cde2a238dc1`, fitted to Flutter 3.47.2, the |
| 8 | +version CI pins. No release carries it yet; 3.47.8 does not. It is licensed |
| 9 | +under Flutter's BSD 3-Clause licence, in `LICENSE`. |
| 10 | + |
| 11 | +## What it fixes |
| 12 | + |
| 13 | +On an iOS simulator, the Flutter tool reads the address of the app's Dart |
| 14 | +VM service from the simulator's log, through a `log stream` it starts as it |
| 15 | +launches the app. In 3.47.2 nothing waits for that stream to be ready, so |
| 16 | +when it starts late it misses the one line the app gives the address in, |
| 17 | +and the tool then waits for the address with no end. The `ios` workflow's |
| 18 | +simulator step hung that way three times on 2026-10-24 and 2026-10-25, each |
| 19 | +time at "Waiting for VM Service port to be available...", until its |
| 20 | +25-minute limit. |
| 21 | + |
| 22 | +With the fix, the tool launches the app only once the stream has printed |
| 23 | +its first line, or has exited. After 30 seconds without either, it says so |
| 24 | +and goes on waiting. |
| 25 | + |
| 26 | +## How it is used |
| 27 | + |
| 28 | +`.github/workflows/ios.yml` applies it to the Flutter it sets up, and has |
| 29 | +the `flutter` command build its tool again from the patched source, as it |
| 30 | +does after any change to that source. Nothing else uses it. It changes |
| 31 | +only how the tool launches an app on a simulator, so none of it is in any |
| 32 | +app the tool builds. |
| 33 | + |
| 34 | +## What was fitted |
| 35 | + |
| 36 | +The change is Flutter's, line for line, with its tests. Two things differ, |
| 37 | +because 3.47.2 is older than the branch the fix was made on: one line of |
| 38 | +context above the first change, and the tests' simulator, built without |
| 39 | +the `cpuArch` argument that 3.47.2's simulator does not take. |
| 40 | + |
| 41 | +To check it, from this repository's root, with `FLUTTER` the path of a |
| 42 | +checkout of Flutter 3.47.2: |
| 43 | + |
| 44 | +```bash |
| 45 | +git -C "$FLUTTER" apply "$PWD/third_party/flutter/simulator_log_stream.patch" |
| 46 | +cd "$FLUTTER/packages/flutter_tools" |
| 47 | +../../bin/cache/dart-sdk/bin/dart pub get |
| 48 | +../../bin/cache/dart-sdk/bin/dart test test/general.shard/ios/simulators_test.dart |
| 49 | +``` |
| 50 | + |
| 51 | +All 53 tests pass. With only the patch's tests applied, the two that wait |
| 52 | +for the log stream fail: the app is launched before the stream has printed |
| 53 | +anything. |
| 54 | + |
| 55 | +## When to remove it |
| 56 | + |
| 57 | +Once CI pins a Flutter that carries the fix, delete this folder and the |
| 58 | +step in `.github/workflows/ios.yml` that applies it. A Flutter carries it |
| 59 | +when, in a checkout of it, `$FLUTTER/packages/flutter_tools/lib/src/ios/simulators.dart` |
| 60 | +says "The iOS simulator log stream did not start". The step fails if the |
| 61 | +patch no longer applies, or the tool built again does not have it. |
0 commit comments