Repository: flutter
Issue: iOS app gets stuck when calling flutterDidEnterBackground
Labels: c: crash,platform-ios,engine,a: existing-apps,a: production,P2,needs repro info,team-engine,triaged-engine

### Steps to reproduce

The monitoring background receives the user's stuck report. I haven’t reproduced it locally

### Expected results

The app will not stuck

### Actual results

App stuck

### Code sample

We don't have a local reproduction, so we can't provide sample code.
Our app is native and connected to the flutter page. There will be multi-engine situations (multiple flutter view controllers exist at the same time)

### Screenshots or Video

_No response_

### Logs

<details open><summary>Logs</summary>

```console
Thread 0 name: com.apple.main-thread  (cpu_usage: 0.00%)
libsystem_kernel.dylib    ___psynch_rw_wrlock (in libsystem_kernel.dylib)
libsystem_pthread.dylib    __pthread_rwlock_lock_wait (in libsystem_pthread.dylib)
libsystem_pthread.dylib    __pthread_rwlock_lock_slow$VARIANT$armv81 (in libsystem_pthread.dylib)
Flutter    fml::SyncSwitch::SetSwitch(bool) (in Flutter:sync_switch.cc:36)
Flutter    flutter::Shell::SetGpuAvailability(flutter::GpuAvailability) (in Flutter:shell.cc:2233)
Flutter    -[FlutterEngine setIsGpuDisabled:] (in Flutter:FlutterEngine.mm:1378)
Flutter    -[FlutterEngine flutterDidEnterBackground:] (in Flutter:FlutterEngine.mm:1368)
CoreFoundation    ___CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ (in CoreFoundation)
CoreFoundation    ____CFXRegistrationPost_block_invoke (in CoreFoundation)
CoreFoundation    __CFXRegistrationPost (in CoreFoundation)
CoreFoundation    __CFXNotificationPost (in CoreFoundation)
Foundation    -[NSNotificationCenter postNotificationName:object:userInfo:] (in Foundation)
UIKitCore    ___47-[UIApplication _applicationDidEnterBackground]_block_invoke (in UIKitCore)
UIKitCore    +[UIViewController _performWithoutDeferringTransitionsAllowingAnimation:actions:] (in UIKitCore)
UIKitCore    -[UIApplication _applicationDidEnterBackground] (in UIKitCore)
UIKitCore    ___101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke_2 (in UIKitCore)
UIKitCore    __UIScenePerformActionsWithLifecycleActionMask (in UIKitCore)
UIKitCore    ___101-[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]_block_invoke (in UIKitCore)
UIKitCore    -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:] (in UIKitCore)
UIKitCore    -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:] (in UIKitCore)
UIKitCore    -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:] (in UIKitCore)
UIKitCore    ___186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke (in UIKitCore)
UIKitCore    +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:] (in UIKitCore)
UIKitCore    __UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion (in UIKitCore)
UIKitCore    -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:] (in UIKitCore)
UIKitCore    __64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.196 (in UIKitCore)
UIKitCore    -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:] (in UIKitCore)
UIKitCore    -[UIScene scene:didUpdateWithDiff:transitionContext:completion:] (in UIKitCore)
UIKitCore    -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:] (in UIKitCore)
FrontBoardServices    -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:] (in FrontBoardServices)
FrontBoardServices    ___94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2 (in FrontBoardServices)
FrontBoardServices    -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:] (in FrontBoardServices)
FrontBoardServices    ___94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke (in FrontBoardServices)
libdispatch.dylib    __dispatch_client_callout (in libdispatch.dylib)
libdispatch.dylib    __dispatch_block_invoke_direct$VARIANT$armv81 (in libdispatch.dylib)
FrontBoardServices    ___FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ (in FrontBoardServices)
FrontBoardServices    -[FBSSerialQueue _targetQueue_performNextIfPossible] (in FrontBoardServices)
FrontBoardServices    -[FBSSerialQueue _performNextFromRunLoopSource] (in FrontBoardServices)
CoreFoundation    ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ (in CoreFoundation)
CoreFoundation    ___CFRunLoopDoSource0 (in CoreFoundation)
CoreFoundation    ___CFRunLoopDoSources0 (in CoreFoundation)
CoreFoundation    ___CFRunLoopRun (in CoreFoundation)
CoreFoundation    _CFRunLoopRunSpecific (in CoreFoundation)
GraphicsServices    _GSEventRunModal (in GraphicsServices)
UIKitCore    -[UIApplication _run] (in UIKitCore)
UIKitCore    _UIApplicationMain (in UIKitCore)
MyApp    main (in MyApp:AppDelegate.swift:39)
dyld    start (in dyld)
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.19.5, on macOS 13.5 22G74 darwin-arm64, locale
    en-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[!] Xcode - develop for iOS and macOS (Xcode 15.2)
    ! CocoaPods 1.12.1 out of date (1.13.0 is recommended).
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin
        code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To upgrade see
      https://guides.cocoapods.org/using/getting-started.html#updating-cocoapods
      for instructions.
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.2)
[✓] VS Code (version 1.89.1)
[✓] Connected device (3 available)
[✓] Network resources
```

</details>