Repository: flutter
Issue: app freezes when running with custom embedder in flutter stable 2.2
Labels: c: regression,c: crash,engine,e: embedder,P2,team-engine,triaged-engine

It seems like flutter commit [`0c00942`](https://github.com/flutter/flutter/commit/0c0094257ab38a76d89096545027df24ca0ff4e4) broke something in flutter-pi. Any app I run gets stuck after the first frame. Touch events still reach the dart VM, but apparently flutter never requests a new frame using the the embedder vsync callback.

The previous engine roll commit (flutter commit `33a9d6c`) works absolutely fine however. [Here's the diff](https://github.com/flutter/engine/compare/a252ec09b74cca0f8d8d3450566bf77c77f81e8d...c4678d65a62b87649ddfce0254131569e421d6f9) between the two engine commits

The engine commits in between are vsync-related, and that'd make sense because a colleague of mine has an embedder that doesn't specify the vsync callback, and he doesn't experience the issue.

Anyone have some idea what could be going on? I can try to create a minimal example for reproducing the issue if that helps

*EDIT:* flutter doctor and reproduction steps:
```
hannes@pop-os:~/devel/flutter_sdk$ flutter doctor -v
[✓] Flutter (Channel unknown, 2.2.0, on Linux, locale de_DE.UTF-8)
    • Flutter version 2.2.0 at /home/hannes/devel/flutter_sdk
    • Framework revision b22742018b (vor 13 Tagen), 2021-05-14 19:12:57 -0700
    • Engine revision a9d88a4d18
    • Dart version 2.13.0

[✗] Android toolchain - develop for Android devices
    ✗ Unable to locate Android SDK.
      Install Android Studio from: https://developer.android.com/studio/index.html
      On first launch it will assist you in installing the Android SDK components.
      (or visit https://flutter.dev/docs/get-started/install/linux#android-setup for detailed instructions).
      If the Android SDK has been installed to a custom location, please use
      `flutter config --android-sdk` to update to that location.


[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Android Studio (version 4.2)
    • Android Studio at /home/hannes/devel/android-studio
    • Flutter plugin version 56.0.2
    • Dart plugin version 202.8488
    • Java version OpenJDK Runtime Environment (build 11.0.8+0-b944-P17168821)

[✓] Connected device (2 available)
    • Chrome (web)          • chrome • web-javascript • Google Chrome 90.0.4430.93
    • Raspberry Pi (mobile) • pi     • linux-arm64    • Raspberry Pi 4 Model B+

! Doctor found issues in 1 category.
```

**Steps to reproduce**
I have a minimal embedder reproducing the issue: [minimal embedder](https://gist.github.com/ardera/60af806830cc80f4a61451b6c333cb50). Needs to be compiled with `-lsystemd` and `-lflutter_engine` (so also make sure you have the `libsystemd-dev` package  installed)

1. build the engine with custom embedders as the target, either the 2.2 stable one or the `c4678d65a62b` one, which is the first one that shows the issue.
2. put the compiled `icudtl.dat` inside `/usr/lib` (on the device you want to run the custom embedder on)
3. compile the minimal embedder. This needs the `flutter_embedder.h` of the engine build in the same directory.
4. checkout the correct flutter SDK: `flutter channel stable` for the 2.2 stable one or `git checkout 0c00942` for the first SDK that shows the issue.
5. create a new hello world app: `flutter create hello_world`
6. inside the `onPressed` callback of the floating action button, add some print command like `print("button was pressed");`
7. build the asset bundle for that app: `flutter build bundle`
8. deploy the asset bundle to `/tmp/hello_world` on the device you want to run the embedder on:
    - for example, `rsync -a ./build/flutter_assets/ pi@raspberrypi:/tmp/hello_world`
9. run the embedder
10. If you run it, you'll see:
    1. flutter requests a frame,
    2. that frame request is responded to by the embedder
    3. flutter presents a frame
    4. flutter requests a new frame
    5. that frame request is responded to by the embedder
    6. flutter requests yet another frame
    7. that frame request is queued since the previous frame has not yet been presented
    8. nothing happens after that, flutter will never present or request anything again

EDIT: Added a minimal embedder reproducing the issue.