Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

OSX Unity crash due to Metal API?

Discussion in 'Editor & General Support' started by lpye, Mar 4, 2019.

  1. lpye

    lpye

    Joined:
    Aug 2, 2012
    Posts:
    30
    Hello all,

    I'm developing on a MacBook Pro with 16GB RAM and two video cards (as is normal), one being the integrated Intel HD 4000 and the other being the discrete NVIDIA GeForce 650M.

    I have reproduced the following issue using Unity versions 2018.3.6f1, 2018.2, and 2019.1.4b.

    - Create a new empty project. I removed all packages via Package Manager aside from the Package Manager itself, but YMMV
    - Make sure that in your Player Settings, you have turned on the Metal Editor and other associated Metal options
    - Make sure that in your Unit Preferences, under General, you have specifically chosen the NVIDIA as the 'Device to use'
    - Import Ultimate Character Controller 2.1.1
    - Open the Demo scene

    The editor will become sluggish and eventually crash to desktop. This is accelerated if you actually Play the scene. At best, Unity hangs. In particular, when you open the scene, simply facing down the first hall toward the first door seems to induce the lag.

    The reason why I think this is a Metal API or Unity issue and not a problem with the UCC Demo is because of the following:

    - If you turn off the Metal flags in the Player Settings and reload the project, you won't get the crash or the hang, but your performance will plummet as you are now using OpenGL
    - If you instead switch the 'Device to Use' in the Unity Preferences to the Intel integrated card, but keep Metal, you won't experience the crash or the lag and performance seems reasonable.

    This was a surprise to me, and means I have a workaround, but it is unexpected behavior and undesirable because the natural inclination for some will be to simply select the more powerful card to use.

    Note: I have the automated graphics switching turned OFF on my system, to force the Mac to use the NVIDIA card regardless of situation.

    Is anyone else able to reproduce this?
     
  2. Lu4e

    Lu4e

    Joined:
    Mar 23, 2018
    Posts:
    276
    Could you check the crash information from ~/Library/Logs/DiagnosticReports? There is a section called "Application Specific Information:".
     
  3. lpye

    lpye

    Joined:
    Aug 2, 2012
    Posts:
    30

    Process: Unity [23242]
    Path: /Applications/Unity/*/Unity.app/Contents/MacOS/Unity
    Identifier: com.unity3d.UnityEditor5.x
    Version: Unity version 2018.3.6f1 (2018.3.6f1)
    Code Type: X86-64 (Native)
    Parent Process: Unity Hub [17392]
    Responsible: Unity [23242]

    Date/Time: 2019-03-03 08:26:03.411 -0600
    OS Version: Mac OS X 10.14.3 (18D109)
    Report Version: 12
    Anonymous UUID: 51C48848-F594-294D-7474-F180B20AC744

    Sleep/Wake UUID: 3BD4B4F9-D83F-4D52-A946-789F824D2F5B

    Time Awake Since Boot: 820000 seconds
    Time Since Wake: 15000 seconds

    System Integrity Protection: enabled

    Crashed Thread: 35 UnityGfxDeviceWorker

    Exception Type: EXC_BAD_INSTRUCTION (SIGABRT)
    Exception Codes: 0x0000000000000001, 0x0000000000000000
    Exception Note: EXC_CORPSE_NOTIFY

    Application Specific Information:
    abort() called
    BUG IN CLIENT OF LIBPLATFORM: Trying to recursively lock an os_unfair_lock

    Thread 0:: CrBrowserMain Dispatch queue: com.apple.main-thread
    0 libsystem_kernel.dylib 0x00007fff5ca201b6 semaphore_wait_trap + 10
    1 libdispatch.dylib 0x00007fff5c89936c _dispatch_sema4_wait + 16
    2 libdispatch.dylib 0x00007fff5c899b48 _dispatch_semaphore_wait_slow + 101
    3 com.unity3d.UnityEditor5.x 0x0000000102a391e8 PlatformSemaphore::WaitForSignal() + 24
    4 com.unity3d.UnityEditor5.x 0x0000000102a4db49 GfxDeviceClient::WaitForPendingPresent() + 89
    5 com.unity3d.UnityEditor5.x 0x0000000102a58600 GfxDeviceClient::BeginRendering(ClientDeviceWindow*) + 48
    6 com.unity3d.UnityEditor5.x 0x0000000102a6be63 ThreadedWindow::BeginRendering() + 35
    7 com.unity3d.UnityEditor5.x 0x0000000100713ef3 GUIView::BeginCurrentContext() + 179
    8 com.unity3d.UnityEditor5.x 0x00000001007292c8 -[GUIMetalView drawRect:] + 264
    9 com.unity3d.UnityEditor5.x 0x000000010071373b GUIView::RepaintAll(bool) + 971
    10 com.unity3d.UnityEditor5.x 0x00000001019c3834 PlayerLoopController::UpdateScene(bool) + 884
    11 com.unity3d.UnityEditor5.x 0x00000001019bd5e9 PlayerLoopController::UpdateSceneIfNeeded() + 89
    12 com.unity3d.UnityEditor5.x 0x00000001019bb551 Application::TickTimer() + 6209
    13 com.unity3d.UnityEditor5.x 0x00000001006fea1e -[EditorApplication TickTimer] + 142
    14 com.apple.Foundation 0x00007fff319ca646 __NSFireTimer + 80
    15 com.apple.CoreFoundation 0x00007fff2f61bc25 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    16 com.apple.CoreFoundation 0x00007fff2f61b7d8 __CFRunLoopDoTimer + 871
    17 com.apple.CoreFoundation 0x00007fff2f61b30d __CFRunLoopDoTimers + 333
    18 com.apple.CoreFoundation 0x00007fff2f5fc8b4 __CFRunLoopRun + 2187
    19 com.apple.CoreFoundation 0x00007fff2f5fbdd6 CFRunLoopRunSpecific + 467
    20 com.apple.HIToolbox 0x00007fff2e885ab5 RunCurrentEventLoopInMode + 293
    21 com.apple.HIToolbox 0x00007fff2e8857eb ReceiveNextEventCommon + 618
    22 com.apple.HIToolbox 0x00007fff2e885568 _BlockUntilNextEventMatchingListInModeWithFilter + 64
    23 com.apple.AppKit 0x00007fff2cb40363 _DPSNextEvent + 997
    24 com.apple.AppKit 0x00007fff2cb3f102 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1362
    25 com.apple.AppKit 0x00007fff2cb39165 -[NSApplication run] + 699
    26 com.apple.AppKit 0x00007fff2cb288a3 NSApplicationMain + 780
    27 com.unity3d.UnityEditor5.x 0x0000000100726d7c EditorMain(int, char const**) + 844
    28 com.unity3d.UnityEditor5.x 0x00000001007271f9 main + 9
    29 libdyld.dylib 0x00007fff5c8e6ed9 start + 1


    And the crashed thread...


    Thread 35 Crashed:: UnityGfxDeviceWorker
    0 libsystem_kernel.dylib 0x00007fff5ca2623e __pthread_kill + 10
    1 libsystem_pthread.dylib 0x00007fff5cadcc1c pthread_kill + 285
    2 libsystem_c.dylib 0x00007fff5c98f1c9 abort + 127
    3 libmonobdwgc-2.0.dylib 0x0000000148dfaafd mono_handle_native_crash + 585
    4 libmonobdwgc-2.0.dylib 0x0000000148d5bd30 mono_sigill_signal_handler + 46
    5 libsystem_platform.dylib 0x00007fff5cad1b3d _sigtramp + 29
    6 com.unity3d.UnityEditor5.x 0x0000000100000000 0x100000000 + 0
    7 com.apple.QuartzCore 0x00007fff3a63ee1f -[CAMetalDrawable dealloc] + 83
    8 com.apple.CoreFoundation 0x00007fff2f64ee94 -[__NSArrayM removeAllObjects] + 226
    9 com.apple.QuartzCore 0x00007fff3a63c4a3 layer_private_cleanup_callbacks(_CAMetalLayerPrivate*) + 286
    10 com.apple.QuartzCore 0x00007fff3a63d26f -[CAMetalLayer nextDrawable] + 277
    11 com.unity3d.UnityEditor5.x 0x000000010072d901 AcquireDrawableMTL + 49
    12 com.unity3d.UnityEditor5.x 0x000000010077e59e SetupMetalFBO(GfxDeviceMetalBase&, GfxClearFlags, ColorRGBAf const&, float, unsigned int) + 830
    13 com.unity3d.UnityEditor5.x 0x000000010077f41d metal::PrepareRenderTargetIfNeeded(GfxDeviceMetalBase&) + 45
    14 com.unity3d.UnityEditor5.x 0x0000000100789cdc GfxDeviceMetalBase::SetShadersThreadable(GpuProgram**, GpuProgramParameters const**, unsigned char const* const*) + 28
    15 com.unity3d.UnityEditor5.x 0x0000000102a60c02 GfxDeviceWorker::RunCommand(ThreadedStreamBuffer&) + 22978
    16 com.unity3d.UnityEditor5.x 0x000000010078f08c GfxDeviceWorkerAutoreleasePoolProxy + 60
    17 com.unity3d.UnityEditor5.x 0x0000000102a654c0 GfxDeviceWorker::RunExt(ThreadedStreamBuffer&) + 160
    18 com.unity3d.UnityEditor5.x 0x0000000102a5af51 GfxDeviceWorker::RunGfxDeviceWorker(void*) + 145
    19 com.unity3d.UnityEditor5.x 0x0000000100e69542 Thread::RunThreadWrapper(void*) + 1234
    20 libsystem_pthread.dylib 0x00007fff5cada305 _pthread_body + 126
    21 libsystem_pthread.dylib 0x00007fff5cadd26f _pthread_start + 70
    22 libsystem_pthread.dylib 0x00007fff5cad9415 thread_start + 13
     
  4. Maxokaan

    Maxokaan

    Joined:
    Feb 24, 2017
    Posts:
    5
    Hi, I have the same problem. It is fixed after disabling Metal.
    For me, it occurs as following (100% of the time).
    • I just updated from 2018.2.x to 2019.1.0f2
    • I created a new project with the Lightweight Rendering Pipeline
    • Everything works, until I open the sample scene (build site thing)
    • It starts to bake the lighting
    • It crashes and produces a similar crash report as the one above. (notably this line: BUG IN CLIENT OF LIBPLATFORM: Trying to recursively lock an os_unfair_lock)
    How can I fix this properly? The solution provided by lpye works, but is not preferable since Metal is faster and more powerful.

    Hope to hear from you, as I need Unity to start my school project. Thanks!
     
  5. RoughSpaghetti3211

    RoughSpaghetti3211

    Joined:
    Aug 11, 2015
    Posts:
    1,695
    I’m seeing the same thing , did anyone do a bug report so I can up vote it. Part of me feels I’ve submitted this one before but not sure :(
     
  6. MX-Peachy

    MX-Peachy

    Joined:
    Mar 12, 2014
    Posts:
    1
    I think this might be a problem with the Player settings or Graphic settings file but I'm not entirely sure since maybe only I had this problem solved like this

    I created a new project to test something from HDRP with 2019.1.2f1 but then 2019.2.0f1 came out and I said well let's just update the version in the project since I have nothing to loss but the update failed so I resigned and created a new one with the new version however the project crashed with the same error ( UnityGfxDeviceWorker ) so I created a new project with the standard rendering system thinking the unity version failed to download the files and the project was created successfully, after downloading again the new version I tried to open it again to see if it worked but it didn't so I decided to just work in the project I created with the build-in rendering and just download the packages from the Package Manager surprisingly the editor crashed again when I tried to change the reference file from the rendering pipeline so I deleted it (ProjectSettings.asset) and to let the editor rebuild it from the last change and the editor was able to load again so I disabled the Auto Graphics API checkbox and switched to OpenGL after reading here that by disabling Metal the editor will no longer crash and it worked but I got the message to switch to Metal because HDRP don't support OpenGL on mac then I moved back to Metal but I got a new error saying HDRP don't support Gamma color space so I had to change it and the editor crashed again so I redid everything however this time instead of moving the project settings file I accidentally moved the GraphicSettings.asset so I had file with no render pipeline selected so I was able to open the editor again without crash so I went and edited the settings manually but this time the scene was able to load --Sorry for the long explanation but I thought this might help with a more in-depth steps of what I didn't. I hope this helps someone since I had almost the same crash report with slightly variations--



    TLDR:

    Create a new project with built-in rendering then replace ProyectSettings.asset and GraphicSettings.asset files with the ones created in the new project then change the render pipeline in Graphics, color space to Linear in Player settings
     
  7. skwanny

    skwanny

    Joined:
    Feb 24, 2017
    Posts:
    1
    I had a similar issue, and I found a solution, so I'm going to leave a record for those of you who search later.

    In MacOS X - Unity2017.4.30f1, my project was upgraded to Unity2018.4.3f1 and rolled back to 2017. Then, during loading editor, there was a continuous crash. I deleted all the files and updated them all on Svn, but repeated crashes with below message.

    ----
    Crashed Thread: 26 UnityGfxDeviceWorker

    Exception Type: EXC_CRASH (SIGABRT)
    Exception Codes: 0x0000000000000000, 0x0000000000000000
    Exception Note: EXC_CORPSE_NOTIFY

    Application Specific Information:
    validateVertexAttribute:723: failed assertion `Attribute at index 1 references a buffer at index 2 that has no stride.'
    ----

    I started looking for solutions, but I didn't have the right solution.
    While searching, I thought MetalAPI might be a problem.

    In ProjectSettings.asset, change from "metalEditorSupport: 1" to 0, loading was successful. No Crash.
    Even if I change to 1 after closing editor, it seems that there is no crash, so it is something that is initialized.
     
  8. PNUMIA-Rob

    PNUMIA-Rob

    Joined:
    Jan 7, 2015
    Posts:
    33
    Just spent 3 days debugging this same problem, and while disabling Metal worked for a short time the error reappeared even with only OpenGLES enabled. After pouring through the ProjectSettings.asset file I noticed that GPU Skinning and Graphics Jobs (Experimental) had been enabled -- disabling them in the .asset file allowed the project to load with full Metal support and without issue. I really hope this helps someone to not tear their hair out.

    Happy New Year Unity Community! =D
     
  9. tataygames

    tataygames

    Joined:
    Aug 4, 2016
    Posts:
    55
    I am force to update to Unity 2019 even I don't like because of googleplaystore api level 29 requirement,
    Im from unity 2017.4 which is perfect
    switching to Unity 2019.4 which supports api level 29, crashes and shutdowns my mac mini 2018 mojave.
    I tried almost 4 times, and it shutting down my computer. this is the first I experience my mac being shutdown by an app, what is happening to unity? every version is getting worse!? why dont they test before release?

    And I hope they can support or update unity 2017 api level max is 28 and just change it to 29 so other who is use to that unity version does not need to update to the buggy higher version of unity.

    I dont know what will I do now, I need to update my android app asap, and unity version which only supports api 29 always shutsdown my mac. ( my mac is i5 and 6 core very fast )
     
    iepathos likes this.