Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't run metal with validation layer on Xcode #659

Closed
Jasper-Bekkers opened this issue Oct 2, 2024 · 3 comments
Closed

Can't run metal with validation layer on Xcode #659

Jasper-Bekkers opened this issue Oct 2, 2024 · 3 comments
Labels
A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates bug Something isn't working duplicate This issue or pull request already exists

Comments

@Jasper-Bekkers
Copy link

Jasper-Bekkers commented Oct 2, 2024

I'm trying to run a simple app in Xcode to test our conversion to objc2 which runs somewhat fine outside of Xcode (we can render stuff at least).

However, when running under Xcode with the validation layers enabled for metal, we get the following error:

thread `main` panicked at `invalid message send to -[CaptureMTLDevice supportsRaytracing]: method not found

Could it be that objc2 gets confused because now we're talking to a CaptureMTLDevice rather then a MTLDevice?

I think it's mostly complaining here because this is the first function we call at startup (or one of the first), if I comment this out it complains about the next function.

@Jasper-Bekkers
Copy link
Author

[2024-10-02][11:29:43][panic][�[31mERROR�[0m] thread 'main' panicked at 'invalid message send to -[CaptureMTLDevice supportsRaytracing]: method not found': /Users/jasperbekkers/.cargo/git/checkouts/objc2-130a98fc7e75e93f/c85f91e/framework-crates/objc2-metal/src/generated/MTLDevice.rs:532
   0: backtrace::backtrace::libunwind::trace
             at /Users/jasperbekkers/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/libunwind.rs:93:5
      backtrace::backtrace::trace_unsynchronized
             at /Users/jasperbekkers/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:66:5
      backtrace::backtrace::trace
             at /Users/jasperbekkers/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/backtrace/mod.rs:53:14
      backtrace::capture::Backtrace::create
             at /Users/jasperbekkers/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:176:9
      backtrace::capture::Backtrace::new
             at /Users/jasperbekkers/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.69/src/capture.rs:140:22
   1: log_panics::Config::install_panic_hook::{{closure}}
             at /Users/jasperbekkers/.cargo/registry/src/index.crates.io-6f17d22bba15001f/log-panics-2.1.0/src/lib.rs:115:29
   2: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/alloc/src/boxed.rs:2036:9
      std::panicking::rust_panic_with_hook
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:799:13
   3: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:664:13
   4: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:171:18
   5: rust_begin_unwind
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:652:5
   6: core::panicking::panic_fmt
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/panicking.rs:72:14
   7: objc2::runtime::message_receiver::panic_verify
   8: objc2::runtime::message_receiver::msg_send_check_class
             at /Users/jasperbekkers/.cargo/git/checkouts/objc2-130a98fc7e75e93f/c85f91e/crates/objc2/src/runtime/message_receiver.rs:331:5
      objc2::runtime::message_receiver::msg_send_check
             at /Users/jasperbekkers/.cargo/git/checkouts/objc2-130a98fc7e75e93f/c85f91e/crates/objc2/src/runtime/message_receiver.rs:308:5
   9: objc2::runtime::message_receiver::MessageReceiver::send_message
             at /Users/jasperbekkers/.cargo/git/checkouts/objc2-130a98fc7e75e93f/c85f91e/crates/objc2/src/runtime/message_receiver.rs:423:13
      objc2::__macro_helpers::msg_send::MsgSend::send_message
             at /Users/jasperbekkers/.cargo/git/checkouts/objc2-130a98fc7e75e93f/c85f91e/crates/objc2/src/__macro_helpers/msg_send.rs:26:31
      objc2_metal::generated::__MTLDevice::MTLDevice::supportsRaytracing
             at /Users/jasperbekkers/.cargo/git/checkouts/objc2-130a98fc7e75e93f/c85f91e/crates/objc2/src/macros/extern_protocol.rs:265:14
      <breda_render_backend_metal::device::Device as breda_render_backend_api::DevicePipelineCreateExt>::capabilities
             at /Users/jasperbekkers/traverse/breda/crates/breda-render-backend-metal/src/device.rs:803:44
  10: evolve::internal_main::{{closure}}
             at /Users/jasperbekkers/traverse/evolve/crates/evolve/src/lib.rs:1263:23
  11: <core::slice::iter::Iter<T> as core::iter::traits::iterator::Iterator>::find
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/slice/iter/macros.rs:300:24
  12: evolve::internal_main
             at /Users/jasperbekkers/traverse/evolve/crates/evolve/src/lib.rs:1261:9
  13: evolve::main
             at /Users/jasperbekkers/traverse/evolve/crates/evolve/src/main.rs:6:5
  14: core::ops::function::FnOnce::call_once
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:250:5
  15: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/sys_common/backtrace.rs:155:18
  16: std::rt::lang_start::{{closure}}
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:159:18
  17: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/core/src/ops/function.rs:284:13
      std::panicking::try::do_call
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:559:40
      std::panicking::try
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:523:19
      std::panic::catch_unwind
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs:149:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:141:48
      std::panicking::try::do_call
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:559:40
      std::panicking::try
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panicking.rs:523:19
      std::panic::catch_unwind
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/panic.rs:149:14
      std::rt::lang_start_internal
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:141:20
  18: std::rt::lang_start
             at /rustc/129f3b9964af4d4a709d1383930ade12dfe7c081/library/std/src/rt.rs:158:17
  19: _main

Program ended with exit code: 101

@Jasper-Bekkers
Copy link
Author

Alright so this seems to be a problem with the debug functionality of this crate in msg_send_check, I think msg_send_check is making an incorrect assumption based on common usage patterns (e.g. you don't expect the instantiated class type to be pulled out from under you by the runtime environment).

Running in release mode works at least now as a work-around.

@madsmtm madsmtm added bug Something isn't working duplicate This issue or pull request already exists A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates labels Oct 2, 2024
@madsmtm
Copy link
Owner

madsmtm commented Oct 2, 2024

Yeah, it's a duplicate of #645 (which we should definitely fix), see that for a workaround as well.

@madsmtm madsmtm closed this as completed Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-objc2 Affects the `objc2`, `objc2-exception-helper` and/or `objc2-encode` crates bug Something isn't working duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants