Repository: flutter
Issue: Windows, multi-window, crash on creating and closing window
Labels: engine,platform-windows,P2,c: fatal crash,a: multi window,team-windows,triaged-windows

### Steps to reproduce

Related issue

https://github.com/MixinNetwork/flutter-plugins/issues/352

Run the demo  https://github.com/lukasz-lukasz-lukasz/flutter-plugins/commit/4ae8e28318187ee8936ffcccdd37c3d433e53f15

### Expected results

No crash

### Actual results

Crashed

![750fe5ec35cac51eeeb50741db6a696](https://github.com/user-attachments/assets/6509980c-b548-4047-9342-d910639b9305)


![image](https://github.com/user-attachments/assets/d10171c0-b69c-4554-8b25-c386dba15db7)


### Code sample

<details open><summary>Code sample</summary>

https://github.com/lukasz-lukasz-lukasz/flutter-plugins/commit/4ae8e28318187ee8936ffcccdd37c3d433e53f15


### Screenshots or Video

<details open>
<summary>Screenshots / Video demonstration</summary>

[Upload media here]

</details>


### Logs

Maybe the same cause  https://github.com/flutter/flutter/issues/137973#issuecomment-1799326980

> I suspect the proper fix is to make the `FlutterViewController` post a task to the raster thread to set the swap interval. This would ensure that the platform thread never makes the EGL context current during a rendering operation. I'll take a look at this.

@loic-sharma Could you please confirm?


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
[√] Flutter (Channel stable, 3.24.3, on Microsoft Windows [Version 10.0.20348.2655], locale en-US)
    • Flutter version 3.24.3 on channel stable at C:\workspace\flutter\flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 2663184aa7 (2 weeks ago), 2024-09-11 16:27:48 -0500
    • Engine revision 36335019a8
    • Dart version 3.5.3
    • DevTools version 2.37.3

[√] Windows Version (Installed version of Windows is version 10 or higher)

[X] Android toolchain - develop for Android devices
    X 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/to/windows-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 C:\Program Files\Google\Chrome\Application\chrome.exe

[√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.11.4)
    • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community
    • Visual Studio Community 2022 version 17.11.35312.102
    • Windows 10 SDK version 10.0.22621.0

[!] Android Studio (not installed)
    • Android Studio not found; download from https://developer.android.com/studio/index.html
      (or visit https://flutter.dev/to/windows-android-setup for detailed instructions).

[√] VS Code (version 1.93.1)
    • VS Code at C:\Users\Administrator\AppData\Local\Programs\Microsoft VS Code
    • Flutter extension version 3.96.0

[√] Connected device (3 available)
    • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.20348.2655]
    • Chrome (web)      • chrome  • web-javascript • Google Chrome 129.0.6668.71
    • Edge (web)        • edge    • web-javascript • Microsoft Edge 129.0.2792.52

[√] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.
```

</details>