NSWindow redraws issues / flickers on resize

I recently noticed that some controls (NSTableView and NSOutlineView) in my application flicker when the application window is resized.

I can't figure out why this is happening. I have scaled down my application to the bare minimum: one document window controller with a window containing a schematic view and a button. No background processing, no loading document data, etc.

Here is a screenshot showing the UI snippets when the window is resized:

Sample screenshot

Notice the fragment of the diagram from above, on a white background and the shadow of the offset window.

There is also a baseline graph warning in the console (see below). Not sure if this is related to the problem.

The app runs on Mac OS X 10.10.1, the deployment target and base SDK are set to 10.9.

Console output (not crash):

<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

      

+3


source to share


2 answers


For reference, I have found the root cause, although I cannot explain it.

In applicationDidFinishLaunching:

I initialized a generic window controller instance and showed its window by calling showWindow:nil

. This window contained NSTableView

. This kind of table caused flickering in another outline view (in an unlinked window).



Why? I honestly have no idea. I removed all controls from the window and added an empty table view directly from the Interface Builder palette -> a problem occurs. After deleting the table view, the problem went away.

The solution was to not immediately open the window in applicationDidFinishLaunching:

. Instead, I added a menu to open it later (it was the debug info window).

+6


source


My solution was to bring this window front after very little delay, i.e .:



- (void)awakeFromNib {
    if (WSPreferences.currentApplication.showActivityWindow) {
        // http://stackoverflow.com/questions/27794135/nswindow-redraw-issues-flickers-when-resized
        //
        [self performSelector:@selector(makeKeyAndOrderFront:) withObject:self afterDelay:0.1];
    }
}

      

+1


source







All Articles