Repository: flutter
Issue: [Flutter 3] Counter App crashes on first repaint after migrating to Flutter 3
Labels: c: crash,platform-android,engine,platform-linux,P2,team-android,triaged-android

Hi there,

While I was trying to upgrade my SDK to Flutter 3, I noticed I couldn't run my production anymore. Apps crash at the first repaint.

**The problem is reproducible from my Ubuntu 20.04 laptop, after upgrading to Flutter 3, Dart 2.17.0, on a Android Pixel 1, Android API 28 emulator, with the following steps**:
## Steps to Reproduce
1. `flutter upgrade` to get Flutter 3.0
2. Navigate to a folder
3. `flutter create .`
4. `flutter pub get`
5. Open your Android emulator (here I have Google Pixel Emulator, SDK28)
6. `flutter run`
7. Press the "+" button one time
8. The application crashes

**Expected results:** The app repaints itself and the UI is updated
**Actual results:** Heavy, fatal crash with no feedback whatsoever

**Reproducible code**
Just to be clear, I've left the code [in this repo](https://github.com/lucavenir/crash_version_3).

But it's just the demo counter app!

**What I've tried already**

- [X] Uninstall all Android Device Emulators I had, then re-install Google Pixel
- [X] Uninstall all Android SDK I had installed, then re-install Android 9
- [X] Run `flutter clean` several times before building and running again
- [X] Try the same procedure above on a different Computer / Operating System. UPDATE: **this works** (MacOS, MacMini, M1, Monterey 12.3.1). This confirms that the issue persists on Ubuntu. See [this comment](https://github.com/flutter/flutter/issues/104018#issuecomment-1129733427).
- [X] Tried the aforementioned procedure on a different emulator / Android API. UPDATE: **this works** (Pixel XL, API 32). This confirms that the issue persists on Pixel 1 API 28 emulator. See [this comment](https://github.com/flutter/flutter/issues/104018#issuecomment-1129703317).
- [X] Completely wipe-out this computer, format it, re-install everything from the ground up and try this again.. UPDATE: **IT STILL DOESN'T WORK** see [this comment](https://github.com/flutter/flutter/issues/104018#issuecomment-1130131425))


<details>
  <summary>Logs</summary>

```
D/EGL_emulation( 8387): eglMakeCurrent: 0xe5b057e0: ver 3 0 (tinfo 0xe5b03d00)
D/eglCodecCommon( 8387): setVertexArrayObject: set vao to 0 (0) 1 2
F/libc    ( 8387): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 8408 (1.raster), pid 8387 (crash_version_3)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'google/sdk_gphone_x86_arm/generic_x86_arm:9/PSR1.180720.117/5875966:user/release-keys'
Revision: '0'
ABI: 'x86'
pid: 8387, tid: 8408, name: 1.raster  >>> com.example.crash_version_3 <<<
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
Cause: null pointer dereference
    eax 00000000  ebx d29dc508  ecx 00000040  edx e40b2f40
    edi d2f18248  esi d09c4a70
    ebp d09c4a48  esp d09c4a10  eip d235e40a
backtrace:
    #00 pc 0179240a  /data/app/com.example.crash_version_3-eW9KTOnI7n7-NPtyOnbWrg==/lib/x86/libflutter.so (offset 0x147e000)
    #01 pc 0178cff8  /data/app/com.example.crash_version_3-eW9KTOnI7n7-NPtyOnbWrg==/lib/x86/libflutter.so (offset 0x147e000)
    #02 pc 0150cc9b  /data/app/com.example.crash_version_3-eW9KTOnI7n7-NPtyOnbWrg==/lib/x86/libflutter.so (offset 0x147e000)
    #03 pc 018384f3  /data/app/com.example.crash_version_3-eW9KTOnI7n7-NPtyOnbWrg==/lib/x86/libflutter.so (offset 0x147e000)
    #04 pc 014ace7c  /data/app/com.example.crash_version_3-eW9KTOnI7n7-NPtyOnbWrg==/lib/x86/libflutter.so (offset 0x147e000)
    #05 pc 0175c98d  /data/app/com.example.crash_version_3-eW9KTOnI7n7-NPtyOnbWrg==/lib/x86/libflutter.so (offset 0x147e000)
    #06 pc 0175c9ba  /data/app/com.example.crash_version_3-eW9KTOnI7n7-NPtyOnbWrg==/lib/x86/libflutter.so (offset 0x147e000)
    #07 pc 018381a2  /data/app/com.example.crash_version_3-eW9KTOnI7n7-NPtyOnbWrg==/lib/x86/libflutter.so (offset 0x147e000)
    #08 pc 0182e9c2  /data/app/com.example.crash_version_3-eW9KTOnI7n7-NPtyOnbWrg==/lib/x86/libflutter.so (offset 0x147e000)
    #09 pc 0183703a  /data/app/com.example.crash_version_3-eW9KTOnI7n7-NPtyOnbWrg==/lib/x86/libflutter.so (offset 0x147e000)
    #10 pc 01766aa5  /data/app/com.example.crash_version_3-eW9KTOnI7n7-NPtyOnbWrg==/lib/x86/libflutter.so (offset 0x147e000)
    #11 pc 01765f42  /data/app/com.example.crash_version_3-eW9KTOnI7n7-NPtyOnbWrg==/lib/x86/libflutter.so (offset 0x147e000)
    #12 pc 0008314f  [anon:libc_malloc:e4080000]
Lost connection to device.
```
</details>

<details>
  <summary>Flutter Analyze output</summary>

There are no problems, but just for the sake of clarity:

```
Analyzing crash_version_3...                                            
No issues found! (ran in 1.6s)
```
</details>
<details>
  <summary>Flutter Doctor -v output</summary>

There are no problems, but just for the sake of clarity:

```
[✓] Flutter (Channel stable, 3.0.0, on Ubuntu 20.04.4 LTS 5.13.0-41-generic, locale en_US.UTF-8)
    • Flutter version 3.0.0 at /home/venir/snap/flutter/common/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ee4e09cce0 (8 days ago), 2022-05-09 16:45:18 -0700
    • Engine revision d1b9a6938a
    • Dart version 2.17.0
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at /home/venir/Android/Sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at: /snap/android-studio/current/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
    • cmake version 3.10.2
    • ninja version 1.8.2
    • pkg-config version 0.29.1

[✓] Android Studio (version 2021.1)
    • Android Studio at /snap/android-studio/118/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[✓] Android Studio
    • Android Studio at /snap/android-studio/current/android-studio
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • android-studio-dir = /snap/android-studio/current/android-studio
    • Java version OpenJDK Runtime Environment (build 11.0.11+0-b60-7590822)

[✓] VS Code (version 1.67.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.40.0

[✓] Connected device (3 available)
    • AOSP on IA Emulator (mobile) • emulator-5554 • android-x86    • Android 9 (API 28) (emulator)
    • Linux (desktop)              • linux         • linux-x64      • Ubuntu 20.04.4 LTS 5.13.0-41-generic
    • Chrome (web)                 • chrome        • web-javascript • Google Chrome 101.0.4951.64

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```
</details>