NSSplitViewCrashes when subview is removed during drag
Originator: | gnachman | ||
Number: | rdar://42411126 | Date Originated: | 7/19/2018 |
Status: | Open | Resolved: | |
Product: | AppKit | Product Version: | 10.13 |
Classification: | Reproducible: | Always |
Area: AppKit Summary: Remove a subview from an NSSplitView while it is being dragged. It throws an exception. Steps to Reproduce: 1. Install https://developer.apple.com/library/archive/samplecode/SplitViews/Introduction/Intro.html 2. Modify -[AppDelegate doVerticalSplit:] to remove the second subview of the splitview after a delay* 3. Run the app 4. Open the vertical split window 5. Drag the divider and keep dragging until the subview is removed * Add this to -doVerticalSplit: dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ NSView *view = _verticalSplitWindController.window.contentView.subviews[0].subviews[1]; [view removeFromSuperview]; }); Expected Results: A graceful exit. While dragging happens in a tracking runloop, the application still has plenty of opportunities to modify its view hierarchy. In my case, a subview is removed when a child process terminates. It's overly burdensome to expect the application to check if a drag is in progress when it modifies a split view's subviews. This is also hard to work around because once -[NSSplitView mouseDown:] is called the application has way to tell the splitview to cancel an ongoing drag. Catching the exception is risky since it could leave the splitview in an inconsistent state. Actual Results: frame #0: 0x00007fff68543c46 libobjc.A.dylib`objc_exception_throw frame #1: 0x00007fff41489b6f CoreFoundation`-[__NSSingleObjectArrayI objectAtIndex:] + 111 frame #2: 0x00007fff3ea962e5 AppKit`-[NSSplitView _presentDividerDragResult:withParams:] + 1558 frame #3: 0x00007fff3ec6ab76 AppKit`-[NSSplitView mouseDown:] + 1504 frame #4: 0x00007fff3f211d6d AppKit`-[NSWindow(NSEventRouting) _handleMouseDownEvent:isDelayedEvent:] + 5891 frame #5: 0x00007fff3f20e9c4 AppKit`-[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 2359 frame #6: 0x00007fff3f20dc70 AppKit`-[NSWindow(NSEventRouting) sendEvent:] + 497 frame #7: 0x00007fff3f06f236 AppKit`-[NSApplication(NSEvent) sendEvent:] + 2462 frame #8: 0x00007fff3e8cf8b5 AppKit`-[NSApplication run] + 812 frame #9: 0x00007fff3e89ea72 AppKit`NSApplicationMain + 804 * frame #10: 0x0000000100001df2 SplitViews`main(argc=3, argv=0x00007ffeefbff5e8) at main.m:13 frame #11: 0x0000000100001dc4 SplitViews`start + 52 Version/Build: 10.13 SDK macOS 10.13.5 Configuration:
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!