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

[ComputeJobOptimization] bug

Discussion in 'Entity Component System' started by RaL, May 10, 2018.

  1. RaL

    RaL

    Joined:
    Nov 29, 2013
    Posts:
    35
    It seems like almost every Job with the [ComputeJobOptimization] attribute crashes the editor on my machine.
    I cannot run any of the ECS sample projects without disabling "Use Burst Jobs".

    This is an example of a very simple JobComponentSystem that keeps crashing on me:
    Code (CSharp):
    1. public class TestSystem : JobComponentSystem
    2. {
    3.     [ComputeJobOptimization]
    4.     struct Job : IJobProcessComponentData<Test>
    5.     {
    6.         public void Execute(ref Test data)
    7.         {
    8.             float2 temp = data.TestVector;
    9.             data.TestVector = temp;
    10.         }
    11.     }
    12.  
    13.     protected override JobHandle OnUpdate(JobHandle inputDeps)
    14.     {
    15.         var job = new Job();
    16.         return job.Schedule(this, 64, inputDeps);
    17.     }
    18. }
    The only way I found to make this code run without crashing was to change it like this:
    Code (CSharp):
    1.  
    2. [ComputeJobOptimization]
    3.     struct Job : IJobProcessComponentData<Test>
    4.     {
    5.         const float Workaround = 0;
    6.  
    7.         public void Execute(ref Test data)
    8.         {
    9.             float2 temp = data.TestVector;
    10.             data.TestVector = new float2(temp.x, temp.y + Workaround);
    11.         }
    12.     }
    13.  
    manifest.json:
    Code (JavaScript):
    1. {
    2.     "dependencies": {
    3.         "com.unity.incrementalcompiler": "0.0.38",
    4.         "com.unity.entities": "0.0.12-preview.1"
    5.     },
    6.     "registry": "https://staging-packages.unity.com",
    7.     "testables": [
    8.         "com.unity.collections",
    9.         "com.unity.entities",
    10.         "com.unity.jobs"
    11.     ]
    12. }
    I'm using Unity 2018.2.0b1 on Windows. The editor crashes without generating a crash dump...
     
  2. recursive

    recursive

    Joined:
    Jul 12, 2012
    Posts:
    669
    Have you submitted a bug report along with a minimum repro case? That should help route the issue to the appropriate person faster.
     
  3. RaL

    RaL

    Joined:
    Nov 29, 2013
    Posts:
    35
    No, I haven't. If I recall correctly someone from Unity said in a thread a few days ago that it was fine to report ECS related bugs here on the forums. So hopefully someone is already looking into this. :)
     
  4. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    416
    I'm having a look at this issue. Not able to reproduce it, so It might have been fixed in the meantime, but going to double check.
     
  5. RaL

    RaL

    Joined:
    Nov 29, 2013
    Posts:
    35
    I tried it today in 18.2.0b4 and on my computer, the issue still persists.

    I don't know if this will help you narrow the issue down but I played with it for a bit today and one thing I noticed was that it didn't crash when I only used floats and ints etc. instead of float2 in the Execute() method.

    This works fine for instance:
    Code (CSharp):
    1. float temp = data.TestFloat;
    2. data.TestFloat = temp;
    This code doesn't crash either, even though it involves float2:
    Code (CSharp):
    1. float2 temp = data.TestVector;
    2. data.TestVector = 1f;
     
  6. RaL

    RaL

    Joined:
    Nov 29, 2013
    Posts:
    35
    I've just tried it with Unity 18.2.0b5 and entities 0.0.12-preview.4
    Some of the jobs don't crash on my PC anymore (for example the one in the first post in this thread works fine for me now)

    But some jobs keep crashing :(

    A minimal repro case is attached.
     

    Attached Files:

    optimise likes this.
  7. xoofx

    xoofx

    Unity Technologies

    Joined:
    Nov 5, 2016
    Posts:
    416
    Not able to reproduce a crash with the latest version. Could you add to your manifest to use a specific version of `"com.unity.burst": "0.2.4-preview.8"` ?
     
  8. RaL

    RaL

    Joined:
    Nov 29, 2013
    Posts:
    35
    It crashes with this version, too.

    Code (CSharp):
    1. data.TestVector += 0.1f; // crashes
    2.  
    3.  
    4. data.TestVector = new float2(data.TestVector.x + 0.1f, data.TestVector.y + 0.1f); // does not crash