macOS Metal Issue - App Crashes Immediately

Henry M <[email protected]>
Newsgroups gmane.comp.lib.wxwindows.general
Message-ID <[email protected]>
I have no issues building and running my wxWidgets project with Xcode 14 on 
macOS 12.7. However, when building it and running it with Xcode 15 on macOS 
14.4, the app crashes once it gets to this line: wxIMPLEMENT_APP(myApp);

I first thought the crash was due to an outdated wxWidgets build, so I 
rebuilt it with the following commands, but that didn't fix it.

git clone --recurse-submodules 
https://github.com/wxWidgets/wxWidgets.git ./configure --disable-sys-libs 
--enable-macosx_arch=x86_64,arm64 make -j5

The stack trace shows that the crash comes from an instruction in 
MTLInputStageReflectionReader::deserialize(id<MTLDeviceSPI>, 
NSObject<OS_dispatch_data>*, NSObject<OS_dispatch_data>) (), which is is a 
Metal library.

Does anyone have any ideas where I should start looking to fix this issue?


Full stack trace: 
Thread 1:
* thread #1, queue = 'com.apple.main-thread' frame #0: 0x00007ff80e105b3e 
libsystem_kernel.dylib`kevent_id + 10 frame #1: 0x00000001011da866 
libdispatch.dylib`_dispatch_kq_poll + 169 frame #2: 0x00000001011db313 
libdispatch.dylib`_dispatch_event_loop_wait_for_ownership + 519 frame #3: 
0x00000001011c7adb libdispatch.dylib`__DISPATCH_WAIT_FOR_QUEUE__ + 305 
frame #4: 0x00000001011c72a5 libdispatch.dylib`_dispatch_sync_f_slow + 222 
frame #5: 0x00007ff816834708 
QuartzCore`CABackingStoreGetFrontTexture(CABackingStore*, CGColorSpace*) + 
180 frame #6: 0x00007ff8168255ce QuartzCore`-[NSObject(CARenderValue) 
CA_prepareRenderValue] + 175 frame #7: 0x00007ff816a6a005 
QuartzCore`CA::Layer::prepare_contents(CALayer*, CA::Transaction*) + 183 
frame #8: 0x00007ff816822137 
QuartzCore`CA::Layer::prepare_commit(CA::Transaction*) + 293 frame #9: 
0x00007ff8169b4e64 
QuartzCore`CA::Context::commit_transaction(CA::Transaction*, double, 
double*) + 978 frame #10: 0x00007ff8167fdd31 
QuartzCore`CA::Transaction::commit() + 725 frame #11: 0x00007ff8119e234d 
AppKit`__62+[CATransaction(NSCATransaction) 
NS_setFlushesWithDisplayLink]_block_invoke + 285 frame #12: 
0x00007ff8124cfe59 
AppKit`___NSRunLoopObserverCreateWithHandler_block_invoke + 41 frame #13: 
0x00007ff80e21ffa6 
CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ 
+ 23 frame #14: 0x00007ff80e21feca CoreFoundation`__CFRunLoopDoObservers + 
493 frame #15: 0x00007ff80e21f44c CoreFoundation`__CFRunLoopRun + 850 frame 
#16: 0x00007ff80e21eb32 CoreFoundation`CFRunLoopRunSpecific + 557 frame 
#17: 0x00007ff818c30829 HIToolbox`RunCurrentEventLoopInMode + 292 frame 
#18: 0x00007ff818c30466 HIToolbox`ReceiveNextEventCommon + 201 frame #19: 
0x00007ff818c30381 
HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 66 frame #20: 
0x00007ff811886be5 AppKit`_DPSNextEvent + 880 frame #21: 0x00007ff812196fe9 
AppKit`-[NSApplication(NSEventRouting) 
_nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1273 frame #22: 
0x00007ff811878005 AppKit`-[NSApplication run] + 603 frame #23: 
0x0000000102890c6a 
libwx_osx_cocoau_core-3.3.0.0.0.dylib`wxGUIEventLoop::OSXDoRun() + 186 
frame #24: 0x000000010161147d 
libwx_baseu-3.3.0.0.0.dylib`wxCFEventLoop::DoRun() + 29 frame #25: 
0x0000000101548abe libwx_baseu-3.3.0.0.0.dylib`wxEventLoopBase::Run() + 158 
frame #26: 0x0000000101511193 
libwx_baseu-3.3.0.0.0.dylib`wxAppConsoleBase::MainLoop() + 99 frame #27: 
0x00000001028182ba libwx_osx_cocoau_core-3.3.0.0.0.dylib`wxApp::OnRun() + 
26 frame #28: 0x000000010158a5b9 libwx_baseu-3.3.0.0.0.dylib`wxEntry(int&, 
wchar_t**) + 169 * frame #29: 0x00000001000065f3 ctrl+cam`main(argc=1, 
argv=0x00007ff7bfeff668) at Main.cpp:37:1 frame #30: 0x00007ff80ddb8366 
dyld`start + 1942 Thread 2:
* thread #2, queue = 'CA::CG::Queue', stop reason = EXC_BAD_ACCESS (code=1, 
address=0x700003f8e822) * frame #0: 0x000000010308c0e0 
MetalOld.dylib`MTLInputStageReflectionReader::deserialize(id<MTLDeviceSPI>, 
NSObject<OS_dispatch_data>*, NSObject<OS_dispatch_data>) + 222 frame #1: 
0x0000000103117f87 MetalOld.dylib`-[MTLRenderPipelineReflectionInternal 
initWithVertexData:fragmentData:serializedVertexDescriptor:device:options:flags:] 
+ 207 frame #2: 0x00000001030f8823 
MetalOld.dylib`newRenderPipeline(MTLProgramObject*, MTLFunctionVariant*, 
MTLProgramObject*, MTLFunctionVariant*, MTLProgramObject*, 
MTLFunctionVariant*, NSObject<OS_dispatch_data>*, MTLProgramObject*, 
MTLFunctionVariant*, NSObject<OS_dispatch_data>*, _MTLDevice*, 
NSObject<OS_dispatch_data>*, MTLRenderPipelineDescriptor*, unsigned long, 
unsigned long, MTLRenderPipelineReflection**, NSMutableDictionary*, 
NSObject<OS_dispatch_data>*, NSObject<OS_dispatch_data>*, void 
(id<MTLRenderPipelineState>, MTLRenderPipelineReflection*, NSError*) 
block_pointer, NSError*) + 590 frame #3: 0x00000001030ffb9b 
MetalOld.dylib`__252-[MTLCompiler 
createVertexStageAndLinkPipelineWithFragment:fragmentVariant:vertexFunction:serializedVertexDescriptor:descriptor:destinationArchive:options:reflection:compileStatistics:fragmentCompileTimeData:pipelineArchiverId:error:completionHandler:]_block_invoke_2 
+ 395 frame #4: 0x00000001030fef3a MetalOld.dylib`-[MTLCompiler 
createVertexStageAndLinkPipelineWithFragment:fragmentVariant:vertexFunction:serializedVertexDescriptor:descriptor:destinationArchive:options:reflection:compileStatistics:fragmentCompileTimeData:pipelineArchiverId:error:completionHandler:] 
+ 1890 frame #5: 0x0000000103101cfb MetalOld.dylib`__128-[MTLCompiler 
newRenderPipelineStateWithDescriptorInternal:options:reflection:destinationBinaryArchive:error:completionHandler:]_block_invoke_2 
+ 378 frame #6: 0x0000000103100c9f MetalOld.dylib`-[MTLCompiler 
newRenderPipelineStateWithDescriptorInternal:options:reflection:destinationBinaryArchive:error:completionHandler:] 
+ 2988 frame #7: 0x00000001030181d8 MetalOld.dylib`-[MTLCompiler 
newRenderPipelineStateWithDescriptor:options:reflection:error:completionHandler:] 
+ 27 frame #8: 0x000000010309b25b MetalOld.dylib`-[_MTLDevice 
newRenderPipelineStateWithDescriptor:options:reflection:error:] + 76 frame 
#9: 0x00007ff80e9982a9 MetalTools`-[MTLDebugDevice 
_newRenderPipelineStateWithDescriptor:options:reflection:error:] + 717 
frame #10: 0x00007ff80e99846b MetalTools`-[MTLDebugDevice 
newRenderPipelineStateWithDescriptor:error:] + 40 frame #11: 
0x00007ff8168582c4 
QuartzCore`CA::OGL::MetalContext::create_pipeline_state(CA::OGL::MetalContext::Pipeline::Spec 
const&, unsigned int*, std::__1::atomic<bool>*) + 5538 frame #12: 
0x00007ff816a233af QuartzCore`CA::OGL::MetalContext::draw(MTLPrimitiveType, 
unsigned int, unsigned int, void const*, unsigned long, unsigned long, 
unsigned int, unsigned int, unsigned short const*, CA::OGL::ClipPlane 
const*, CA::OGL::MetalBufferPool::MetalBuffer const*) + 13569 frame #13: 
0x00007ff816854b34 
QuartzCore`CA::OGL::MetalContext::draw_elements(CA::OGL::PrimitiveMode, 
unsigned int, unsigned short const*, CA::OGL::Vertex const*, unsigned int, 
unsigned int, CA::OGL::ClipPlane const*) + 110 frame #14: 
0x00007ff816854a85 QuartzCore`CA::OGL::Context::array_flush() + 55 frame 
#15: 0x00007ff816a740bb QuartzCore`CA::OGL::emit_combine(CA::OGL::Context&, 
CA::OGL::TextureFunction, CA::OGL::Surface*, int, CA::OGL::Surface*, int, 
CA::Shape const*, CA::Vec4<float> const&) + 1268 frame #16: 
0x00007ff8168544ce 
QuartzCore`CA::CG::FillRects::draw_shape(CA::CG::Renderer&) const + 682 
frame #17: 0x00007ff816851f6f 
QuartzCore`CA::CG::DrawOp::render(CA::CG::Renderer&) const + 3835 frame 
#18: 0x00007ff81684e5a5 QuartzCore`CA::CG::Queue::render_callback(void*) + 
1391 frame #19: 0x00000001011b6a7b 
libdispatch.dylib`_dispatch_client_callout + 8 frame #20: 
0x00000001011be429 libdispatch.dylib`_dispatch_lane_serial_drain + 1397 
frame #21: 0x00000001011bf121 libdispatch.dylib`_dispatch_lane_invoke + 431 
frame #22: 0x00000001011cc21b 
libdispatch.dylib`_dispatch_root_queue_drain_deferred_wlh + 301 frame #23: 
0x00000001011cb770 libdispatch.dylib`_dispatch_workloop_worker_thread + 490 
frame #24: 0x0000000100421370 libsystem_pthread.dylib`_pthread_wqthread + 
327 frame #25: 0x0000000100427beb libsystem_pthread.dylib`start_wqthread + 
15

Also, I should mention that on the newer Mac, I'm able to build (from the 
command line) all the wxWidgets OpenGL samples and the wxWidgets minimal 
sample and run them without issue.

-- 
Please read https://www.wxwidgets.org/support/mlhowto.htm before posting.
--- 
You received this message because you are subscribed to the Google Groups "wx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/wx-users/9d221bd4-7949-4f15-8e12-1e12ddccc343n%40googlegroups.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.