# getSaveFilePath

**URL:** https://discourse.libcinder.org/t/getsavefilepath/1845
**Category:** Using Cinder
**Created:** [July 30, 2021, 3:06am UTC](https://discourse.libcinder.org/t/getsavefilepath/1845 "2021-07-30T03:06:50Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![chaim](https://avatars.discourse-cdn.com/v4/letter/c/f4b2a3/32.png) [@chaim](https://discourse.libcinder.org/u/chaim)
#### Post date: [July 30, 2021, 3:06am UTC](https://discourse.libcinder.org/t/getsavefilepath/1845/1 "2021-07-30T03:06:50Z")

</div>

Hello,

getSaveFilePath intermittently causes an assertion within macOS. I can’t figure out the conditions that cause it to happen. In another app I am working on I have had the same problem, and not passing any file types into getSaveFilePath (i.e. no 2nd argument) often helped.

**Assertion failure in -[NSSavePanel \_attachSandboxExtensions:toURL:orURLs:]**

I’ve tried one of the sample apps that uses getSaveFilePath and it doesn’t have this issue (which suggests that something is amiss with my project, but I can’t think of what I might have modified that is relevant). I’m running 10.15.7.

Any tips or thoughts on how to debug?

I’m using the dev branch of libcinder, but I believe I had this issue also with the latest stable release, too. (I’ve made some tweaks to ImGui to update it to its latest release.)

Chaim

```auto
2021-07-29 19:47:46.224255-0700 Castle2d[49141:3256573] Metal API Validation Enabled
2021-07-29 19:47:54.709993-0700 Castle2d[49141:3256573] *** Assertion failure in -[NSSavePanel _attachSandboxExtensions:toURL:orURLs:], /AppleInternal/BuildRoot/Library/Caches/com.apple.xbs/Sources/AppKit/AppKit-1894.60.101/Nav.subproj/OpenAndSavePanelRemote/NSVBOpenAndSavePanels.m:712
2021-07-29 19:47:54.712770-0700 Castle2d[49141:3256573] -[NSSavePanel observeValueForKeyPath:ofObject:change:context:] caught non-fatal NSInternalInconsistencyException 'ROSP: sandbox extension failure: nil result or wrong class type ((null)) for enumerated URL (file:///Users/chaim/Documents/Projects/Castles/Castle2d/assets/maps/box.c2d, /Users/chaim/Documents/Projects/Castles/Castle2d/assets/maps/box.c2d)!' with backtrace (
	0 CoreFoundation 0x00007fff327f5627 __exceptionPreprocess + 250
	1 libobjc.A.dylib 0x00007fff6b6d55bf objc_exception_throw + 48
	2 CoreFoundation 0x00007fff3281e7c8 +[NSException raise:format:arguments:] + 88
	3 Foundation 0x00007fff34f1090d -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 191
	4 AppKit 0x00007fff303decee __53-[NSSavePanel _attachSandboxExtensions:toURL:orURLs:]_block_invoke + 309
	5 CoreFoundation 0x00007fff3276cfc7 __NSARRAY_IS_CALLING_OUT_TO_A_BLOCK__ + 7
	6 CoreFoundation 0x00007fff327837b5 -[__NSSingleObjectArrayI enumerateObjectsWithOptions:usingBlock:] + 80
	7 AppKit 0x00007fff303dea89 -[NSSavePanel _attachSandboxExtensions:toURL:orURLs:] + 125
	8 AppKit 0x00007fff303e3826 -[NSSavePanel _URLsWithSecurityScoped:] + 193
	9 AppKit 0x00007fff303ded27 -[NSSavePanel _attachSandboxExtensionsAndStartAccessing] + 48
	10 AppKit 0x00007fff303df6c2 -[NSSavePanel nameFieldStringValue] + 27
	11 AppKit 0x00007fff303e00d3 -[NSSavePanel completeWithReturnCode:url:urls:] + 259
	12 AppKit 0x00007fff303e2062 -[NSSavePanel observeValueForKeyPath:ofObject:change:context:] + 341
	13 Foundation 0x00007fff34de6d70 NSKeyValueNotifyObserver + 335
	14 Foundation 0x00007fff34ed619c NSKeyValueDidChange + 437
	15 Foundation 0x00007fff34f77eb1 NSKeyValueDidChangeWithPerThreadPendingNotifications + 146
	16 ViewBridge 0x00007fff65533310 __41-[NSViewBridge setObject:forKey:withKVO:]_block_invoke + 360
	17 ViewBridge 0x00007fff655b6d20 withHintInProgress + 472
	18 ViewBridge 0x00007fff65529a33 -[NSViewBridge setObject:forKey:withKVO:] + 856
	19 ViewBridge 0x00007fff6552b136 -[NSViewBridge nonLocalChangeInProgress:block:] + 352
	20 ViewBridge 0x00007fff6552ad93 -[NSRemoteViewMarshal exceptionSafeSetRemoteObject:forKey:withReply:] + 264
	21 ViewBridge 0x00007fff6552ac47 -[NSRemoteViewMarshal setRemoteObject:forKey:withReply:] + 56
	22 CoreFoundation 0x00007fff3275b37c __invoking___ + 140
	23 CoreFoundation 0x00007fff3275b221 -[NSInvocation invoke] + 303
	24 ViewBridge 0x00007fff655283e4 __deferNSXPCInvocationOntoMainThread_block_invoke + 228
	25 ViewBridge 0x00007fff65516e38 __wrapBlockWithVoucher_block_invoke + 37
	26 ViewBridge 0x00007fff65516c07 __deferBlockOntoMainThread_block_invoke_2 + 507
	27 CoreFoundation 0x00007fff3277947c __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12
	28 CoreFoundation 0x00007fff327793c4 __CFRunLoopDoBlocks + 379
	29 CoreFoundation 0x00007fff327788bd __CFRunLoopRun + 2450
	30 CoreFoundation 0x00007fff327778ce CFRunLoopRunSpecific + 462
	31 HIToolbox 0x00007fff313a3abd RunCurrentEventLoopInMode + 292
	32 HIToolbox 0x00007fff313a37d5 ReceiveNextEventCommon + 584
	33 HIToolbox 0x00007fff313a3579 _BlockUntilNextEventMatchingListInModeWithFilter + 64
	34 AppKit 0x00007fff2f9ea039 _DPSNextEvent + 883
	35 AppKit 0x00007fff2f9e8880 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1352
	36 AppKit 0x00007fff2fceaef2 -[NSApplication _doModalLoop:peek:] + 315
	37 AppKit 0x00007fff2fce9c85 __35-[NSApplication runModalForWindow:]_block_invoke_2 + 64
	38 AppKit 0x00007fff2fce9c32 __35-[NSApplication runModalForWindow:]_block_invoke + 70
	39 AppKit 0x00007fff2fce94c4 _NSTryRunModal + 100
	40 AppKit 0x00007fff2fce93a9 -[NSApplication runModalForWindow:] + 128
	41 AppKit 0x00007fff303e3127 -[NSSavePanel runModal] + 145
	42 Castle2d 0x000000010005ad47 _ZN6cinder3app13PlatformCocoa15getSaveFilePathERKN3ghc10filesystem4pathERKNSt3__16vectorINS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEENSC_ISE_EEEE + 503
	43 Castle2d 0x000000010006d6fb _ZN6cinder3app7AppBase15getSaveFilePathERKN3ghc10filesystem4pathERKNSt3__16vectorINS7_12basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEENSC_ISE_EEEE + 43
	44 Castle2d 0x0000000100031469 _ZN11Castle2dApp8saveFileEN3ghc10filesystem4pathEb + 153
	45 Castle2d 0x0000000100031295 _ZN11Castle2dApp7keyDownEN6cinder3app8KeyEventE + 469
	46 Castle2d 0x000000010016abfe _ZN6cinder3app6Window11emitKeyDownEPNS0_8KeyEventE + 190
	47 Castle2d 0x00000001000b4944 -[CinderViewMac keyDown:] + 436
	48 AppKit 0x00007fff2fb90d5d -[NSWindow(NSEventRouting) _reallySendEvent:isDelayedEvent:] + 6512
	49 AppKit 0x00007fff2fb8f1c9 -[NSWindow(NSEventRouting) sendEvent:] + 349
	50 AppKit 0x00007fff2fb8defe -[NSApplication(NSEvent) sendEvent:] + 2826
	51 AppKit 0x00007fff2f9da5bf -[NSApplication run] + 707
	52 Castle2d 0x0000000100149d7f _ZN6cinder3app6AppMac6launchEv + 47
	53 Castle2d 0x0000000100032641 _ZN6cinder3app6AppMac4mainI11Castle2dAppEEvRKNSt3__110shared_ptrINS0_8RendererEEEPKciPKPcRKNS4_8functionIFvPNS0_7AppBase8SettingsEEEE + 417
	54 Castle2d 0x000000010003238c main + 172
	55 libdyld.dylib 0x00007fff6c87dcc9 start + 1
)

```

---

<div class="post-metadata">

### Author: ![lithium](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.libcinder.org/lithium/32/38_2.png) [@lithium](https://discourse.libcinder.org/u/lithium)
#### Post date: [July 30, 2021, 5:13am UTC](https://discourse.libcinder.org/t/getsavefilepath/1845/2 "2021-07-30T05:13:07Z")

</div>

I’d say this is macOS and the moving target that is their security model. It’s possible that the OS is remembering the last folder the `NSSavePanel` was in but the app in question, being sandboxed, doesn’t have access to that folder so it borks. This would explain the sporadic nature since it’s dependent on what you’ve been opening/saving prior to running your app.

You can disable sandboxing for your app, grant it full disk access in the system prefs / security section, or only allow your app to open from folders to which access has been granted.

---

<div class="post-metadata">

### Author: ![chaim](https://avatars.discourse-cdn.com/v4/letter/c/f4b2a3/32.png) [@chaim](https://discourse.libcinder.org/u/chaim)
#### Post date: [July 30, 2021, 6:53pm UTC](https://discourse.libcinder.org/t/getsavefilepath/1845/3 "2021-07-30T18:53:07Z")

</div>

Thanks, Lithium. I’ll explore those routes and report back.
