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

Unity 2018.3.6 Editor Crashes when calling Meshfilter.mesh

Discussion in 'Editor & General Support' started by mowax74, Feb 21, 2019.

  1. mowax74

    mowax74

    Joined:
    Mar 3, 2015
    Posts:
    94
    Hi!

    Since we switched from Unity 2018.2.20 to Unity 2018.3 we get strange editor chrashes every time this method is called:

    Code (CSharp):
    1. public virtual void UpdateBounds ()
    2. {
    3.     bounds = new Bounds ();
    4.     if (visual != null)
    5.     {
    6.         MeshFilter[] filters = visual.GetComponentsInChildren<MeshFilter> (true);
    7.         foreach (MeshFilter mf in filters)
    8.         {
    9.             Vector3 max = mf.mesh.bounds.max;
    10.             Vector3 min = mf.mesh.bounds.min;
    11.             if (bounds.size.Equals (Vector3.zero))
    12.             {
    13.                 bounds = new Bounds ((max + min)/2, max - min);
    14.              }
    15.              else
    16.              {
    17.                  bounds.Encapsulate (max);
    18.                  bounds.Encapsulate (min);
    19.              }
    20.          }
    21.      }
    22.  }
    It crashes at line 9. You can call the MeshFilter mf, but when you call mf.mesh, it crashes.
    But this is nothing special here, i have no idea why it crashes there. Even when i set a Debug.Log (mf.mesh); it crashes. Any Ideas what could be the reason? It does not happen in 2018.2, there it works just fine.

    This is what the crash.dmp opened in VS shows:


    Dump Summary
    ------------
    Dump File: crash.dmp : C:\Users\Daniel\AppData\Local\Temp\unity\Editor\Crashes\Crash_2019-02-20_175317524\crash.dmp
    Last Write Time: 20.02.2019 18:53:24
    Process Name: Unity.exe : C:\Program Files\Unity\Hub\Editor\2018.3.6f1\Editor\Unity.exe
    Process Architecture: x64
    Exception Code: 0xC0000005
    Exception Information: The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
    Heap Information: Not Present

    System Information
    ------------------
    OS Version: 10.0.17134
    CLR Version(s):
     
  2. mowax74

    mowax74

    Joined:
    Mar 3, 2015
    Posts:
    94
    Ok, when i use renderer.bounds instead of meshfilter.mesh.bounds it works. But why is the meshfilter.mesh.bounds call crashing Unity? And why in 2018.3 and not in Unity 2018.2 and 5 Years before?

    Has it to do with the Nvidia Physix Update? Or the new Prefab system? Something must have changed on Unity side that causes that crash.

    I really would like to use the meshfilter.mesh.bounds instead of the renderer.bounds. I need the bounds before scaling happened to the mesh.
     
  3. Strodio

    Strodio

    Joined:
    Oct 20, 2018
    Posts:
    4
    I also encountered the similar issue. When I play in editor, it work well. But it will crash when I play on windows standalone. Seems to be related with mesh? Some mesh works well, some mesh will crash.
     
  4. mowax74

    mowax74

    Joined:
    Mar 3, 2015
    Posts:
    94
    I didn't made a build since that, for me the editor crashes.

    But you are right: The crash is not happening on all meshes. Some are working, but most of them not. And when it's happening to a mesh, its happening always - when a mesh is working, then it never crashes. It's not randomly. I can reproduce it, but i still didn't found the reason.

    In my case these are simple furniture meshes, nothing special and all have not more than 1000 tris. I tried putting new shaders for testing on them - did not helped.
    Like i said - in Unity 2018.2 and before (and back to 4.0) all worked fine.

    The models are imported from maya with the following import settings:

    - Rig Animation Type: NONE
    - import animation off
    - import constraints off
    - import materials off
    - import blendshapes off
    - import visibility off
    - import cameras off
    - import lights off
    - preserve hierarchy on
    - read/write disabled
    - optimize mesh on
    - generate colliders off
    - keep quads off
    - weld vertices on
    - index format 16bit
    - normals import
    - normals mode unweighted
    - smoothness source prefer s.g.
    - tangents calculate Mikktspace

    Also, since 2018.3 there now is automatically an animation component with "avatar missing" added to (some of) the model prefabs. Why is that? These models don't need an animation component! But it seems that this has nothing to do with the crash - removing these didn't solve the crash.
     
  5. JBMS

    JBMS

    Joined:
    Sep 30, 2017
    Posts:
    6
    I am experiencing this same issue in 2019.1.4f1.

    I can use MeshFilter.mesh when and object ISN'T loaded via a bundle, but when an object IS loaded via a bundle, using MeshFilter.mesh is hit-and-miss. It works with some meshes (and when it works, it always works), and causes a crash with other meshes (and if it crashes, it always crashes).

    I made another post about this, and shared a project that can be used to reproduce the issue, here:
    https://forum.unity.com/threads/uni...sh-after-loading-object-from-a-bundle.687319/
     
  6. OVRSuppleTeet

    OVRSuppleTeet

    Joined:
    Sep 21, 2018
    Posts:
    3
    Had this same problem accessing
    mf.mesh
    in builds on Start. I found this thread, switched from
    MeshFilter.mesh
    to
    MeshFilter.sharedMesh
    and added a
    if (MeshFilter.sharedMesh != null)
    check first and the problem went away

    I'm in 2019.1.0f2 btw
     
    Last edited: Jun 19, 2019