Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity 5.3.1f1 crashing in glDrawElements

Discussion in 'iOS and tvOS' started by cgJames, Dec 28, 2015.

  1. cgJames

    cgJames

    Joined:
    Dec 3, 2014
    Posts:
    30
    Has anyone else experienced crashing in Unity 5.3.1f1 on iOS with EXC_BAD_ACCESS in the following stack trace?
    • gleRunVertexSubmitARM
    • glDrawElements
    • :: DrawBuffers()
    • :: DrawMeshBuffersRaw()
    • :: DrawMeshRaw()
    • :: Render()
    • :: Flush()
    • :: PerformRendering()
    • :: DoForwardShaderRenderLoop()
    • :: DoRenderLoop()
    • :: DoRender()
    • :: Render()
    • Render [inlined]
    • :: StandaloneRender()
    • :: Camera_CUSTOM_Render()
    We see this sporadically on all our iOS test devices (iPhone 4s, 5, 6, iPad Air). It's always triggered by calling Render on a Camera targeting a RenderTexture. The code has been in production for several months now without any problems (Unity 4.6.7p2).

    We also see something very similar on the Android-based Nexus 9, failing with Fatal signal 11 (SIGSEGV). The failing code is in libglcore.so, so could be the same problem as with iOS.

    It does not occur in the Unity Editor.

    The crash happens often, but is not consistent enough to create a repro project yet.

    Based on solutions to past bugs related to glDrawElements, we've tried the following, but with no benefit:
    • Disabling dynamic batching
    • Targeting OGLES 3 (instead of 2)
    • Removing any complex shaders in the scene.
    If anyone has seen something similar then please get in touch.
     
  2. Filip_Iliescu

    Filip_Iliescu

    Unity Technologies

    Joined:
    Sep 28, 2015
    Posts:
    2
    This could be a number of things really. Probably not just iOS specific (unless its an iOS GL related driver bug) but rather something busted with some piece of geometry or buffer data that is passed to glDrawElements. It could also be how we are handling geometry data, but its hard to say without a reproducible test case. If possible, I would try to make the simplest thing possible that causes this crash. Start by figuring out what geometry is in the scene that could be involved and strip things out until thats all thats left. I know it sounds like a daunting task but if you can get it to crash consistently then removing meshes and stuff that gets rendered until it just crashes on a minimal subset could be a great way to find this issue. If you can do that please file a bug and attach that test case.
     
  3. jcarpay

    jcarpay

    Joined:
    Aug 15, 2008
    Posts:
    561
    kuncs likes this.
  4. futureflyit

    futureflyit

    Joined:
    Feb 10, 2015
    Posts:
    6
    We are getting the same crash in Unity 5.3.5p1 when running GLES 2.0 (iPhone 4S, 5 and 5C). Seems related to calling GC.Collect() + Resources.UnloadUnusedAssets() before the crash.
     
  5. cg_han-squirrel

    cg_han-squirrel

    Joined:
    Nov 27, 2013
    Posts:
    46
    also in 5.3.5p3, do you have any solution to avoid this problem?
     
    futureflyit likes this.
  6. abutt1

    abutt1

    Joined:
    Jan 24, 2014
    Posts:
    18
    @futureflyit :
    Did you end up finding a resolution for this? We're seeing the same issue (also using GLES 2.0). We're not explicitly using GC.Collect(), but we are using Resources.UnloadUnusedAssets(). If we take those calls out of our app, we don't get a crash.

    *We're using Unity 5.3.5f1
     
    futureflyit likes this.
  7. abutt1

    abutt1

    Joined:
    Jan 24, 2014
    Posts:
    18
    I've been fruitlessly attempting to create a repro project for this crash. No idea what the conditions of repro are!

    I can confirm that I see it stops crashing on an iPhone5 if we remove all Resources.UnloadUnusedAssets() calls from the app. If I add them back in, it crashes. Really bizarre.

    We're running an IL2CPP universal iOS build, running full .net 2.0.
     
    futureflyit likes this.
  8. povilas

    povilas

    Unity Technologies

    Joined:
    Jan 28, 2014
    Posts:
    427
    It could be that Unity is a bit too eager to remove resources that are still used by rendering pipeline. Could you submit entire project by chance? To reduce the project size it helps to export the crashing scene by "Export package" and then import the created package to a new project.
     
  9. futureflyit

    futureflyit

    Joined:
    Feb 10, 2015
    Posts:
    6
    Hello.

    I have since heard back from a developer that has moved to another company, and solved the problem there. The source at least one variant of the problem was calling Resources.UnloadUnusedAssets from Start() directly, and also not yielding it since it returns an AsyncOperation. This particular variant was solved by placing and yielding the call in an independent Coroutine instead.

    It appears that this operation cannot be started from just any part of the unity operating loop.
     
  10. abutt1

    abutt1

    Joined:
    Jan 24, 2014
    Posts:
    18
    @povilas - sorry I only just saw this reply.

    I was unable to create a repro project, but I was able to resolve the crashes (or at least so I think) by running the following line after creating a camera:

    GL.InvalidateState();
     
    AlekseyLaz likes this.
  11. AlekseyLaz

    AlekseyLaz

    Joined:
    Aug 16, 2016
    Posts:
    7
    It helped me. Thanks a lot.