I'm trying to serialize a MTLBinaryArchive to a file inside the application bundle caches directory.
unsafe {
binary_archive.addFunctionWithDescriptor_library_error(&fragment_desc, &fragment)?;
binary_archive.addFunctionWithDescriptor_library_error(&vertex_desc, &vertex)?;
}
unsafe {
let manager = NSFileManager::defaultManager();
let application_support =manager
.URLsForDirectory_inDomains(NSSearchPathDirectory::NSCachesDirectory, NSSearchPathDomainMask::NSUserDomainMask);
let metal_lib = application_support.first().unwrap().URLByAppendingPathComponent(ns_string!("librashader.metallib"))
.unwrap();
eprintln!("{:?}", metal_lib);
if let Err(e) = binary_archive.serializeToURL_error(&metal_lib) {
eprintln!("{:?}", e.localizedDescription());
}
}
This is panicking unexpectedly with objc2 generated code
URL { __superclass: file:///Users/chyyran/Library/Containers/red.snowflakepow.librashader-objctest/Data/Library/Caches/librashader.metallib }
thread '<unnamed>' panicked at /Users/chyyran/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc2-metal-0.2.2/src/generated/MTLBinaryArchive.rs:79:1:
error parameter should be set if the method returns NO
stack backtrace:
0: _rust_begin_unwind
1: core::panicking::panic_fmt
2: core::option::expect_failed
3: core::option::Option<T>::expect
at /rustc/adf8d168af9334a8bf940824fcf4207d01e05ae5/library/core/src/option.rs:928:21
4: objc2::__macro_helpers::msg_send::encountered_error
at /Users/chyyran/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc2-0.5.2/src/__macro_helpers/msg_send.rs:153:5
5: objc2::__macro_helpers::msg_send::MsgSend::send_message_error
at /Users/chyyran/.cargo/registry/src/index.crates.io-6f17d22bba15001f/objc2-0.5.2/src/__macro_helpers/msg_send.rs:95:26
6: objc2_metal::generated::__MTLBinaryArchive::MTLBinaryArchive::serializeToURL_error
How I'm debugging this is a little complex so it might just be easier to give repro instructions.
$ git clone https://github.com/SnowflakePowered/librashader
$ git checkout metal-shader-cache
$ git submodule update --init
$ cd librashader-runtime-mtl
$ cargo test triangle -- --test-threads=1
This won't actually give you the full unwind message though due to C-unwind ABI changes, but I wrapped it in catch_unwind in the repro branch (https://github.com/SnowflakePowered/librashader/tree/metal-shader-cache) to get more of that out. I got this backtrace via a very finicky debug setup with C ABI bindings and running within XCode so it's too complicated to set up compared to just the cargo test.
I'm trying to serialize a
MTLBinaryArchiveto a file inside the application bundle caches directory.This is panicking unexpectedly with objc2 generated code
How I'm debugging this is a little complex so it might just be easier to give repro instructions.
This won't actually give you the full unwind message though due to C-unwind ABI changes, but I wrapped it in
catch_unwindin the repro branch (https://github.com/SnowflakePowered/librashader/tree/metal-shader-cache) to get more of that out. I got this backtrace via a very finicky debug setup with C ABI bindings and running within XCode so it's too complicated to set up compared to just thecargo test.