Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Tiny don't support jobchunk?

Discussion in 'Project Tiny' started by kuailaiwanli, Jul 18, 2021.

  1. kuailaiwanli

    kuailaiwanli

    Joined:
    Apr 22, 2013
    Posts:
    47
    Is tiny support dots's jobchunk?
    I creat a IJobChunk for test , Schedule or ScheduleParallel will run error in html5
     
  2. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    I've been using iJobChunk without no problem. What error do get?
     
  3. kuailaiwanli

    kuailaiwanli

    Joined:
    Apr 22, 2013
    Posts:
    47
    I just create a jobchunk like this for test:
    struct TestJob : IJobChunk
    {

    public void Execute(ArchetypeChunk chunk, int chunkIndex, int firstEntityIndex)
    {
    Debug.Log("a");
    }
    }

    In OnCreate:
    m_Query = GetEntityQuery(ComponentType.ReadOnly<UIState>());

    In OnUpdate:
    TestJob testjob = new TestJob();
    testjob.ScheduleParallel(m_Query);


    I got Error in html like this:
    Code (CSharp):
    1. 016ba176:0x2e6e0a Uncaught RuntimeError: unreachable
    2.     at il2cpp::os::CrashHelpers::CrashImpl() (<anonymous>:wasm-function[15284]:0x2e6e0a)
    3.     at il2cpp::os::CrashHelpers::Crash() (<anonymous>:wasm-function[15275]:0x2e6aee)
    4.     at tiny::vm::Exception::Raise(char const*) (<anonymous>:wasm-function[15246]:0x2e4ebf)
    5.     at tiny::vm::Exception::Raise(Il2CppException*) (<anonymous>:wasm-function[15247]:0x2e4f01)
    6.     at ComponentSafetyHandles_CompleteAllJobsAndInvalidateArrays_m000A8D8866A6320E175537571D0794EDFB78D2A9 (<anonymous>:wasm-function[9791]:0x1686ff)
    7.     at ComponentDependencyManager_CompleteAllJobsAndInvalidateArrays_m789377FCA17814F3242C476D98E55936ABAC438D (<anonymous>:wasm-function[9790]:0x168522)
    8.     at EntityDataAccess_BeforeStructuralChange_mC73F35C65CE0BCC301792A780D9B35FD74F0B3E2 (<anonymous>:wasm-function[10093]:0x179f06)
    9.     at EntityDataAccess_AddComponent_mCA928B3F0C385FBD8B0CA7F6BD38230C9D587ED0 (<anonymous>:wasm-function[10100]:0x17ab99)
    10.     at EntityManager_AddComponent_m714A3F19E8D029D11F9EBEEFC1F188A5AF8374E1 (<anonymous>:wasm-function[10148]:0x17cfc6)
    11.     at EntityManager_AddComponentData_TisSimpleMeshRenderer_tA9014985B2685BC3B0C5AB5DB1095D2FA2626FD5_m73C56A0AF68EA3EBE8C7E779B1513A7246ECD8B7 (<anonymous>:wasm-function[2425]:0x58afc)
     
  4. kuailaiwanli

    kuailaiwanli

    Joined:
    Apr 22, 2013
    Posts:
    47
    It's solved,but it's strange.

    1st: ScheduleParallel must add "Complete()"?? if not,it'll got error.

    2nd: If I use "chunk.GetNativeArray(entitytype)" and assign entitytype with "GetEntityTypeHandle()" in OnUpdate,it'll got error too.

    I'm confused about it...
     
  5. GilCat

    GilCat

    Joined:
    Sep 21, 2013
    Posts:
    676
    You must return the job handle in case of a JobComponentSystem or assign that job handle to the "Dependency" property of your system in case of SystemBase.
    I always test it in the editor where we can trigger these systems to just run and if there is a problem they will yield a proper error message. In the debut build the errors sometimes are not quite there yet and might not give you the proper hints about it.

    JobComponentSystem:
    Code (CSharp):
    1.   protected override JobHandle OnUpdate(JobHandle inputDeps) {
    2.     inputDeps = new TestJob()
    3.       .ScheduleParallel(_query, inputDeps);
    4.     return inputDeps;
    5.   }
    SystemBase:
    Code (CSharp):
    1.     protected override void OnUpdate() {
    2.  
    3.       Dependency = new TestJob()
    4.         .ScheduleParallel(_query);
    5.   }
    Calling Complete() will force a sync point where the job will complete immediately. You should avoid that when possible because you will lose the opportunity for this job to possibly run in parallel with jobs from other systems.
    Your 2nd scenario should also run fine but only with code examples I can tell what is wrong.

    I strongly advice to create Unit Tests for your systems to allow testing on editor and keep everything in a sane state.
     
  6. kuailaiwanli

    kuailaiwanli

    Joined:
    Apr 22, 2013
    Posts:
    47
    Thanks,GilCat!
    Problems solved,2nd I haven't add ReadOnly Tag to EntityTypeHandle in job......
     
    GilCat likes this.