Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Bug / Crash  [Burst] Lots of errors after adding to solver in some cases
#1
Bug 
I cannot provide my project because it is under NDA. I was using Obi Cloth and generating all stuff in runtime and I am using several solvers in the scene to simulate differently stuff. It is working totally fine with Oni backend. But with Burst I have these errors sometimes. It is rare errors and it happens 100% times in some specific cases in some special conditions I cannot reveal yet. Because I do scene snapshotting in my app and so I can get the case when it is reproducing 100% but I cannot tell what leads to this in the low level. Could be some mesh for simulation is null or corrupted or something like that. But Obi should handle these cases instead of crashing with unhandled errors. This issue also leads to a hang on iOS device.
Could you look into it?

It seems when the actor is added to Solver simulation not started and I got this exception in the console
First I got this error:
Quote:InvalidOperationException: The NativeContainer ApplyVolumeConstraintsBatchJob.particleIndices has not been assigned or constructed. All containers must be valid when scheduling a job.
Unity.Jobs.LowLevel.Unsafe.JobsUtility.ScheduleParallelFor (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters, System.Int32 arrayLength, System.Int32 innerloopBatchCount) (at <8691ad7005ed4755a1828378ff0b52b1>:0)
Unity.Jobs.IJobParallelForExtensions.Schedule[T] (T jobData, System.Int32 arrayLength, System.Int32 innerloopBatchCount, Unity.Jobs.JobHandle dependsOn) (at <8691ad7005ed4755a1828378ff0b52b1>:0)
Obi.BurstVolumeConstraintsBatch.Apply (Unity.Jobs.JobHandle inputDeps, System.Single deltaTime) (at Assets/Plugins/Obi/Scripts/Common/Backends/Burst/Constraints/Volume/BurstVolumeConstraintsBatch.cs:79)
Obi.BurstConstraintsImpl`1[T].EvaluateParallel (Unity.Jobs.JobHandle inputDeps, System.Single deltaTime) (at Assets/Plugins/Obi/Scripts/Common/Backends/Burst/Constraints/BurstConstraintsImpl.cs:136)
Obi.BurstConstraintsImpl`1[T].Project (Unity.Jobs.JobHandle inputDeps, System.Single deltaTime) (at Assets/Plugins/Obi/Scripts/Common/Backends/Burst/Constraints/BurstConstraintsImpl.cs:97)
Obi.BurstSolverImpl.ApplyConstraints (Unity.Jobs.JobHandle inputDeps, System.Single deltaTime) (at Assets/Plugins/Obi/Scripts/Common/Backends/Burst/Solver/BurstSolverImpl.cs:765)
Obi.BurstSolverImpl.Substep (System.Single substepTime) (at Assets/Plugins/Obi/Scripts/Common/Backends/Burst/Solver/BurstSolverImpl.cs:658)
Obi.ObiSolver.Substep (System.Single substepTime) (at Assets/Plugins/Obi/Scripts/Common/Solver/ObiSolver.cs:1425)
Obi.ObiUpdater.Substep (System.Single substepDeltaTime) (at Assets/Plugins/Obi/Scripts/Common/Updaters/ObiUpdater.cs:77)
Obi.ObiFixedUpdater.FixedUpdate () (at Assets/Plugins/Obi/Scripts/Common/Updaters/ObiFixedUpdater.cs:62)

InvalidOperationException: The previously scheduled job BurstParticleCollisionConstraintsBatch:UpdateParticleContactsJob reads from the NativeArray UpdateParticleContactsJob.velocities. You are trying to schedule a new job ApplyInertialForcesJob, which writes to the same NativeArray (via ApplyInertialForcesJob.velocities). To guarantee safety, you must include BurstParticleCollisionConstraintsBatch:UpdateParticleContactsJob as a dependency of the newly scheduled job.
Unity.Jobs.LowLevel.Unsafe.JobsUtility.ScheduleParallelFor (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters, System.Int32 arrayLength, System.Int32 innerloopBatchCount) (at <8691ad7005ed4755a1828378ff0b52b1>:0)
Unity.Jobs.IJobParallelForExtensions.Schedule[T] (T jobData, System.Int32 arrayLength, System.Int32 innerloopBatchCount, Unity.Jobs.JobHandle dependsOn) (at <8691ad7005ed4755a1828378ff0b52b1>:0)
Obi.BurstSolverImpl.ApplyFrame (System.Single worldLinearInertiaScale, System.Single worldAngularInertiaScale, System.Single deltaTime) (at Assets/Plugins/Obi/Scripts/Common/Backends/Burst/Solver/BurstSolverImpl.cs:251)
Obi.ObiSolver.UpdateTransformFrame (System.Single dt) (at Assets/Plugins/Obi/Scripts/Common/Solver/ObiSolver.cs:1359)
Obi.ObiSolver.BeginStep (System.Single stepTime) (at Assets/Plugins/Obi/Scripts/Common/Solver/ObiSolver.cs:1386)
Obi.ObiUpdater.BeginStep (System.Single stepDeltaTime) (at Assets/Plugins/Obi/Scripts/Common/Updaters/ObiUpdater.cs:47)
Obi.ObiFixedUpdater.FixedUpdate () (at Assets/Plugins/Obi/Scripts/Common/Updaters/ObiFixedUpdater.cs:54)


Then console is spamming these errors:
Quote:InvalidOperationException: The previously scheduled job ApplyCollisionConstraintsBatchJob writes to the NativeArray ApplyCollisionConstraintsBatchJob.positions. You are trying to schedule a new job InterpolationJob, which reads from the same NativeArray (via InterpolationJob.positions). To guarantee safety, you must include ApplyCollisionConstraintsBatchJob as a dependency of the newly scheduled job.
Unity.Jobs.LowLevel.Unsafe.JobsUtility.ScheduleParallelFor (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters, System.Int32 arrayLength, System.Int32 innerloopBatchCount) (at <8691ad7005ed4755a1828378ff0b52b1>:0)
Unity.Jobs.IJobParallelForExtensions.Schedule[T] (T jobData, System.Int32 arrayLength, System.Int32 innerloopBatchCount, Unity.Jobs.JobHandle dependsOn) (at <8691ad7005ed4755a1828378ff0b52b1>:0)
Obi.BurstSolverImpl.ApplyInterpolation (Obi.ObiNativeVector4List startPositions, Obi.ObiNativeQuaternionList startOrientations, System.Single stepTime, System.Single unsimulatedTime) (at Assets/Plugins/Obi/Scripts/Common/Backends/Burst/Solver/BurstSolverImpl.cs:800)
Obi.ObiSolver.Interpolate (System.Single stepTime, System.Single unsimulatedTime) (at Assets/Plugins/Obi/Scripts/Common/Solver/ObiSolver.cs:1492)
Obi.ObiUpdater.Interpolate (System.Single stepDeltaTime, System.Single accumulatedTime) (at Assets/Plugins/Obi/Scripts/Common/Updaters/ObiUpdater.cs:115)
Obi.ObiFixedUpdater.Update () (at Assets/Plugins/Obi/Scripts/Common/Updaters/ObiFixedUpdater.cs:79)

InvalidOperationException: The previously scheduled job PredictPositionsJob reads from the NativeArray PredictPositionsJob.activeParticles. You must call JobHandle.Complete() on the job PredictPositionsJob, before you can write to the NativeArray safely.
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckWriteAndBumpSecondaryVersion (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <8691ad7005ed4755a1828378ff0b52b1>:0)
Unity.Collections.NativeList`1[T].Resize (System.Int32 length, Unity.Collections.NativeArrayOptions options) (at Library/PackageCache/com.unity.collections@0.8.0-preview.5/Unity.Collections/NativeList.cs:593)
Unity.Collections.NativeList`1[T].ResizeUninitialized (System.Int32 length) (at Library/PackageCache/com.unity.collections@0.8.0-preview.5/Unity.Collections/NativeList.cs:605)
Obi.BurstSolverImpl.SetActiveParticles (System.Int32[] indices, System.Int32 num) (at Assets/Plugins/Obi/Scripts/Common/Backends/Burst/Solver/BurstSolverImpl.cs:270)
Obi.ObiSolver.PushActiveParticles () (at Assets/Plugins/Obi/Scripts/Common/Solver/ObiSolver.cs:1253)
Obi.ObiSolver.BeginStep (System.Single stepTime) (at Assets/Plugins/Obi/Scripts/Common/Solver/ObiSolver.cs:1379)
Obi.ObiUpdater.BeginStep (System.Single stepDeltaTime) (at Assets/Plugins/Obi/Scripts/Common/Updaters/ObiUpdater.cs:47)
Obi.ObiFixedUpdater.FixedUpdate () (at Assets/Plugins/Obi/Scripts/Common/Updaters/ObiFixedUpdater.cs:54)

Unity 2019.4.11f1
Obi Cloth v.5.6
Packages manifest:
Code:
{
  "dependencies": {
    "com.unity.2d.sprite": "1.0.0",
    "com.unity.2d.tilemap": "1.0.0",
    "com.unity.addressables": "1.8.5",
    "com.unity.ads": "3.4.9",
    "com.unity.analytics": "3.3.5",
    "com.unity.burst": "1.3.7",
    "com.unity.collab-proxy": "1.2.16",
    "com.unity.collections": "0.9.0-preview.6",
    "com.unity.ide.rider": "1.1.4",
    "com.unity.ide.vscode": "1.2.1",
    "com.unity.inputsystem": "1.0.0",
    "com.unity.mathematics": "1.2.1",
    "com.unity.multiplayer-hlapi": "1.0.6",
    "com.unity.postprocessing": "2.2.2",
    "com.unity.purchasing": "2.1.0",
    "com.unity.quicksearch": "1.4.1",
    "com.unity.test-framework": "1.1.16",
    "com.unity.textmeshpro": "2.0.1",
    "com.unity.timeline": "1.2.6",
    "com.unity.ugui": "1.0.0",
    "com.unity.xr.legacyinputhelpers": "2.1.4",
    "com.unity.modules.ai": "1.0.0",
    "com.unity.modules.androidjni": "1.0.0",
    "com.unity.modules.animation": "1.0.0",
    "com.unity.modules.assetbundle": "1.0.0",
    "com.unity.modules.audio": "1.0.0",
    "com.unity.modules.cloth": "1.0.0",
    "com.unity.modules.director": "1.0.0",
    "com.unity.modules.imageconversion": "1.0.0",
    "com.unity.modules.imgui": "1.0.0",
    "com.unity.modules.jsonserialize": "1.0.0",
    "com.unity.modules.particlesystem": "1.0.0",
    "com.unity.modules.physics": "1.0.0",
    "com.unity.modules.physics2d": "1.0.0",
    "com.unity.modules.screencapture": "1.0.0",
    "com.unity.modules.terrain": "1.0.0",
    "com.unity.modules.terrainphysics": "1.0.0",
    "com.unity.modules.tilemap": "1.0.0",
    "com.unity.modules.ui": "1.0.0",
    "com.unity.modules.uielements": "1.0.0",
    "com.unity.modules.umbra": "1.0.0",
    "com.unity.modules.unityanalytics": "1.0.0",
    "com.unity.modules.unitywebrequest": "1.0.0",
    "com.unity.modules.unitywebrequestassetbundle": "1.0.0",
    "com.unity.modules.unitywebrequestaudio": "1.0.0",
    "com.unity.modules.unitywebrequesttexture": "1.0.0",
    "com.unity.modules.unitywebrequestwww": "1.0.0",
    "com.unity.modules.vehicles": "1.0.0",
    "com.unity.modules.video": "1.0.0",
    "com.unity.modules.vr": "1.0.0",
    "com.unity.modules.wind": "1.0.0",
    "com.unity.modules.xr": "1.0.0"
  }
}
Reply
#2
Hi there,

Agreed that Obi (like any software) should not produce errors or unhandled exceptions under any circumstances, but I'm unable to reproduce these. Would it be possible for you to provide a minimal repro project/scene/script that causes this (even if it's only sometimes)? That way I can find and fix this asap.

Note that Burst and Oni are two completely different physics engines, so this issue might affect Burst and not Oni, that's completely possible.
Reply
#3
I've fixed it by adding 
Quote:particleIndices = particleIndices,

for ApplyVolumeConstraintsBatchJob

Error is:
All containers must be valid when scheduling a job.


so all containers must be assigned. ParticleIndices was invalid because it was unassigned. It is not used in the code but it was defined in ApplyVolumeConstraintsBatchJob class
Probably Unity is using some new version of Jobs that has a requirement for this that throws this exception
Reply
#4
(02-10-2020, 11:05 AM)mmortall Wrote: I've fixed it by adding 

for ApplyVolumeConstraintsBatchJob

Error is:
All containers must be valid when scheduling a job.


so all containers must be assigned. ParticleIndices was invalid because it was unassigned. It is not used in the code but it was defined in ApplyVolumeConstraintsBatchJob class
Probably Unity is using some new version of Jobs that has a requirement for this that throws this exception

The particleIndices array is not used at all in that particular job (leftover declaration that should not be there, my fault), so I see no reason for the Job system to complain about it. Will remove the declaration it in the next update. Thanks for reporting this!
Reply