Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  When I refer Mesh at OnPreRender() of Camera, Unity Editer Crash.
#1
Hello all.

I found the crash of Unity Editer.
My enviroment are follows.
Obi Cloth version is 3.3.1.
Unity version 2017.2.0f3.
PC OS is Windows10 64bit.

When I refer Mesh at OnPreRender() of Camera, this issue will happen.
Moreover error.log says "Unity.exe caused an Access Violation (0xc0000005)" & "Read from location 00000000 caused an access violation.".
My PC Memory has enough space.


The Simple way for Reproduction is follows.

Step1
Use Obi Cloth Sample Scene named "CharacterCloth.unity" in "Sample Scene" directory.

Step2
Attach the following Script into "Main Camera".

-MeshTest.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MeshTest : MonoBehaviour
{
    void OnPreRender()
    {
        MeshRenderer[] meshrenderers = Component.FindObjectsOfType<MeshRenderer>();
        SkinnedMeshRenderer[] skinnedMeshRenderers = Component.FindObjectsOfType<SkinnedMeshRenderer>();

        foreach (MeshRenderer r in meshrenderers)
        {
            Mesh m = r.GetComponent<MeshFilter>().sharedMesh;
        }
        foreach (SkinnedMeshRenderer r in skinnedMeshRenderers)
        {
            Mesh m = new Mesh();
            r.BakeMesh(m);
        }
    }
}

Step3
Click the Play Button.

Step4
Probably you can see the Crash of Unity Editer.

Does anyone know how can I fix this issue?


Attached Files
.cs   MeshTest.cs (Size: 643 bytes / Downloads: 1)
Reply
#2
(14-05-2018, 04:44 AM)tomonori Wrote: Hello all.

I found the crash of Unity Editer.
My enviroment are follows.
Obi Cloth version is 3.3.1.
Unity version 2017.2.0f3.
PC OS is Windows10 64bit.

When I refer Mesh at OnPreRender() of Camera, this issue will happen.
Moreover error.log says "Unity.exe caused an Access Violation (0xc0000005)" & "Read from location 00000000 caused an access violation.".
My PC Memory has enough space.


The Simple way for Reproduction is follows.

Step1
Use Obi Cloth Sample Scene named "CharacterCloth.unity" in "Sample Scene" directory.

Step2
Attach the following Script into "Main Camera".

-MeshTest.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MeshTest : MonoBehaviour
{
    void OnPreRender()
    {
        MeshRenderer[] meshrenderers = Component.FindObjectsOfType<MeshRenderer>();
        SkinnedMeshRenderer[] skinnedMeshRenderers = Component.FindObjectsOfType<SkinnedMeshRenderer>();

        foreach (MeshRenderer r in meshrenderers)
        {
            Mesh m = r.GetComponent<MeshFilter>().sharedMesh;
        }
        foreach (SkinnedMeshRenderer r in skinnedMeshRenderers)
        {
            Mesh m = new Mesh();
            r.BakeMesh(m);
        }
    }
}

Step3
Click the Play Button.

Step4
Probably you can see the Crash of Unity Editer.

Does anyone know how can I fix this issue?

Hi,

This is a bug in Unity. The crash happens inside BakeMesh, due to a null reference exception when computing the bind pose bounding box. We can do nothing to fix it, here's the stack strace:

#0  0x00000100aec3a0 in ComputeBoneBindPoseAABB(Matrix4x4f const*, unsigned long, StrideIterator<Vector3f>, BoneWeights4 const*, unsigned long, dynamic_array<BlendShapeVertex, 4ul> const&, MinMaxAABB*)
#1  0x00000100aec124 in Mesh::GetCachedBonesBounds()
#2  0x00000100b3a615 in SkinnedMeshRenderer::CalculateBoneBasedBounds(Matrix4x4f const*, unsigned long, MinMaxAABB&)
#3  0x00000100b40d2a in SkinnedMeshRenderer::BakeMesh(Mesh&)

You should file a bug report.

Anyway, why using BakeMesh when you can access the deformed mesh directly from Obi? (Obi overrides Unity's skinning system, as BakeMesh is extremely slow). Do this instead:
Code:
Mesh m = cloth.clothMesh; //cloth is a ObiCloth component
Reply
#3
(14-05-2018, 09:46 AM)josemendez Wrote: Hi,

This is a bug in Unity. The crash happens inside BakeMesh, due to a null reference exception when computing the bind pose bounding box. We can do nothing to fix it, here's the stack strace:

#0  0x00000100aec3a0 in ComputeBoneBindPoseAABB(Matrix4x4f const*, unsigned long, StrideIterator<Vector3f>, BoneWeights4 const*, unsigned long, dynamic_array<BlendShapeVertex, 4ul> const&, MinMaxAABB*)
#1  0x00000100aec124 in Mesh::GetCachedBonesBounds()
#2  0x00000100b3a615 in SkinnedMeshRenderer::CalculateBoneBasedBounds(Matrix4x4f const*, unsigned long, MinMaxAABB&)
#3  0x00000100b40d2a in SkinnedMeshRenderer::BakeMesh(Mesh&)

You should file a bug report.

Anyway, why using BakeMesh when you can access the deformed mesh directly from Obi? (Obi overrides Unity's skinning system, as BakeMesh is extremely slow). Do this instead:
Code:
Mesh m = cloth.clothMesh; //cloth is a ObiCloth component

Hi,
Thank you josemendez!! Arigato Gozaimasu.

I will report this issue to Unity.

Actually...
I want to use another "Drawing Out-Line Plugin".
And I had queried to the development team of that Plugin about this crash issue.
They says that their Plugin includes BakeMesh() method calling in OnPreRender() method.
However, BakeMesh() calling is Hidden in dll file.
So I cannot use your code that access to "cloth.clothMesh" directly.
I (=That Plugin) must use BakeMash() for getting Mesh Information...

Do you have anything like "Non-Unity Skinning System Override Mode"?
Or Can I edit script for switching to "Non-Unity Skinning System Override Mode"?
Reply