Repository: flutter
Issue: FlutterView for Android's native RecyclerView. Sometimes rendering fails and does not attach to the view, rendering it black. 
Labels: platform-android,a: existing-apps,has reproducible steps,P2,team-android,triaged-android,:hourglass_flowing_sand:,found in release: 3.16,found in release: 3.19

### Steps to reproduce

Just modify the adapter from this official list case, 
https://flutter.cn/docs/development/add-to-app/android/add-flutter-view

Steps to reproduce：Slide the RecyclerView quickly, or modify the judgment condition code random.nextInt(1)

```
    override fun getItemViewType(position: Int): Int {
        return if (random.nextInt(1) == 0) {
            TYPE_FLUTTER
        } else {
            TYPE_ANDROID
        }
    }
```

### Code sample

adapter code：

```
class ListAdapter(context: Context, private val flutterViewEngine: FlutterViewEngine) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {

    private val TYPE_ANDROID = 0
    private val TYPE_FLUTTER = 1

    private val matchParentLayout = ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 500)

    private val random = Random.Default
    private val flutterChannel = MethodChannel(flutterViewEngine.engine.dartExecutor, "dev.flutter.example/cell")

    override fun onCreateViewHolder(viewGroup: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        return if (viewType == TYPE_FLUTTER) {
            val flutterView = FlutterView(viewGroup.context)
            flutterView.layoutParams = matchParentLayout
            FlutterViewHolder(flutterView)
        } else {
            val bind = AndroidCardBinding.inflate(LayoutInflater.from(viewGroup.context), viewGroup, false)
            Cell(bind)
        }
    }

    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        if (holder is FlutterViewHolder) {
            flutterViewEngine.attachFlutterView(holder.view)
            flutterChannel.invokeMethod("setCellNumber", position)
        } else if (holder is Cell) {
            holder.bind.androidCard.visibility = View.VISIBLE
            holder.bind.cellNumber.text = position.toString();
        }
    }

    override fun getItemViewType(position: Int): Int {
        return if (random.nextInt(3) == 0) {
            TYPE_FLUTTER
        } else {
            TYPE_ANDROID
        }
    }

    override fun getItemCount() = 100

    inner class Cell(val bind: AndroidCardBinding) : RecyclerView.ViewHolder(bind.root)
    inner class FlutterViewHolder(val view: FlutterView) : RecyclerView.ViewHolder(view)

}
```


### Performance profiling on master channel

- [X] The issue still persists on the master channel

### Timeline Traces

<details open><summary>Timeline Traces JSON</summary>

```json
[Paste the Timeline Traces here]
```

</details>


### Video demonstration

Quickly slide RecyclerView

![01](https://github.com/flutter/flutter/assets/45938601/125e4a02-712e-4d2a-b25f-c8ab85b32f3b)



### What target platforms are you seeing this bug on?

Android

### OS/Browser name and version | Device information

... ...

### Does the problem occur on emulator/simulator as well as on physical devices?

Yes

### Is the problem only reproducible with Impeller?

N/A

### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

```
[✓] Flutter (Channel stable, 3.13.2, on macOS 14.2.1 23C71 darwin-arm64, locale zh-Hans-CN)
    • Flutter version 3.13.2 on channel stable at /xx/xx/Documents/flutter_profile/flutter_sdk/flutter_3.13.2
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ff5b5b5fa6 (5 months ago), 2023-08-24 08:12:28 -0500
    • Engine revision b20183e040
    • Dart version 3.1.0
    • DevTools version 2.25.0
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /xx/xx/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • ANDROID_HOME = /xx/xx/Library/Android/sdk
    • Java binary at: /Applications/Android Studio_2022.3.1.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15A240d
    • CocoaPods version 1.14.3

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.3)
    • Android Studio at /Applications/Android Studio_2022.3.1.app/Contents
    • 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 17.0.6+0-17.0.6b829.9-10027231)

[✓] Android Studio (version 4.2)
    • Android Studio at /Applications/Android Studio_2021.4.2.2.app/Contents
    • 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.8+10-b944.6916264)

[✓] IntelliJ IDEA Ultimate Edition (version 2023.2.2)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 75.1.4
    • Dart plugin version 232.9559.10

[✓] VS Code (version 1.85.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.80.0

[✓] Connected device (3 available)
    • sdk gphone64 arm64 (mobile) • emulator-5554 • android-arm64  • Android 13 (API 33) (emulator)
    • macOS (desktop)             • macos         • darwin-arm64   • macOS 14.2.1 23C71 darwin-arm64
    • Chrome (web)                • chrome        • web-javascript • Google Chrome 120.0.6099.234

```