Skip to content

Fix: IJobArchChunk.Schedule causes crash#5

Merged
nuskey8 merged 1 commit intomainfrom
fix-crash-schedule
Mar 2, 2024
Merged

Fix: IJobArchChunk.Schedule causes crash#5
nuskey8 merged 1 commit intomainfrom
fix-crash-schedule

Conversation

@nuskey8
Copy link
Member

@nuskey8 nuskey8 commented Mar 2, 2024

No description provided.

@nuskey8 nuskey8 merged commit 9690d2a into main Mar 2, 2024
@nuskey8 nuskey8 deleted the fix-crash-schedule branch March 2, 2024 07:24
@akeit0
Copy link

akeit0 commented Mar 2, 2024

This PR is only a temporary fix.
If ScheduleMode.Run is used, Assertion failed on expression: 'jobData->range.numJobs == 1' is logged.
Also even ScheduleMode.Single is selected, job runs in paralell.
So following is my solution.

public static unsafe void Execute(ref JobWrapper<T> jobData, IntPtr jobData2, IntPtr bufferRangePatchData,
    ref JobRanges ranges, int jobIndex)
{
    if (jobIndex==-1)
    {
      
        JobsUtility.PatchBufferMinMaxRanges(bufferRangePatchData, UnsafeUtility.AddressOf(ref jobData),
            0, jobData.ChunkArray.Length);
        for (int index = 0; index < jobData.ChunkArray.Length; ++index)
        {
            var chunk = jobData.ChunkArray[index];
            jobData.JobData.Execute(chunk);
        }
        return;
    }
    while (true)
    {
        if (!JobsUtility.GetWorkStealingRange(ref ranges, jobIndex, out int begin, out int end))
        {
            break;
        }

        JobsUtility.PatchBufferMinMaxRanges(bufferRangePatchData, UnsafeUtility.AddressOf(ref jobData),
            begin, end - begin);

        var endThatCompilerCanSeeWillNeverChange = end;
        for (var i = begin; i < endThatCompilerCanSeeWillNeverChange; i++)
        {
            var chunk = jobData.ChunkArray[i];
            jobData.JobData.Execute(chunk);
        }
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants