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. Dismiss Notice

Resolved Status of Burstable scheduling? e.g. scheduling jobs inside [BurstCompile] ISystem.OnUpdate

Discussion in 'Entity Component System' started by bilalakil, Aug 10, 2022.

  1. bilalakil

    bilalakil

    Joined:
    Jan 28, 2018
    Posts:
    68
    I found that I couldn't schedule jobs from a
    [BurstCompile] ISystem.OnUpdate
    , even if the system and jobs involved did nothing, and regardless of whether it was an
    IJob
    or
    IJobParallelFor
    or had come from a
    LambdaSingleJobDescription
    - they all failed to burst compile with various different arcane reasons.

    When fishing around the
    com.unity.entities
    source, I found the following:

    Code (CSharp):
    1.  
    2.         //disabling burst in dotsrt until burstable scheduling works
    3. #if !UNITY_DOTSRUNTIME
    4.         [BurstCompile]
    5. #endif
    6.         public void OnUpdate(ref SystemState state)
    7.         {
    8.             var localToWorldType = state.GetComponentTypeHandle<LocalToWorld>(true);
    9.             var childType = state.GetBufferTypeHandle<Child>(true);
    10. // ...
    It seems that every
    ISystem.OnUpdate
    with a scheduled job is guarded with that preprocessor condition. The one above (in
    LocalToParentSystem.cs
    ) is the only one I saw with a comment suggesting some reasoning.

    So apparently this is a known thing. Is there an open bug or thread for it, or any more info to share on this?

    A side question is regarding the usage of
    UNITY_DOTSRUNTIME
    , although someone else opened a thread specifically asking about that.

    EDIT: Oddly, adding the same
    #if !UNITY_DOTSRUNTIME
    to my own system didn't resolve the issue lol, I guess that define isn't set on user-code? Confusion compounds.
     
  2. DreamingImLatios

    DreamingImLatios

    Joined:
    Jun 3, 2017
    Posts:
    3,983
    It doesn't work with job types defined in the Unity Engine without the Jobs/Collections package. The job types in the Job/Collections package and Entities package usually work. There's an IJobBurstScheduable if you need Bursted scheduling.
     
    bilalakil and xVergilx like this.
  3. bilalakil

    bilalakil

    Joined:
    Jan 28, 2018
    Posts:
    68
    Oh wonderful, didn't know about the
    BurstSchedulable
    alternatives, found the
    IJobParallelForBurstSchedulable
    alternative when digging around there. Thanks!
     
  4. elliotc-unity

    elliotc-unity

    Unity Technologies

    Joined:
    Nov 5, 2015
    Posts:
    228
    FWIW, these will go away in 1.0, since we made all the normal jobs burst schedulable.
     
    Dre0Dru, apkdev, bilalakil and 2 others like this.