You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

NavigationSplitView中Popover/Sheet崩溃及异常问题问询

关于macOS下NavigationSplitView结合NavigationStack展示Popover/Sheet的崩溃问题

问题描述

  • 在macOS平台,当NavigationSplitView与NavigationStack结合使用,且通过NavigationPath推入的非根视图中展示Popover或Sheet时,应用会出现异常行为或崩溃(已在Xcode Beta 2、Beta 3验证,iPadOS上运行完全正常)。
  • 仅在存在NavigationSplitView的场景下触发崩溃,单独使用NavigationStack无任何问题。
  • 伴随异常现象:启动应用时隐藏侧边栏,在根视图展示Popover/Sheet后,侧边栏会自动展开。
  • 已准备好最小化复现的测试项目。

崩溃日志(中文翻译版)

2022-10-14 21:50:15.886600+0400 IssueTest[16220:537280] [通用] 窗口已被标记为需要再次执行窗口约束更新流程,但当前执行的窗口约束更新次数已超过窗口中的视图数量。
<SwiftUI.AppKitWindow: 0x15d023de0> 0xa0d (2573) {{830, 361}, {900, 584}} en 未来标记的窗口约束更新需求可能会被忽略。
2022-10-14 21:50:15.893015+0400 IssueTest[16220:537280] [通用] 窗口已被标记为需要再次执行窗口约束更新流程,但当前执行的窗口约束更新次数已超过窗口中的视图数量。
<SwiftUI.AppKitWindow: 0x15d023de0> 0xa0d (2573) {{830, 361}, {900, 584}} en
2022-10-14 21:50:15.896399+0400 IssueTest[16220:537280] [通用] (
    0   CoreFoundation                      0x000000019fab4418 __exceptionPreprocess + 176
    1   libobjc.A.dylib                     0x000000019f5feea8 objc_exception_throw + 60
    2   CoreFoundation                      0x000000019fab42bc +[NSException exceptionWithName:reason:userInfo:] + 0
    3   AppKit                              0x00000001a2cc0d04 -[NSWindow(NSDisplayCycle) _postWindowNeedsUpdateConstraintsUnlessPostingDisabled] + 1844
    4   AppKit                              0x00000001a2caaddc -[NSView _informContainerThatSubviewsNeedUpdateConstraints] + 64
    5   AppKit                              0x00000001a2caaddc -[NSView _informContainerThatSubviewsNeedUpdateConstraints] + 64
    6   AppKit                              0x00000001a2caaddc -[NSView _informContainerThatSubviewsNeedUpdateConstraints] + 64
    7   AppKit                              0x00000001a2caaddc -[NSView _informContainerThatSubviewsNeedUpdateConstraints] + 64
    8   AppKit                              0x00000001a2caaddc -[NSView _informContainerThatSubviewsNeedUpdateConstraints] + 64
    9   AppKit                              0x00000001a2caad60 -[NSView setNeedsUpdateConstraints:] + 460
    10  AppKit                              0x00000001a3699a10 -[NSView(NSConstraintBasedLayoutInternal) _prepareForTwoPassConstraintsUpdateIfNeeded] + 364
    11  AppKit                              0x00000001a2d15790 -[NSView updateConstraints] + 24
    12  SwiftUI                             0x00000001c75be970 OUTLINED_FUNCTION_11 + 53928
    13  SwiftUI                             0x00000001c75be99c OUTLINED_FUNCTION_11 + 53972
    14  AppKit                              0x00000001a345c8d0 ___NSViewUpdateConstraints_block_invoke + 88
    15  AppKit                              0x00000001a2cd2700 NSPerformVisuallyAtomicChange + 108
    16  AppKit                              0x00000001a2d1576c _NSViewUpdateConstraints + 96
    17  AppKit                              0x00000001a2d1549c -[NSView _updateConstraintsForSubtreeIfNeededCollectingViewsWithInvalidBaselines:] + 692
    18  AppKit                              0x00000001a2d210dc __82-[NSView _updateConstraintsForSubtreeIfNeededCollectingViewsWithInvalidBaselines:]_block_invoke + 228
    19  CoreAutoLayout                      0x00000001a770a514 -[NSISEngine withBehaviors:performModifications:] + 88
    20  AppKit                              0x00000001a2d152b0 -[NSView _updateConstraintsForSubtreeIfNeededCollectingViewsWithInvalidBaselines:] + 200
    21  AppKit                              0x00000001a2d15358 -[NSView _updateConstraintsForSubtreeIfNeededCollectingViewsWithInvalidBaselines:] + 368
    22  AppKit                              0x00000001a2d15358 -[NSView _updateConstraintsForSubtreeIfNeededCollectingViewsWithInvalidBaselines:] + 368
    23  AppKit                              0x00000001a2d15358 -[NSView _updateConstraintsForSubtreeIfNeededCollectingViewsWithInvalidBaselines:] + 368
    24  AppKit                              0x00000001a2d15358 -[NSView _updateConstraintsForSubtreeIfNeededCollectingViewsWithInvalidBaselines:] + 368
    25  AppKit                              0x00000001a3452980 __45-[NSView updateConstraintsForSubtreeIfNeeded]_block_invoke_2 + 52
    26  AppKit                              0x00000001a2d15068 __45-[NSView updateConstraintsForSubtreeIfNeeded]_block_invoke + 224
    27  AppKit                              0x00000001a2cd2700 NSPerformVisuallyAtomicChange + 108
    28  AppKit                              0x00000001a2d14f7c -[NSView updateConstraintsForSubtreeIfNeeded] + 96
    29  AppKit                              0x00000001a36a0088 -[NSWindow(NSConstraintBasedLayoutInternal) updateConstraintsIfNeeded] + 172
    30  AppKit                              0x00000001a2d35e88 __NSWindowGetDisplayCycleObserverForUpdateConstraints_block_invoke + 364
    31  AppKit                              0x00000001a2d35ce8 NSDisplayCycleObserverInvoke + 168
    32  AppKit                              0x00000001a2d35944 NSDisplayCycleFlush + 644
    33  QuartzCore                          0x00000001a7081bb0 _ZN2CA11Transaction19run_commit_handlersE18CATransactionPhase + 120
    34  QuartzCore                          0x00000001a7080930 _ZN2CA11Transaction6commitEv + 324
    35  AppKit                              0x00000001a2db7bc4 __62+[CATransaction(NSCATransaction) NS_setFlushesWithDisplayLink]_block_invoke + 272
    36  AppKit                              0x00000001a3494760 ___NSRunLoopObserverCreateWithHandler_block_invoke + 64
    37  CoreFoundation                      0x000000019fa38de4 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 36
    38  CoreFoundation                      0x000000019fa38cd0 __CFRunLoopDoObservers + 532
    39  CoreFoundation                      0x000000019fa38308 __CFRunLoopRun + 784
    40  CoreFoundation                      0x000000019fa378a4 CFRunLoopRunSpecific + 612
    41  HIToolbox                           0x00000001a90ae3bc RunCurrentEventLoopInMode + 292
    42  HIToolbox                           0x00000001a90ae200 ReceiveNextEventCommon + 672
    43  HIToolbox                           0x00000001a90adf48 _BlockUntilNextEventMatchingListInModeWithFilter + 72
    44  AppKit                              0x00000001a2c8f664 _DPSNextEvent + 632
    45  AppKit                              0x00000001a2c8e7f4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 728
    46  AppKit                              0x00000001a2c82c24 -[NSApplication run] + 464
    47  AppKit                              0x00000001a2c5a08c NSApplicationMain + 880
    48  SwiftUI                             0x00000001c63c805c OUTLINED_FUNCTION_8 + 8244
    49  SwiftUI                             0x00000001c75b1784 OUTLINED_FUNCTION_11 + 188
    50  SwiftUI                             0x00000001c6df09c8 OUTLINED_FUNCTION_1 + 136
    51  IssueTest                           0x00000001049c6de8 $s9IssueTest0aB3AppV5$mainyyFZ + 40
    52  IssueTest                           0x00000001049c6f80 main + 12
    53  dyld                                0x000000019f62fe50 start + 2544
)

判断与解决方案

这是SwiftUI在macOS Beta版本中的框架Bug,而非代码实现问题,理由如下:

  1. 仅在NavigationSplitView与NavigationStack组合使用时触发,单独使用NavigationStack无异常,排除业务逻辑错误。
  2. iPadOS上运行正常,说明是macOS平台特定的布局适配问题。
  3. 崩溃日志显示约束更新进入无限循环,属于布局系统内部逻辑错误,非开发者代码能直接导致。

临时规避方案

  • 更新至最新Xcode Beta版本,确认是否已修复该问题。
  • 在非根视图展示Popover/Sheet前,临时隐藏NavigationSplitView的侧边栏,展示完成后再恢复。
  • 改用自定义弹窗替代系统Popover/Sheet组件。

长期解决

向Apple反馈该Bug,提交测试项目和崩溃日志,帮助官方修复问题。

内容的提问来源于stack exchange,提问作者devon't

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 20:45:30