Repository: flutter
Issue: macos: Error waiting for a debug connection: The log reader stopped unexpectedly.
Labels: c: crash,tool,platform-mac,dependency: dart,P2,found in release: 2.2,found in release: 2.3,team-tool,triaged-tool

I am seeing this error when running my macOS desktop app with `flutter run -d macos` from the command line:
`Error waiting for a debug connection: The log reader stopped unexpectedly.`

I have a large Flutter macOS app that uses FFI with a large C library. When the C library is linked to the macOS app, I see this issue. When  I remove the C library, I do not see this issue.

**Workaround**
I am able to run the app from Xcode, and then use flutter attach where hot reload works.
```
flutter attach --debug-uri http://127.0.0.1:63466/Hs4cWkOF-og=/

Activating Dart DevTools...                                      1,696ms
Syncing files to device macOS...                                    9.1s

Flutter run key commands.
r Hot reload. 🔥🔥🔥
R Hot restart.
h Repeat this help message.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).
An Observatory debugger and profiler on macOS is available at: http://127.0.0.1:63603/ws7tORNO9k4=/

Flutter DevTools, a Flutter debugger and profiler, on macOS is available at:
http://127.0.0.1:63620?uri=http%3A%2F%2F127.0.0.1%3A63603%2Fws7tORNO9k4%3D%2F

Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
```

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue.
-->

```
$ flutter run -d macos
Running "flutter pub get" in example...                          1,886ms
Launching lib/main.dart on macOS in debug mode...
Running pod install...                                           1,725ms                                           
note: Using new build system                                            
note: Building targets in parallel                                      
note: Planning build                                                    
note: Constructing build description                                    
Building macOS application...                                           
Error waiting for a debug connection: The log reader stopped unexpectedly.
Error launching application on macOS.
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
Analyzing example...                                                    
No issues found! (ran in 1.9s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
[✓] Flutter (Channel stable, 2.0.5, on macOS 11.2.3 20D91 darwin-x64, locale en-US)
    • Flutter version 2.0.5 at /Applications/flutter
    • Framework revision adc687823a (4 weeks ago), 2021-04-16 09:40:20 -0700
    • Engine revision b09f014e96
    • Dart version 2.12.3

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/larry/Library/Android/sdk
    • Platform android-29, build-tools 28.0.3
    • ANDROID_HOME = /Users/larry/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.4, Build version 12D4e
    • CocoaPods version 1.10.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.0)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 50.0.1
    • Dart plugin version 193.7547
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.56.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.22.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-x64     • macOS 11.2.3 20D91 darwin-x64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 90.0.4430.212
    ! Error: Apple TV is not connected. Xcode will continue when Apple TV is connected. (code -13)

• No issues found!
```

</details>