沙盒继承过程中的NSOpenPanel崩溃问题

7

我有一个在沙盒中运行的应用程序,使用NSTask启动一个助手应用程序包(助手应用程序包包含在应用程序的捆绑包中)。

通过使用正确的授权,主应用程序能够使用NSTask启动助手,并继承了沙盒而没有崩溃。唯一的问题似乎是当我打开NSOpenPanel时,会出现以下崩溃。请注意,当使用NSOpenPanel时,调用者应用程序不会崩溃,只有助手程序会崩溃。

这看起来像是系统中的一个错误,所以如果有人之前遇到过这个问题,可能有一个解决方法。

下面是主应用程序的授权:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.device.usb</key>
    <true/>
    <key>com.apple.security.files.bookmarks.app-scope</key>
    <true/>
    <key>com.apple.security.device.serial</key>
    <true/>
    <key>com.apple.security.network.client</key>
    <true/>
    <key>com.apple.security.files.user-selected.read-write</key>
    <true/>
</dict>
</plist>

助手的权限:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.app-sandbox</key>
    <true/>
    <key>com.apple.security.inherit</key>
    <true/>
</dict>
</plist>

打开NSOpenPanel时崩溃:
2015-12-09 10:35:56.879 Desktops[29807:22090051] -[NSVBSavePanel init] caught non-fatal NSObjectNotAvailableException 'service com.apple.appkit.xpc.openAndSavePanelService failed to init an instance of NSOpenPanelService on behalf of <NSLayerCentricRemoteView: 0x1077fd0> due to {
    callStackSymbols = (
    0   CoreFoundation                      0x00007fff8f375e32 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff855084fa objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff8f3dc65d +[NSException raise:format:] + 205
    3   com.apple.appkit.xpc.openAndSavePanelService 0x000000010879493a com.apple.appkit.xpc.openAndSavePanelService + 6458
    4   AppKit                              0x00007fff87e4a662 -[NSViewController _loadViewIfRequired] + 75
    5   AppKit                              0x00007fff87e4a5cd -[NSViewController view] + 30
    6   ViewBridge                          0x00007fff9180dbab -[NSViewServiceMarshal _bootstrap:replyData:] + 11432
    7   ViewBridge                          0x00007fff9180efb5 -[NSViewServiceMarshal bootstrap:withReply:] + 124
    8   CoreFoundation                      0x00007fff8f2e7b5c __invoking___ + 140
    9   CoreFoundation                      0x00007fff8f2e79ee -[NSInvocation invoke] + 286
    10  CoreFoundation                      0x00007fff8f302e36 -[NSInvocation invokeWithTarget:] + 54
    11  ViewBridge                          0x00007fff91847f01 -[NSVB_ViewServiceImplicitAnimationDecodingProxy forwardInvocation:] + 264
    12  CoreFoundation                      0x00007fff8f2e6472 ___forwarding___ + 514
    13  CoreFoundation                      0x00007fff8f2e61e8 _CF_forwarding_prep_0 + 120
    14  CoreFoundation                      0x00007fff8f2e7b5c __invoking___ + 140
    15  CoreFoundation                      0x00007fff8f2e79ee -[NSInvocation invoke] + 286
    16  CoreFoundation                      0x00007fff8f302e36 -[NSInvocation invokeWithTarget:] + 54
    17  ViewBridge                          0x00007fff918189fa -[NSVB_QueueingProxy forwardInvocation:] + 323
    18  CoreFoundation                      0x00007fff8f2e6472 ___forwarding___ + 514
    19  CoreFoundation                      0x00007fff8f2e61e8 _CF_forwarding_prep_0 + 120
    20  CoreFoundation                      0x00007fff8f2e7b5c __invoking___ + 140
    21  CoreFoundation                      0x00007fff8f2e79ee -[NSInvocation invoke] + 286
    22  CoreFoundation                      0x00007fff8f302e36 -[NSInvocation invokeWithTarget:] + 54
    23  CoreFoundation                      0x00007fff8f2e6472 ___forwarding___ + 514
    24  CoreFoundation                      0x00007fff8f2e61e8 _CF_forwarding_prep_0 + 120
    25  CoreFoundation                      0x00007fff8f2e7b5c __invoking___ + 140
    26  CoreFoundation                      0x00007fff8f2e79ee -[NSInvocation invoke] + 286
    27  ViewBridge                          0x00007fff918573db withHintInProgress + 501
    28  ViewBridge                          0x00007fff91857161 __deferNSXPCInvocationOntoMainThread_block_invoke_2 + 220
    29  ViewBridge                          0x00007fff917f5c3f +[NSViewServiceApplication withHostPID:invoke:] + 46
    30  ViewBridge                          0x00007fff9185702f __deferNSXPCInvocationOntoMainThread_block_invoke + 129
    31  ViewBridge                          0x00007fff91856c3a __deferBlockOntoMainThread_block_invoke_2 + 448
    32  CoreFoundation                      0x00007fff8f30b4dc __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
    33  CoreFoundation                      0x00007fff8f2eadf5 __CFRunLoopDoBlocks + 341
    34  CoreFoundation                      0x00007fff8f2eab5b __CFRunLoopRun + 2347
    35  CoreFoundation                      0x00007fff8f2e9fc8 CFRunLoopRunSpecific + 296
    36  HIToolbox                           0x00007fff86193d55 RunCurrentEventLoopInMode + 235
    37  HIToolbox                           0x00007fff86193b8f ReceiveNextEventCommon + 432
    38  HIToolbox                           0x00007fff861939cf _BlockUntilNextEventMatchingListInModeWithFilter + 71
    39  AppKit                              0x00007fff87e01d96 _DPSNextEvent + 1067
    40  AppKit                              0x00007fff87e011c5 -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
    41  ViewBridge                          0x00007fff917f6c11 -[NSViewServiceApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 73
    42  AppKit                              0x00007fff87df5d28 -[NSApplication run] + 682
    43  AppKit                              0x00007fff87dbefbe NSApplicationMain + 1176
    44  libxpc.dylib                        0x00007fff91ee24f2 _xpc_objc_main + 793
    45  libxpc.dylib                        0x00007fff91ee0f1e xpc_main + 494
    46  ViewBridge                          0x00007fff9181c7b7 xpc_connection_handler + 0
    47  ViewBridge                          0x00007fff917faac9 NSViewServiceApplicationMain + 2818
    48  com.apple.appkit.xpc.openAndSavePanelService 0x00000001087996ec main + 208
    49  libdyld.dylib                       0x00007fff896d85ad start + 1
    50  ???                                 0x0000000000000001 0x0 + 1
);
    name = NSInternalInconsistencyException;
    reason = "+[NSOpenAndSavePanelService loadViewToService:isOpenPanel:appCentric:] : failed entitlements check";
    userInfo = "<null>";
}' with backtrace (
    0   CoreFoundation                      0x904a2c19 __raiseError + 201
    1   libobjc.A.dylib                     0x99387f11 objc_exception_throw + 276
    2   ViewBridge                          0x981b5cff __62-[NSRemoteViewBase advanceToConfigPhase:awaitingWindowRights:]_block_invoke + 0
    3   ViewBridge                          0x981b4518 -[NSRemoteViewBase advanceToConfigPhase] + 49
    4   ViewBridge                          0x981b6645 -[NSRemoteViewBase viewServiceMarshalProxy:withDetailedErrorHandler:] + 228
    5   ViewBridge                          0x981b6ace -[NSRemoteViewBase viewServiceMarshalProxy:withErrorHandler:] + 109
    6   ViewBridge                          0x981b62ce -[NSRemoteViewBase viewServiceMarshalProxy:] + 48
    7   ViewBridge                          0x981a88b5 -[NSRemoteViewBase bridge] + 255
    8   AppKit                              0x94e7e03c -[NSVBSavePanel init] + 689
    9   AppKit                              0x94e7dcfd +[NSSavePanel newRemotePanel] + 357
    10  AppKit                              0x94e7d94f +[NSSavePanel _crunchyRawUnbonedPanel] + 108
    11  AppKit                              0x94e7d8de +[NSOpenPanel openPanel] + 33
    12  Desktops                            0x000c7935 -[TDesktopInfoController choosePicture:] + 101
    13  libobjc.A.dylib                     0x993819e4 -[NSObject performSelector:withObject:] + 70
    14  AppKit                              0x94e7d556 __36-[NSApplication sendAction:to:from:]_block_invoke + 51
    15  libsystem_trace.dylib               0x9a8b13c9 _os_activity_initiate + 85
    16  AppKit                              0x94e7d477 -[NSApplication sendAction:to:from:] + 610
    17  AppKit                              0x94e90e69 -[NSControl sendAction:to:] + 102
    18  AppKit                              0x94e90d5d __26-[NSCell _sendActionFrom:]_block_invoke + 176
    19  libsystem_trace.dylib               0x9a8b13c9 _os_activity_initiate + 85
    20  AppKit                              0x94e90c8c -[NSCell _sendActionFrom:] + 161
    21  AppKit                              0x950ed08d __48-[NSCell trackMouse:inRect:ofView:untilMouseUp:]_block_invoke1010 + 43
    22  libsystem_trace.dylib               0x9a8b13c9 _os_activity_initiate + 85
    23  AppKit                              0x94e8f039 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2744
    24  AppKit                              0x94edb64b -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 809
    25  AppKit                              0x94e8d668 -[NSControl mouseDown:] + 693
    26  AppKit                              0x9547abff -[NSWindow _handleMouseDownEvent:isDelayedEvent:] + 6266
    27  AppKit                              0x9547c406 -[NSWindow _reallySendEvent:isDelayedEvent:] + 2303
    28  AppKit                              0x94e1971f -[NSWindow sendEvent:] + 567
    29  AppKit                              0x94d94bf2 -[NSApplication sendEvent:] + 2919
    30  AppKit                              0x94be807b -[NSApplication run] + 1159
    31  AppKit                              0x94bae6a4 NSApplicationMain + 1630
    32  Desktops                            0x0007b27e +[TAppController Main] + 46
    33  Desktops                            0x00011f7a PASCALMAIN + 90
    34  Desktops                            0x00011f10 main + 32
    35  Desktops                            0x00011ecd start + 253
    36  Desktops                            0x00011df8 start + 40
)

好的,我错过了那部分内容:“请注意,在使用NSOpenPanel时,调用应用程序不会崩溃,只有助手会崩溃。” - kisileno
1
@GenericPtr,你最终找出了是什么原因导致了这个问题吗? - Aᴄʜᴇʀᴏɴғᴀɪʟ
1个回答

3

我也遇到了这个问题。问题最终在于我的应用程序缺少必要的授权,以允许执行此操作。

Add file Read/Write entitlements

在您的项目设置中,找到 App Sandbox > File Access > User Selected File 并选择 Read/Write


1
我知道我不应该发这样的话,但是-谢谢!就是这个。 - solgar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接