【发布时间】:2015-01-06 07:39:03
【问题描述】:
我最近注意到,当我调整应用程序的窗口大小时,我的应用程序中的一些控件(NSTableView 和 NSOutlineView)会闪烁。
我不明白为什么会这样。我将应用程序缩减到最低限度:一个带有包含大纲视图和按钮的窗口的单个文档窗口控制器。无后台处理,不加载文档数据等
这是一个屏幕截图,显示了调整窗口大小时的 UI 片段:
注意顶部轮廓视图的片段,白色背景和偏移窗口阴影。
控制台中还有一个与 Core Graphics 相关的警告(见下文)。不确定是否与问题有关。
应用在 Mac OS X 10.10.1 上运行,部署目标和基础 SDK 设置为 10.9。
控制台输出(不是崩溃):
<Warning>: void CGSUpdateManager::log() const: conn 0x22833 token 0x10dfffffffff3823
<Warning>: Backtrace (at 4250.73):
<Warning>: void CGSUpdateManager::log() const: 0 CoreGraphics 0x00007fff986f5215 CGSBacktraceCreate + 59
<Warning>: void CGSUpdateManager::log() const: 1 CoreGraphics 0x00007fff98714688 _ZN16CGSUpdateManager14disable_updateEv + 84
<Warning>: void CGSUpdateManager::log() const: 2 AppKit 0x00007fff8e4e2de5 -[NSWindow disableScreenUpdatesUntilFlush] + 127
<Warning>: void CGSUpdateManager::log() const: 3 AppKit 0x00007fff8e4a2250 -[NSView _gainedLayerTreeHostAncestor] + 385
<Warning>: void CGSUpdateManager::log() const: 4 AppKit 0x00007fff8e4a20ae -[NSView _recursiveGainedLayerTreeHostAncestor] + 27
<Warning>: void CGSUpdateManager::log() const: 5 AppKit 0x00007fff8e4a667a -[NSScroller _recursiveGainedLayerTreeHostAncestor] + 103
<Warning>: void CGSUpdateManager::log() const: 6 AppKit 0x00007fff8e70da56 -[NSScroller _setSurfaceBacked:] + 213
<Warning>: void CGSUpdateManager::log() const: 7 AppKit 0x00007fff8e67324f -[NSScrollView setScrollerStyle:] + 304
<Warning>: void CGSUpdateManager::log() const: 8 AppKit 0x00007fff8ed0af27 +[NSScrollerImpPair _updateAllScrollerImpPairsForNewRecommendedScrollerStyle:] + 426
<Warning>: void CGSUpdateManager::log() const: 9 CoreFoundation 0x00007fff8b36fcbc __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 12
<Warning>: void CGSUpdateManager::log() const: 10 CoreFoundation 0x00007fff8b2611b4 _CFXNotificationPost + 3140
<Warning>: void CGSUpdateManager::log() const: 11 Foundation 0x00007fff8b5f8ea1 -[NSNotificationCenter postNotificationName:object:userInfo:] + 66
<Warning>: void CGSUpdateManager::log() const: 12 CoreFoundation 0x00007fff8b2d154c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
<Warning>: void CGSUpdateManager::log() const: 13 CoreFoundation 0x00007fff8b2c3655 __CFRunLoopDoBlocks + 341
<Warning>: void CGSUpdateManager::log() const: 14 CoreFoundation 0x00007fff8b2c2e0e __CFRunLoopRun + 910
<Warning>: void CGSUpdateManager::log() const: 15 CoreFoundation 0x00007fff8b2c2838 CFRunLoopRunSpecific + 296
<Warning>: void CGSUpdateManager::log() const: 16 HIToolbox 0x00007fff9980043f RunCurrentEventLoopInMode + 235
<Warning>: void CGSUpdateManager::log() const: 17 HIToolbox 0x00007fff998000be ReceiveNextEventCommon + 179
<Warning>: void CGSUpdateManager::log() const: 18 HIToolbox 0x00007fff997ffffb _BlockUntilNextEventMatchingListInModeWithFilter + 71
<Warning>: void CGSUpdateManager::log() const: 19 AppKit 0x00007fff8e4266d1 _DPSNextEvent + 964
<Warning>: void CGSUpdateManager::log() const: 20 AppKit 0x00007fff8e425e80 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 194
<Warning>: void CGSUpdateManager::log() const: 21 AppKit 0x00007fff8e419e23 -[NSApplication run] + 594
<Warning>: void CGSUpdateManager::log() const: 22 AppKit 0x00007fff8e4052d4 NSApplicationMain + 1832
<Warning>: void CGSUpdateManager::log() const: 23 MyApp 0x00000001000022eb main + 75
<Warning>: void CGSUpdateManager::log() const: 24 libdyld.dylib 0x00007fff97a025c9 start + 1
【问题讨论】:
-
那么问题是什么?如何避免闪烁或如何解决崩溃?如果是后者,那么我们需要查看一些代码。
-
@Droppy 问题是什么可能导致闪烁。控制台输出不是崩溃,只是警告。我不知道它是否直接相关(但可能)。
-
我会说这是相关的;除非您在视图中进行大量自定义绘图,否则您不会注意到任何闪烁。
-
没有自定义绘图,只有屏幕截图中的窗口。我无法在另一个测试项目中重现这个,所以我怀疑这个项目的 Xcode 构建设置或另一个干扰绘图的库......
标签: macos cocoa core-graphics nswindow