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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Weird "Metal" Crashes - 4.6.2p2

Discussion in 'iOS and tvOS' started by Drowning-Monkeys, Feb 13, 2015.

  1. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    Hi Guys,

    So I am getting crashes that I've never gotten before, in places that don't cause any kind of NRE's. For example, the game simply hangs on the main menu on an iPhone 6 or iPad Air. On my iPhone 5S and Mini 2, I can get into the game, and then the game crashes when i am running a cutscene, and the game changes cameras between the cutscene camera and the main camera.

    For the former, I don't get any kind of crash. The game just hangs on the main menu with nothing moving, no error of any kind.

    For the latter, this is the error i am getting in Xcode:
    /SourceCache/AppleEmbeddedGPUDrivers/AppleEmbeddedGPUDrivers-50.6.10/AGP/G3/agxa_g3_command_buffer.mm:40: failed assertion `A command encoder is already encoding to this command buffer'

    The "Thread 1 signal SIGBART" error is happening in
    Thred 1 > 6 SetupMetalFBO(unsigned int, ColorRGBAf const&, float, unsigned int)


    Also - important side note, none of this was happening before Metal rendering in 4.6.2p2
     
  2. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    Case #672232
     
  3. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    I'm not sure if Metal is fully stable yet, I have my doubts...maybe not everyone understand it yet.
    I select Automatic settings, does this include metal?
     
  4. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    unfortunately yes. In fact i cannot get it to compile in such a way that it is stable, like 4.6.2p1
     
  5. rextr09

    rextr09

    Joined:
    Dec 22, 2011
    Posts:
    416
    I'm having the same error: NullReference at SetupMetalFBO.
     
  6. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,602
    >>Case #672232
    sorry, i will not look into 7gbs repro (unless there are no other options at all)
    So, anyone was able to repro it with some actually small project? (or managed to cut down their bigger one to small)
     
  7. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    @Alexey
    Here's a 500mb repro. Hope it works, i simply exported (including Dependancies) the two scenes in question that need to be tested.

    Case #672842
     
  8. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    @rextr09 so good news on my end, hopefully this fixes it for you. Don't know why this is but Unity couldn't reproduce my bugs, so when i deleted everything from my phone (the old app), restarted, and reinstalled, everything ran fine.
     
  9. Drowning-Monkeys

    Drowning-Monkeys

    Joined:
    Mar 6, 2013
    Posts:
    328
    nope, spoke too soon. I still get this error.
     
  10. rextr09

    rextr09

    Joined:
    Dec 22, 2011
    Posts:
    416
    I found out that "NullReference at SetupMetalFBO" error happens only if Everyplay is imported to the project. Removing Everyplay from the project fixes the problem for me.
     
    Last edited: Mar 1, 2015
    MrEsquire likes this.
  11. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,602
    oh i totally lost this thread, some updates:
    thanks will look into it
    Can has repro please?
    you also submitted case 672232 which was totally different (as in - thats the issue in backporting metal to 4.x - i missed some codepaths that i believed were not there on 4.x) and will be fixed in next patch release (or smth)

    *edited for some clarification - formatting totally killed it
     
  12. rextr09

    rextr09

    Joined:
    Dec 22, 2011
    Posts:
    416
    @Alexey, I couldn't produce a small repro yet. I need a little help here. Can you tell me briefly what's happening in the SetupMetalFBO, so that I can focus on things related to that function?
     
  13. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,602
    well, nothing really: more or less just [MTLCommandBuffer renderCommandEncoderWithDescriptor]
    are you running with debug layer? if so - is it maybe some assert?
     
  14. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    @Alexey, It seems I have the same issue. But since I don't have an ARM64 device available at the moment, I cannot reproduce it. But looking at the crash log, it seems "WarmupAllShaders()" may be the cause in my app. Here is the crash log in case it maybe helpful to you.
     

    Attached Files:

  15. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,602
    hm, Awake sounds like really bad place to do stuff. Also for 5.0 we changed first frame handling, but on 4.x you still need to be careful about doing rendering magic on first frame. Can you try splitting your first scene into two? The first one just switching to second on, say, first or second Update?
    EDIT: also i am quite surprised - you mean you have no device that supports metal to test on? you should probably stick to gles-only then (check http://forum.unity3d.com/threads/tw...ction-in-unity-4-6-3-and-upcoming-5-0.299415/ for more info on how to do it)
     
  16. rextr09

    rextr09

    Joined:
    Dec 22, 2011
    Posts:
    416
    @Alexey, no I'm not running debug.

    @artaka, do you have antialiasing enabled in your game?
     
  17. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    @rextr09, no antialiasing is not enabled.
    @Alexey, can you clarify, what is the purpose of splitting the scene into two? What should the first scene do before switching to the second?
     
    Last edited: Mar 5, 2015
  18. Alexey

    Alexey

    Unity Technologies

    Joined:
    May 10, 2010
    Posts:
    1,602
    Well, it is hard to say without proper repro, but what happens (i think) is that you do call WarmupShaders in Awake in first scene - and at this time rendering is not yet set up properly hence the crash. So:
    1. please make small repro and bug report (drop here case number)
    2. Try to do two scenes, first one being just "load actual scene on, say, second update", this way your second scene is guaranteed to be loaded when everything is cool on native side. Yes i agree this is not cool - but some workaround is always cool (and anyway - NEVER do anything like this in Awake)
     
  19. artaka

    artaka

    Joined:
    Feb 19, 2013
    Posts:
    128
    @Alexey, what I ended up doing is moving WarmupShaders into a simple Coroutine that is triggered in Awake but waits for the next frame before running WarmupShaders. That fixed the crash.
    Thanks for your help.
     
  20. Wawro01

    Wawro01

    Joined:
    Apr 23, 2014
    Posts:
    44
    Guys, please one simple question. How can i detect if unity really uses Metal for rendering on iOS ? Is there some property somewhere ?
     
  21. GameZero

    GameZero

    Joined:
    Apr 29, 2015
    Posts:
    3
    We've just encountered this exact same problem; seems fixed in version 4.6.5p2
     
  22. maurogarcia

    maurogarcia

    Joined:
    Nov 6, 2012
    Posts:
    12
    Hi, I have same issue in Unity 4.6.4 . Can somebody confirm if it was fixed in 4.6.5??
    Thanks!!
     
  23. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    You know 4.6.9 is latest version, quiet lot of things have been improved and changed since 4.6.4 days.
     
  24. maurogarcia

    maurogarcia

    Joined:
    Nov 6, 2012
    Posts:
    12
    MrEsquire,
    I just installed the 4.6.9 version and now when I try to build my project I get the following error:
    thanks in advance!
     

    Attached Files:

    • cpt.png
      cpt.png
      File size:
      17.5 KB
      Views:
      874
  25. MrEsquire

    MrEsquire

    Joined:
    Nov 5, 2013
    Posts:
    2,712
    Not seen this before, trying googling it. Its almost like install did not go well.
    Did you make a fresh install maybe better and always backup project etc.