Re: [Solved] Crash in addSubview: when compiled with SDK > 10.9
Re: [Solved] Crash in addSubview: when compiled with SDK > 10.9
- Subject: Re: [Solved] Crash in addSubview: when compiled with SDK > 10.9
- From: Konidaris Christos <email@hidden>
- Date: Thu, 03 Nov 2016 17:00:06 +0200
> On 2 Nov 2016, at 19:24, Quincey Morris <email@hidden> wrote:
>
> On Nov 2, 2016, at 10:00 , Konidaris Christos <email@hidden> wrote:
>>
>> Our application crashes inside AppKit when compiled with any SDK > 10.9. The crash happens at the following point in the program:
>>
>> activityPaneController = [[ESC_ActivityPaneController alloc] initWithNibName: @“ESC_ActivitySideBox" bundle: nil];
>> [superV addSubview: activityPaneController.view];
>
> To be precise, this is two points in the program (or more than two, if we decide to be pedantic).
>
>> Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
>> 0 com.apple.AppKit 0x00007fffd366a733 -[NSViewController _viewDidMoveToWindow:fromWindow:unhiding:] + 78
>> 1 com.apple.AppKit 0x00007fffd3601e12 -[NSView _setWindow:] + 3209
>> 2 com.apple.CoreFoundation 0x00007fffd599ee12 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 114
>> 3 com.apple.CoreFoundation 0x00007fffd599eccf -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 239
>> 4 com.apple.AppKit 0x00007fffd3e26bfb __21-[NSView _setWindow:]_block_invoke.643 + 151
>> 5 com.apple.AppKit 0x00007fffd3601d1e -[NSView _setWindow:] + 2965
>> 6 com.apple.CoreFoundation 0x00007fffd599ee12 __53-[__NSArrayM enumerateObjectsWithOptions:usingBlock:]_block_invoke + 114
>> 7 com.apple.CoreFoundation 0x00007fffd599eca6 -[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 198
>> 8 com.apple.AppKit 0x00007fffd3e26bfb __21-[NSView _setWindow:]_block_invoke.643 + 151
>> 9 com.apple.AppKit 0x00007fffd3601d1e -[NSView _setWindow:] + 2965
>> 10 com.apple.AppKit 0x00007fffd35fe4c5 -[NSView addSubview:] + 461
>> 11 gr.escape.esc 0x000000010380a729 -[ESCSideBarController initialiseForWindow:andView:] + 985 (ESCSideBarController.mm:119)
>> 12 gr.escape.esc 0x00000001037ccb29 -[ESCMainWindowController windowDidLoad] + 713
>> 13 com.apple.AppKit 0x00007fffd368fcd4 -[NSWindowController _windowDidLoad] + 682
>> 14 com.apple.AppKit 0x00007fffd362ff83 -[NSWindowController window] + 110
>> 15 com.apple.AppKit 0x00007fffd380bc0e -[NSWindowController showWindow:] + 36
>
> According to line 11 of this backtrace, the view controller whose view led to the crash is a ESCSideBarController, not a ESC_ActivityPaneController. Unless you did something tricksy with #define, neither of the above 2 points in the program is where the crash happened.
>
>> The code loads 3 NSBoxes from separate NIBs and (tries) to add them as subviews to an NSBox in the main program window. The program works if we compile it with the 10.9 SDK. It crashes when compiled with any later SDK (10.10, 10.11, 10.12, Latest macOS). I am using Xcode 8.1 on 10.12.1. No ARC, no Storyboards and no AutoLayout are used in these parts of the program. I include below the crash-log.
>
> So, you crash when loading views with view controllers, and it fails when compiled against 10.10+ SDK. The thing that changed in macOS 10.10 is that view controllers are automatically added to the responder chain, provided that you link against 10.10 SDK or higher. Do you have “legacy” code that used to do this manually? That would certainly lead to unhappiness.
The problem was that my NIBs also contained NSViewController objects for some of their subviews. Changing these controllers to plain NSObjects eliminated the crashes.
Thank you for pointing me to the correct direction.
Regards,
– Christos
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden