Repository: flutter
Issue: [App Hang] CoreFoundation CFNOTIFICATIONCENTER
Labels: c: crash,platform-ios,engine,a: production,P2,needs repro info,team-engine,triaged-engine,customer: trivia

### Steps to reproduce

We can't reproduce it on development environments, we just have the stacktrace from production (attached below).

Hardware Model:     iPhone14,2
Role:               Foreground
OS Version:         iOS 16.6.1

### Expected results

The app hang is not triggered

### Actual results

```
App HangThe app was terminated while unresponsive


Hardware Model:     iPhone14,2
Process:            Preguntados
Identifier:         com.etermax.preguntados
Version:            3.254.1
Role:               Foreground
OS Version:         iOS 16.6.1


App Hang: The app was terminated while unresponsive

0  libsystem_kernel.dylib +0x1b18 ___psynch_cvwait
1  libsystem_pthread.dylib +0xfd0 __pthread_cond_wait
2  Flutter +0x570f8               std::_LIBCPP_ABI_NAMESPACE::__libcpp_condvar_wait[abi:v15000](_opaque_pthread_cond_t*, _opaque_pthread_mutex_t*) (__threading_support:335:10)
3  Flutter +0x3e95dc              flutter::PlatformView::NotifyCreated() (waitable_event.cc:148:9)
4  Flutter +0x2e2c4               -[FlutterViewController appOrSceneBecameActive] (FlutterViewController.mm:1036:5)
5  Flutter +0x2e194               -[FlutterViewController applicationBecameActive:] (FlutterViewController.mm:983:3)
6  CoreFoundation +0x2f2d4        ___CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
7  CoreFoundation +0x2ec9c        ____CFXRegistrationPost_block_invoke
8  CoreFoundation +0x2ebe4        __CFXRegistrationPost
9  CoreFoundation +0x2e134        __CFXNotificationPost
10 Foundation +0x2a7a0            -[NSNotificationCenter postNotificationName:object:userInfo:]
11 UIKitCore +0x18c6fc            -[UIApplication _stopDeactivatingForReason:]
12 UIKitCore +0x13ac18            -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]
13 UIKitCore +0x139654            -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
14 UIKitCore +0x138fbc            -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]
15 UIKitCore +0x138e8c            ___186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke
16 UIKitCore +0x138d94            +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:]
17 UIKitCore +0x13861c            __UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion
18 UIKitCore +0x1382cc            -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
19 UIKitCore +0x4bc0a4            ___64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.225
20 UIKitCore +0x137450            -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:]
21 UIKitCore +0x1372c0            -[UIScene scene:didUpdateWithDiff:transitionContext:completion:]
22 UIKitCore +0x137100            -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:]
23 FrontBoardServices +0xe5b0     -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:]
24 FrontBoardServices +0xe2fc     ___94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2
25 FrontBoardServices +0xe198     -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
26 FrontBoardServices +0xe0b4     ___94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke
27 libdispatch.dylib +0x42fc      __dispatch_client_callout
28 libdispatch.dylib +0x7d44      __dispatch_block_invoke_direct
29 FrontBoardServices +0xa51c     __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
30 FrontBoardServices +0xa49c     -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible]
31 FrontBoardServices +0xa374     -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource]
32 CoreFoundation +0x37128        ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
33 CoreFoundation +0x363a4        ___CFRunLoopDoSource0
34 CoreFoundation +0x34bb8        ___CFRunLoopDoSources0
35 CoreFoundation +0x33894        ___CFRunLoopRun
36 CoreFoundation +0x33474        _CFRunLoopRunSpecific
37 GraphicsServices +0x34f4       _GSEventRunModal
38 UIKitCore +0x22c628            -[UIApplication _run]
39 UIKitCore +0x22bc64            _UIApplicationMain
40 Preguntados +0x1bca8           main (main.m:8:22)
41 dyld +0x5dc8                   start
```

### Code sample

n/a

### Screenshots or Video

_No response_

### Logs

Threads Log:

```
Thread 0 - com.apple.main-thread - (TH_STATE_WAITING)
0  libsystem_kernel.dylib +0x1b18 ___psynch_cvwait
1  libsystem_pthread.dylib +0xfd0 __pthread_cond_wait
2  Flutter +0x570f8               std::_LIBCPP_ABI_NAMESPACE::__libcpp_condvar_wait[abi:v15000](_opaque_pthread_cond_t*, _opaque_pthread_mutex_t*) (__threading_support:335:10)
3  Flutter +0x3e95dc              flutter::PlatformView::NotifyCreated() (waitable_event.cc:148:9)
4  Flutter +0x2e2c4               -[FlutterViewController appOrSceneBecameActive] (FlutterViewController.mm:1036:5)
5  Flutter +0x2e194               -[FlutterViewController applicationBecameActive:] (FlutterViewController.mm:983:3)
6  CoreFoundation +0x2f2d4        ___CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__
7  CoreFoundation +0x2ec9c        ____CFXRegistrationPost_block_invoke
8  CoreFoundation +0x2ebe4        __CFXRegistrationPost
9  CoreFoundation +0x2e134        __CFXNotificationPost
10 Foundation +0x2a7a0            -[NSNotificationCenter postNotificationName:object:userInfo:]
11 UIKitCore +0x18c6fc            -[UIApplication _stopDeactivatingForReason:]
12 UIKitCore +0x13ac18            -[_UISceneLifecycleMultiplexer _performBlock:withApplicationOfDeactivationReasons:fromReasons:]
13 UIKitCore +0x139654            -[_UISceneLifecycleMultiplexer _evalTransitionToSettings:fromSettings:forceExit:withTransitionStore:]
14 UIKitCore +0x138fbc            -[_UISceneLifecycleMultiplexer uiScene:transitionedFromState:withTransitionContext:]
15 UIKitCore +0x138e8c            ___186-[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]_block_invoke
16 UIKitCore +0x138d94            +[BSAnimationSettings(UIKit) tryAnimatingWithSettings:fromCurrentState:actions:completion:]
17 UIKitCore +0x13861c            __UISceneSettingsDiffActionPerformChangesWithTransitionContextAndCompletion
18 UIKitCore +0x1382cc            -[_UIWindowSceneFBSSceneTransitionContextDrivenLifecycleSettingsDiffAction _performActionsForUIScene:withUpdatedFBSScene:settingsDiff:fromSettings:transitionContext:lifecycleActionType:]
19 UIKitCore +0x4bc0a4            ___64-[UIScene scene:didUpdateWithDiff:transitionContext:completion:]_block_invoke.225
20 UIKitCore +0x137450            -[UIScene _emitSceneSettingsUpdateResponseForCompletion:afterSceneUpdateWork:]
21 UIKitCore +0x1372c0            -[UIScene scene:didUpdateWithDiff:transitionContext:completion:]
22 UIKitCore +0x137100            -[UIApplicationSceneClientAgent scene:handleEvent:withCompletion:]
23 FrontBoardServices +0xe5b0     -[FBSScene updater:didUpdateSettings:withDiff:transitionContext:completion:]
24 FrontBoardServices +0xe2fc     ___94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke_2
25 FrontBoardServices +0xe198     -[FBSWorkspace _calloutQueue_executeCalloutFromSource:withBlock:]
26 FrontBoardServices +0xe0b4     ___94-[FBSWorkspaceScenesClient _queue_updateScene:withSettings:diff:transitionContext:completion:]_block_invoke
27 libdispatch.dylib +0x42fc      __dispatch_client_callout
28 libdispatch.dylib +0x7d44      __dispatch_block_invoke_direct
29 FrontBoardServices +0xa51c     __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
30 FrontBoardServices +0xa49c     -[FBSMainRunLoopSerialQueue _targetQueue_performNextIfPossible]
31 FrontBoardServices +0xa374     -[FBSMainRunLoopSerialQueue _performNextFromRunLoopSource]
32 CoreFoundation +0x37128        ___CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
33 CoreFoundation +0x363a4        ___CFRunLoopDoSource0
34 CoreFoundation +0x34bb8        ___CFRunLoopDoSources0
35 CoreFoundation +0x33894        ___CFRunLoopRun
36 CoreFoundation +0x33474        _CFRunLoopRunSpecific
37 GraphicsServices +0x34f4       _GSEventRunModal
38 UIKitCore +0x22c628            -[UIApplication _run]
39 UIKitCore +0x22bc64            _UIApplicationMain
40 Preguntados +0x1bca8           main (main.m:8:22)
41 dyld +0x5dc8                   start

Thread 1 - com.apple.uikit.eventfetch-thread - (TH_STATE_WAITING)
0  libsystem_kernel.dylib +0x1174  _mach_msg2_trap
1  libsystem_kernel.dylib +0xf0c   _mach_msg2_internal
2  libsystem_kernel.dylib +0xe24   _mach_msg_overwrite
3  libsystem_kernel.dylib +0xc64   _mach_msg
4  CoreFoundation +0x35b18         ___CFRunLoopServiceMachPort
5  CoreFoundation +0x33a10         ___CFRunLoopRun
6  CoreFoundation +0x33474         _CFRunLoopRunSpecific
7  Foundation +0x2c488             -[NSRunLoop(NSRunLoop) runMode:beforeDate:]
8  Foundation +0x59748             -[NSRunLoop(NSRunLoop) runUntilDate:]
9  UIKitCore +0x18e4a4             -[UIEventFetcher threadMain]
10 Foundation +0xafddc             ___NSThread__start__
11 libsystem_pthread.dylib +0x24d0 __pthread_start

Thread 2 - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0x96cc  ___workq_kernreturn
1 libsystem_pthread.dylib +0x19ac __pthread_wqthread

Thread 3 - com.google.firebase.crashlytics.MachExceptionServer - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0x1174  _mach_msg2_trap
1 libsystem_kernel.dylib +0xf0c   _mach_msg2_internal
2 libsystem_kernel.dylib +0xe24   _mach_msg_overwrite
3 libsystem_kernel.dylib +0xc64   _mach_msg
4 FirebaseCrashlytics +0x18a4c    FIRCLSMachExceptionReadMessage (FIRCLSMachException.c:192:7)
5 libsystem_pthread.dylib +0x24d0 __pthread_start

Thread 4 - KSCrash Exception Handler (Secondary) - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0x1174  _mach_msg2_trap
1 libsystem_kernel.dylib +0xf0c   _mach_msg2_internal
2 libsystem_kernel.dylib +0x5714  _thread_suspend
3 Bugsnag +0x9a44                 ksmachexc_i_handleExceptions (BSG_KSCrashSentry_MachException.c:222:9)
4 libsystem_pthread.dylib +0x24d0 __pthread_start

Thread 5 - KSCrash Exception Handler (Primary) - (TH_STATE_WAITING)
0 libsystem_kernel.dylib +0x1174  _mach_msg2_trap
1 libsystem_kernel.dylib +0xf0c   _mach_msg2_internal
2 libsystem_kernel.dylib +0xe24   _mach_msg_overwrite
3 libsystem_kernel.dylib +0xc64   _mach_msg
4 Bugsnag +0x9a78                 ksmachexc_i_handleExceptions (BSG_KSCrashSentry_MachException.c:229:36)
5 libsystem_pthread.dylib +0x24d0 __pthread_start

```

### 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.1, on macOS 14.2.1 23C71 darwin-arm64, locale en-AR)
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
[✓] Xcode - develop for iOS and macOS (Xcode 15.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2023.1)
[✓] IntelliJ IDEA Community Edition (version 2022.2.2)
[✓] VS Code (version 1.85.1)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!
```

</details>