MTLCreateSystemDefaultDevice crash?

Device: iPod 7 iOS version: 14.4.1 ,

GMetalDevice = MTLCreateSystemDefaultDevice();


(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
  frame #0: 0x00000001d7a3784c libsystem_kernel.dylib`__pthread_kill + 8
 * frame #1: 0x00000001f39c29e8 libsystem_pthread.dylib`pthread_kill + 212
  frame #2: 0x00000001b4b738f4 libsystem_c.dylib`abort + 100
  frame #3: 0x00000001bb238030 libsystem_malloc.dylib`malloc_vreport + 556
  frame #4: 0x00000001bb2381e8 libsystem_malloc.dylib`malloc_report + 60
  frame #5: 0x00000001bb22e2e8 libsystem_malloc.dylib`free + 432
  frame #6: 0x00000001f48dab10 AGXMetalA10`___lldb_unnamed_symbol1249 + 1644
  frame #7: 0x00000001f49064d4 AGXMetalA10`___lldb_unnamed_symbol1504 + 72
  frame #8: 0x00000001c18ca694 Metal`+[MTLIOAccelDevice registerDevices] + 224
  frame #9: 0x00000001c18ccbf8 Metal`invocation function for block in MTLDeviceArrayInitialize() + 872
  frame #10: 0x0000000119505528 libdispatch.dylib`_dispatch_client_callout + 16
  frame #11: 0x0000000119506e6c libdispatch.dylib`_dispatch_once_callout + 84
  frame #12: 0x00000001c18cc470 Metal`MTLCreateSystemDefaultDevice + 200
  frame #13: 0x00000001054f5f54 MyProject`+[FIOSView layerClass](self=<unavailable>, _cmd=<unavailable>) at IOSView.cpp:134:18 [opt]
  frame #14: 0x00000001aebbd034 UIKitCore`UIViewCommonInitWithFrame + 1040
  frame #15: 0x00000001aebbcbcc UIKitCore`-[UIView initWithFrame:] + 124
  frame #16: 0x00000001054f6274 MyProject`-[FIOSView initWithFrame:](self=<unavailable>, _cmd=<unavailable>, Frame=<unavailable>) at IOSView.cpp:233:14 [opt]
  frame #17: 0x0000000102d237f8 MyProject`invocation function for block in FAppEntry::PlatformInit() [inlined] MainThreadInit() at LaunchIOS.cpp:348:24 [opt]
  frame #18: 0x0000000102d237a8 MyProject`invocation function for block in FAppEntry::PlatformInit(.block_descriptor=<unavailable>) at LaunchIOS.cpp:373:47 [opt]
  frame #19: 0x0000000119503ce4 libdispatch.dylib`_dispatch_call_block_and_release + 24
  frame #20: 0x0000000119505528 libdispatch.dylib`_dispatch_client_callout + 16
  frame #21: 0x0000000119513994 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 972
  frame #22: 0x00000001abdf85e0 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 12
  frame #23: 0x00000001abdf2a88 CoreFoundation`__CFRunLoopRun + 2480
  frame #24: 0x00000001abdf1ba0 CoreFoundation`CFRunLoopRunSpecific + 572
  frame #25: 0x00000001c2b5a598 GraphicsServices`GSEventRunModal + 160
  frame #26: 0x00000001ae6e32f4 UIKitCore`-[UIApplication _run] + 1052
  frame #27: 0x00000001ae6e8874 UIKitCore`UIApplicationMain + 164
  frame #28: 0x0000000102d312bc MyProject`main(argc=3, argv=0x000000016d4e7700) at LaunchIOS.cpp:584:13 [opt]
  frame #29: 0x00000001abad0568 libdyld.dylib`start + 4

Replies

In macOS Ventura they removed the ability to call MTLCreateSystemDefaultDevice() from command-line apps. You have to use MTLCopyAllDevices().first! instead. However this problem shouldn't exist on iOS and older than v16.0.0.

  • This is what the error message says on macOS, but the documentation gives another solution: just import CoreGraphics, then MTLCreateSystemDefaultDevice() works again.

  • I was use on iOS 14.4.

  • #import <CoreGraphics/CoreGraphics.h> helps me fix assertion on iOS 12.5.4 , iPhone 6

Add a Comment

did you solve this problem, I met this crash too. waiting for solution