Obi Official Forum
Doesn't work in Unity 2020.1.41f - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: Obi Softbody (https://obi.virtualmethodstudio.com/forum/forum-12.html)
+--- Thread: Doesn't work in Unity 2020.1.41f (/thread-2483.html)

Pages: 1 2


Doesn't work in Unity 2020.1.41f - quakeulf - 10-09-2020

Observe findings in Twitter-post here:

https://twitter.com/Colonthreee/status/1304175460532858882

Doesn't matter what I do, I always get:
[attachment=769]
Code:
InvalidOperationException: The previously scheduled job ApplyCollisionConstraintsBatchJob writes to the UNKNOWN_OBJECT_TYPE ApplyCollisionConstraintsBatchJob.positions. You are trying to schedule a new job InterpolationJob, which reads from the same UNKNOWN_OBJECT_TYPE (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 <e8645a79b0794e0e9a2b5bbff081b88a>:0)
Unity.Jobs.IJobParallelForExtensions.Schedule[T] (T jobData, System.Int32 arrayLength, System.Int32 innerloopBatchCount, Unity.Jobs.JobHandle dependsOn) (at <e8645a79b0794e0e9a2b5bbff081b88a>:0)
Obi.BurstSolverImpl.ApplyInterpolation (Obi.ObiNativeVector4List startPositions, Obi.ObiNativeQuaternionList startOrientations, System.Single stepTime, System.Single unsimulatedTime) (at Assets/Obi/Scripts/Common/Backends/Burst/Solver/BurstSolverImpl.cs:935)
Platform is PC standalone.


RE: Doesn't work in Unity 2020.1.41f - josemendez - 11-09-2020

Hi there,

I’m unable to reproduce this, going to investigate further. For the time being, you can switch your solver to the Oni backend. It will work without using Burst, instead using a native c++ lib with about the same performance (even a bit better in some scenes). See:
http://obi.virtualmethodstudio.com/tutorials/backends.html

Edit: I find surprising that ApplyCollisionConstraintsBatchJob.positions is regarded as UNKNOWN_OBJECT_TYPE in the error message you posted: it's a plain NativeArray? What Burst/Jobs versions are you using?

Regarding performance/vectorization, the current bottleneck for Burst is not CPU cycles spent on arithmetic instructions, but job scheduling by far: scheduling a job is quite often as slow or slower than executing it. This is specially problematic for small constraint batches. For this reason, we're currently concentrating our efforts on merging jobs together, which is what we've done in 5.6 (available next week) for a noticeable performance improvement.

After that there's some more low-hanging fruit for vectorization, such as removing branches from constraint application methods. Then there's the possibility of processing multiple constraints at once during batch execution/processing. This is what we do in the C++ lib: instead of letting vectorization on the hands of the compiler we use SIMD intrinsics and manually unroll/vectorize where possible. Over time our intention is to port these optimizations to Burst, and have the Burst backend outperform the native backend.


RE: Doesn't work in Unity 2020.1.41f - quakeulf - 11-09-2020

I am using the latest versions of Jobs, Collections, Mathematics, Burst, and so on. I am already working with Burst and Jobs for my project for other tasks like pathfinding and movement, and in the process of finding out to what degree I can upgrade my project to a hybrid-ECS solution.

[attachment=770]

[edit] IJobFor has worked wonders for me to do lots of small jobs in parallel, like swapping textures on meshes based on indices and processing quadtree queries. I also use it for A-star pathfinding for up to 1024 pathfinding requests across 128 waypoints. I am aware of the overhead of scheduling, so I made a queue system that executes when a certain number is reached or at specified intervals.


RE: Doesn't work in Unity 2020.1.41f - josemendez - 11-09-2020

Quote:IJobFor has worked wonders for me to do lots of small jobs in parallel, like swapping textures on meshes based on indices and processing quadtree queries. I also use it for A-star pathfinding for up to 1024 pathfinding requests across 128 waypoints. I am aware of the overhead of scheduling, so I made a queue system that executes when a certain number is reached or at specified intervals.

We use the same concept: only call JobHandle.ScheduleBatchedJobs(); after a certain number of jobs has been scheduled (currently set to 16). Still, this was quite surprising to me at first, as the in-house job system we use for the c++ backend has virtually zero scheduling overhead.

Still trying to reproduce the initial issue, will get back to you as soon as I have an idea of what's happening.


RE: Doesn't work in Unity 2020.1.41f - quakeulf - 11-09-2020

It works with using Oni.

However, the reason I want to use the Job system is that it is now supported in WebGL by using:
Code:
PlayerSettings.WebGL.threadsSupport = true;
As per the post in the Unity-fora here: https://forum.unity.com/threads/2019-1.597238/

I cannot make a blueprint because of this error I get when I try to create one:

Assertion failed on expression: 'fRoot >= Vector3f::epsilon'
UnityEngine.Matrix4x4:get_rotation()
Obi.ObiUtils:GetPointCloudAnisotropy(List`1, Single, Single, Vector3&, Vector3&, Quaternion&, Vector3&) (at Assets/Obi/Scripts/Common/Utils/ObiUtils.cs:792)
Obi.<Initialize>d__10:MoveNext() (at Assets/Obi/Scripts/Softbody/Blueprints/ObiSoftbodySurfaceBlueprint.cs:139)
Obi.<Generate>d__57:MoveNext() (at Assets/Obi/Scripts/Common/Blueprints/ObiActorBlueprint.cs:292)
Obi.<Start>d__15:MoveNext() (at Assets/Obi/Scripts/Common/Utils/Coroutines/CoroutineJob.cs:99)
Obi.EditorCoroutine:ShowCoroutineProgressBar(String, IEnumerator&) (at Assets/Obi/Scripts/Common/Utils/Coroutines/EditorCoroutine.cs:21)
Obi.ObiActorBlueprintEditor:Generate() (at Assets/Obi/Editor/Common/Blueprints/ObiActorBlueprintEditor.cs:110)
Obi.ObiActorBlueprintEditor:OnInspectorGUI() (at Assets/Obi/Editor/Common/Blueprints/ObiActorBlueprintEditor.cs:128)
UnityEngine.GUIUtilityLenguarocessEvent(Int32, IntPtr, Boolean&)

Which means I can't get it work on my FBX because when I try "Bind Skin" I get this:

Quaternion To Matrix conversion failed because input Quaternion is invalid {nan, nan, nan, nan} l=nan
UnityEngine.Matrix4x4:TRS(Vector3, Quaternion, Vector3)
Obi.<BindSkin>d__17:MoveNext() (at Assets/Obi/Scripts/Softbody/Rendering/ObiSoftbodySkinner.cs:180)
Obi.<Start>d__15:MoveNext() (at Assets/Obi/Scripts/Common/Utils/Coroutines/CoroutineJob.cs:99)
Obi.EditorCoroutine:ShowCoroutineProgressBar(String, IEnumerator&) (at Assets/Obi/Scripts/Common/Utils/Coroutines/EditorCoroutine.cs:21)
Obi.ObiSoftbodySkinnerEditor:OnInspectorGUI() (at Assets/Obi/Editor/Softbody/ObiSoftbodySkinnerEditor.cs:67)
UnityEngine.GUIUtilityLenguarocessEvent(Int32, IntPtr, Boolean&)

It also says I am sending forms too often so I cannot reply anywhere? WTF is this? I paid for this software!

Edit 3:

I have spent hours trying to figure out what is wrong. I cannot create new posts. I cannot create new threads. All I can do 10% of the time is edit this post. I keep getting errors every step of the way when I try something. This was supposed to save me time for a demo, but has so far cost more than is defensible. This is really frustrating.

Edit 4:

I get these errors when I tried to look over the blueprint settings and clicked Radius:

Evaluate: time parameter is not a valid number
UnityEngine.Gradient:Evaluate(Single)
Obi.ObiBlueprintFloatProperty:ToColor(Int32) (at Assets/Obi/Editor/Common/Blueprints/Properties/BaseTypes/ObiBlueprintFloatProperty.cs:91)
Obi.ObiMeshBasedActorBlueprintEditorGran sonrisarawGradientMesh(Single[], Single[]) (at Assets/Obi/Editor/Common/Blueprints/ObiMeshBasedActorBlueprintEditor.cs:127)
Obi.ObiBlueprintRenderModeMesh:OnSceneRepaint(SceneView) (at Assets/Obi/Editor/Common/Blueprints/RenderModes/ObiBlueprintRenderModeMesh.cs:42)
Obi.ObiActorBlueprintEditor:OnSceneGUI(SceneView) (at Assets/Obi/Editor/Common/Blueprints/ObiActorBlueprintEditor.cs:294)
UnityEngine.GUIUtilityLenguarocessEvent(Int32, IntPtr, Boolean&)


RE: Doesn't work in Unity 2020.1.41f - josemendez - 14-09-2020

Quote:As per the post in the Unity-fora here: https://forum.unity.com/threads/2019-1.597238/

I cannot make a blueprint because of this error I get when I try to create one:

Assertion failed on expression: 'fRoot >= Vector3f::epsilon'
UnityEngine.Matrix4x4:get_rotation()
Obi.ObiUtils:GetPointCloudAnisotropy(List`1, Single, Single, Vector3&, Vector3&, Quaternion&, Vector3&) (at Assets/Obi/Scripts/Common/Utils/ObiUtils.cs:792)
Obi.<Initialize>d__10:MoveNext() (at Assets/Obi/Scripts/Softbody/Blueprints/ObiSoftbodySurfaceBlueprint.cs:139)
Obi.<Generate>d__57:MoveNext() (at Assets/Obi/Scripts/Common/Blueprints/ObiActorBlueprint.cs:292)
Obi.<Start>d__15:MoveNext() (at Assets/Obi/Scripts/Common/Utils/Coroutines/CoroutineJob.cs:99)
Obi.EditorCoroutine:ShowCoroutineProgressBar(String, IEnumerator&) (at Assets/Obi/Scripts/Common/Utils/Coroutines/EditorCoroutine.cs:21)
Obi.ObiActorBlueprintEditor:Generate() (at Assets/Obi/Editor/Common/Blueprints/ObiActorBlueprintEditor.cs:110)
Obi.ObiActorBlueprintEditor:OnInspectorGUI() (at Assets/Obi/Editor/Common/Blueprints/ObiActorBlueprintEditor.cs:128)
UnityEngine.GUIUtilityLenguarocessEvent(Int32, IntPtr, Boolean&)

Which means I can't get it work on my FBX because when I try "Bind Skin" I get this:

Quaternion To Matrix conversion failed because input Quaternion is invalid {nan, nan, nan, nan} l=nan
UnityEngine.Matrix4x4:TRS(Vector3, Quaternion, Vector3)
Obi.<BindSkin>d__17:MoveNext() (at Assets/Obi/Scripts/Softbody/Rendering/ObiSoftbodySkinner.cs:180)
Obi.<Start>d__15:MoveNext() (at Assets/Obi/Scripts/Common/Utils/Coroutines/CoroutineJob.cs:99)
Obi.EditorCoroutine:ShowCoroutineProgressBar(String, IEnumerator&) (at Assets/Obi/Scripts/Common/Utils/Coroutines/EditorCoroutine.cs:21)
Obi.ObiSoftbodySkinnerEditor:OnInspectorGUI() (at Assets/Obi/Editor/Softbody/ObiSoftbodySkinnerEditor.cs:67)
UnityEngine.GUIUtilityLenguarocessEvent(Int32, IntPtr, Boolean&)

I'm unable to reproduce any of these. Would it be possible for you to send your mesh to our support email (support(at)virtualmethodstudio.com)? This way I can test with the exact same input you're using and figure out the cause of this.

Based on the error message, my guess is that your mesh is non-manifold and has either overlapping vertices, zero-area faces, or zero-length edges, or a combination of these. This is what the fRoot >= Vector3f::epsilon assert hints at. Non-manifold meshes are not supported, and they should be fixed before using them. Not that using non-manifold meshes is good practice anywhere as they give rise to a plethora of issues, but for physics simulation they're specially problematic.

I've also seen cases of people using extremely small meshes (less than a millimeter in size, in Unity units), then compensate for this by using extremely large scale values in the transform hierarchy so that they render correctly. Floating point precision issues aside, since softbody blueprint generation works by quantizing vertices that are extremely close together, the entire miniature mesh is quantized to a single point in space. This might (might not) be your case, if so the solution is to use sane values for mesh vertices. Taking a look at the actual mesh will let us figure out the actual cause.

Quote:It also says I am sending forms too often so I cannot reply anywhere? WTF is this? I paid for this software!

This is typical antispam-filter measures. With no filters in place, spammers become a real pita. Machinegun-posting in most forums will only get you flagged as a spammer (re-sending the same posting form many times has the same effect, so you could have triggered the filters accidentally). If you need fast, personalized support, you can also write to support(at)virtualmethodstudio.com. I usually answer within an hour, two hours tops, except during weekends.

Quote:I have spent hours trying to figure out what is wrong. I cannot create new posts. I cannot create new threads. All I can do 10% of the time is edit this post. I keep getting errors every step of the way when I try something. This was supposed to save me time for a demo, but has so far cost more than is defensible. This is really frustrating.

This means the anti spam filters have flagged you as a spammer. Will manually unban you, please accept my apologies for the inconvenience.

Edit: I've whitelisted your user account, which was indeed flagged as a spammer account due to repeated posting in a very short period of time:

[Image: ON6pRvW.png]

The spam filter should no longer bother you, drop me a line to support(at)virtualmethodstudio.com if problems with the forum persist.


RE: Doesn't work in Unity 2020.1.41f - josemendez - 14-09-2020

Back to the original issue, I'm still unable to reproduce it. Installed 2020.1.4f1, latest versions of Burst, Jobs, Collections and Mathematics packages, imported Obi and all scenes run out of the box (both the Burst backend and the Oni backend):




Are you using the jobs debugger? it should be disabled (as it will bring performance down quite considerably). Also disable safety checks and leak detection, as warned in the manual:
http://obi.virtualmethodstudio.com/tutorials/backends.html


RE: Doesn't work in Unity 2020.1.41f - josemendez - 14-09-2020

Could reproduce the issue by enabling the jobs debugger. With it disabled, things run normally, so the workaround for now is to just disable the debugger (which should be done anyway for normal performance).

This error is not present in Unity 2019. With the debugger enabled, no errors are shown in the console and the simulation runs normally using Burst. So it's either a bug in our job scheduling scheme that 2019's job debugger does not catch, or a bug in 2020's job debugger. Will investigate further.


RE: Doesn't work in Unity 2020.1.41f - josemendez - 14-09-2020

Found the cause and fixed it, was indeed an omission in our job code.

Multiple jobs are scheduled when there are multiple actors in the scene, and they all write to different sections the same data arrays. For this reason,
the [NativeDisableContainerSafetyRestriction] attribute is used to mark the read/write arrays so that the job system knows we intend to write to the same array from different jobs.

I forgot to mark one of the arrays, so the job system rightly complains about concurrent writes to the same array -even if they're perfectly safe, as they do not write to the same indices-.

Not sure why Unity 2019 does not pick this up, but 2020 does. Replacing BurstShapeMatchingConstraintsBatch.cs with the attached one will fix the issue. You can find the file at Obi/Scripts/Common/Backends/Burst/Constraints/ShapeMatching/

Let me know if I can be of further help Sonrisa.


RE: Doesn't work in Unity 2020.1.41f - quakeulf - 14-09-2020

(14-09-2020, 01:25 PM)josemendez Wrote: Found the cause and fixed it, was indeed an omission in our job code.

Multiple jobs are scheduled when there are multiple actors in the scene, and they all write to different sections the same data arrays. For this reason,
the [NativeDisableContainerSafetyRestriction] attribute is used to mark the read/write arrays so that the job system knows we intend to write to the same array from different jobs.

I forgot to mark one of the arrays, so the job system rightly complains about concurrent writes to the same array -even if they're perfectly safe, as they do not write to the same indices-.

Not sure why Unity 2019 does not pick this up, but 2020 does. Replacing BurstShapeMatchingConstraintsBatch.cs with the attached one will fix the issue. You can find the file at Obi/Scripts/Common/Backends/Burst/Constraints/ShapeMatching/

Let me know if I can be of further help Sonrisa.
Thank you. I shall have a look hopefully later today.

I will unfortunately be very busy this week, with limited time to test, but from next week again I will have time.