Good evening, I am facing an issue with Unity 2018.3f2, where a simple draw mesh instance causes the editor to crash, constantly with the following stack trace:
Stack Trace of Crashed Thread 21800:
0x0000000140B969C0 (Unity) FindDataSource
0x0000000140B7C74E (Unity) WriteConstantLoop<MemCpy<CopyFloat,4> >
0x0000000140B7961F (Unity) InstancingProps::FillInstanceBufferDispatchConstants<Instancing::smile:rawAPIArgs>
0x0000000140B6F213 (Unity) InstanceBufferJob<Instancing::smile:rawAPIArgs>
0x00000001408A4D38 (Unity) JobQueue::Exec
0x00000001408A6C7D (Unity) JobQueue::Steal
0x00000001408A4FC2 (Unity) JobQueue::ExecuteJobFromQueue
0x00000001408A53C2 (Unity) JobQueue::ProcessJobs
0x00000001408A7403 (Unity) JobQueue::WorkLoop
0x0000000140A6F094 (Unity) Thread::RunThreadWrapper
0x00007FFE310B7E94 (KERNEL32) BaseThreadInitThunk
0x00007FFE33C3A251 (ntdll) RtlUserThreadStart
The component needed to crash is super simple:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
public class shouldCrash : MonoBehaviour
{
public GameObject mesh;
public Material mat;
private Mesh m;
private Matrix4x4[] matrices;
private CommandBuffer cmd;
// Start is called before the first frame update
private void ensureCommandBuffer() {
if (cmd == null) {
cmd = new CommandBuffer();
}
}
void Start()
{
var mf = mesh.GetComponent<MeshFilter>();
m= mf.sharedMesh;
matrices = new Matrix4x4[200];
for(int i =0; i <200;++i)
{
matrices[i] = Matrix4x4.identity;
}
ensureCommandBuffer();
var camera = Camera.main;
camera.AddCommandBuffer(CameraEvent.AfterGBuffer, cmd);
}
// Update is called once per frame
void Update()
{
ensureCommandBuffer();
cmd.Clear();
int deferredPassIndex = mat.FindPass("DEFERRED");
//int deferredPassIndex = m_material.FindPass("FORWARD");
cmd.EnableShaderKeyword("LIGHTPROBE_SH");
cmd.EnableShaderKeyword("UNITY_HDR_ON ");
for(int i=0; i <4;++i)
{
cmd.DrawMeshInstanced(m,0,mat,deferredPassIndex,matrices,178);
}
}
}
I am attaching the full project and crash log. Does anyone have any idea about this?
https://drive.google.com/file/d/1W96IRmbgaVmWM0mBANx_W1vlp7BHi6wt/view?usp=sharing
best regards
M.