Obi Official Forum
Bug / Crash "ObjectDisposedException" in cloth objects on scene startup in Unity 2020.3.16f1 - Printable Version

+- Obi Official Forum (https://obi.virtualmethodstudio.com/forum)
+-- Forum: Obi Users Category (https://obi.virtualmethodstudio.com/forum/forum-1.html)
+--- Forum: General (https://obi.virtualmethodstudio.com/forum/forum-5.html)
+--- Thread: Bug / Crash "ObjectDisposedException" in cloth objects on scene startup in Unity 2020.3.16f1 (/thread-3071.html)

Pages: 1 2


"ObjectDisposedException" in cloth objects on scene startup in Unity 2020.3.16f1 - timconkling - 18-08-2021

After upgrading to Unity 2020.3.16f1 (from 2020.3.15), many of my ObiCloth objects have recently started throwing this error when entering Play Mode:

Code:
ObjectDisposedException: Cannot access a disposed object.
Object name: 'The NativeArray has been disposed, it is not allowed to access it'.
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckExistsAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle& handle) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Jobs/AtomicSafetyHandle.bindings.cs:186)
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.ValidateNonDefaultHandle (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle& handle) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Jobs/AtomicSafetyHandle.bindings.cs:175)
Unity.Collections.NativeArray`1[T].get_Length () (at /Users/bokken/buildslave/unity/build/Runtime/Export/NativeArray/NativeArray.cs:117)
Obi.BurstColliderCollisionConstraints.GetConstraintCount () (at Assets/ThirdParty/Obi/Scripts/Common/Backends/Burst/Constraints/ColliderCollision/BurstColliderCollisionConstraints.cs:27)
Obi.BurstSolverImpl.GetConstraintCount (Oni+ConstraintType type) (at Assets/ThirdParty/Obi/Scripts/Common/Backends/Burst/Solver/BurstSolverImpl.cs:405)
Obi.ObiSolver.EndStep (System.Single substepTime) (at Assets/ThirdParty/Obi/Scripts/Common/Solver/ObiSolver.cs:1577)
Obi.ObiUpdater.EndStep (System.Single substepDeltaTime) (at Assets/ThirdParty/Obi/Scripts/Common/Updaters/ObiUpdater.cs:92)
Obi.ObiLateFixedUpdater.LateFixedUpdate () (at Assets/ThirdParty/Obi/Scripts/Common/Updaters/ObiLateFixedUpdater.cs:67)
Obi.ObiLateFixedUpdater+<RunLateFixedUpdate>d__6.MoveNext () (at Assets/ThirdParty/Obi/Scripts/Common/Updaters/ObiLateFixedUpdater.cs:51)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at /Users/bokken/buildslave/unity/build/Runtime/Export/Scripting/Coroutines.cs:17)


Sometimes this is seemingly harmless, and sometimes it results in, for example, my main character's gown being frozen in place:

[attachment=1106]

If I manually disable and re-enable the cloth's `ObiLateFixedUpdater` component at runtime, the cloth simulates properly.

I'm not sure what triggered this - I just updated to Obi 6.2 (from 6.1), and also updated to Burst 1.5.6 (from 1.5.5), but rolling back both of those changes doesn't solve the issue. EDIT: Aha - this was triggered by a Unity update. In Unity 2020.3.15f2, I don't get this error. In Unity 2020.3.16f1 - the most recent LTE release as of today - I do.

(I'm using the Burst backend for Obi.)

Any thoughts on what might be going wrong?


RE: "ObjectDisposedException" in cloth objects on scene startup in Unity 2020.3.16f1 - josemendez - 19-08-2021

Hi there!

Not been able to reproduce this one, will do some more testing and get back to you. I'm leaving for holidays tomorrow, but if this is a critical issue I can try to squeeze a fix asap.


RE: "ObjectDisposedException" in cloth objects on scene startup in Unity 2020.3.16f1 - timconkling - 19-08-2021

(19-08-2021, 01:01 PM)josemendez Wrote: Hi there!

Not been able to reproduce this one, will do some more testing and get back to you. I'm leaving for holidays tomorrow, but if this is a critical issue I can try to squeeze a fix asap.

Cool, thanks! Not a critical issue, I can just stick with the previous version of Unity for the time being. Enjoy your holidays!

(If you're not able to track this down, I can also put together a sample project that demonstrates the error.)


RE: "ObjectDisposedException" in cloth objects on scene startup in Unity 2020.3.16f1 - timconkling - 27-08-2021

Unity 2020.3.17 was released today, and the problem persists, so it wasn't a one-off with a bad Unity version.


RE: "ObjectDisposedException" in cloth objects on scene startup in Unity 2020.3.16f1 - timconkling - 24-09-2021

(19-08-2021, 01:01 PM)josemendez Wrote: Hi there!

Not been able to reproduce this one, will do some more testing and get back to you. I'm leaving for holidays tomorrow, but if this is a critical issue I can try to squeeze a fix asap.

Hi Jose - 

This is still an issue for us with Unity 2020.3.19, and it's stopping us from upgrading Unity. Have you had a chance to look at it?

If you're having trouble reproing, I can put together a test case. In certain scenes in this game, it happens 100% of the time.


RE: "ObjectDisposedException" in cloth objects on scene startup in Unity 2020.3.16f1 - josemendez - 27-09-2021

(24-09-2021, 10:52 PM)timconkling Wrote: Hi Jose - 

This is still an issue for us with Unity 2020.3.19, and it's stopping us from upgrading Unity. Have you had a chance to look at it?

If you're having trouble reproing, I can put together a test case. In certain scenes in this game, it happens 100% of the time.

Hi Tim,

Sorry for the late reply! I've tested on:

- Unity 2020.3.19f1 LTS
- Burst 1.5.4
- Mathematics 1.2.1
- Jobs 0.11.0-preview.6
- Collections 1.0.0-preview.5,

With safety checks enabled, however no errors pop up when running any of the included sample scenes. Also tried a simple scene with just character cloth and collisions (which seems closer to what you have) but still no errors. Building and running a standalone binary also works fine.

If you could send your test case to support(at)virtualmethodstudio.com I'd be glad to take a look at it and see if I can find a fix for it.

kind regards,


RE: "ObjectDisposedException" in cloth objects on scene startup in Unity 2020.3.16f1 - mattiaswargren - 28-09-2021

(27-09-2021, 08:46 AM)josemendez Wrote: Hi Tim,

Sorry for the late reply! I've tested on:

- Unity 2020.3.19f1 LTS
- Burst 1.5.4
- Mathematics 1.2.1
- Jobs 0.11.0-preview.6
- Collections 1.0.0-preview.5,

With safety checks enabled, however no errors pop up when running any of the included sample scenes. Also tried a simple scene with just character cloth and collisions (which seems closer to what you have) but still no errors. Building and running a standalone binary also works fine.

If you could send your test case to support(at)virtualmethodstudio.com I'd be glad to take a look at it and see if I can find a fix for it.

kind regards,

I have the same issue and have found out that it is pretty simple to reproduce.

No Error:
Rope Solver is inside camera view + Simulate When Invisible (true)
Rope Solver is inside camera view + Simulate When Invisible (false)
Rope Solver is outside camera view + Simulate When Invisible (true)

Error:
Rope Solver is outside camera view + Simulate When Invisible (false)


Unity 2020.3.19
Obi Rope 6.0.1
Burst 1.5.6
Jobs 0.11.0
Collections 1.0.0


Code:
ObjectDisposedException: Cannot access a disposed object.
Object name: 'The NativeArray has been disposed, it is not allowed to access it'.
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckExistsAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle& handle) (at <ca496b8c93454b2f9b9924292c19379f>:0)
Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.ValidateNonDefaultHandle (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle& handle) (at <ca496b8c93454b2f9b9924292c19379f>:0)
Unity.Collections.NativeArray`1[T].get_Length () (at <ca496b8c93454b2f9b9924292c19379f>:0)
Obi.BurstColliderCollisionConstraints.GetConstraintCount () (at Assets/Obi/Scripts/Common/Backends/Burst/Constraints/ColliderCollision/BurstColliderCollisionConstraints.cs:27)
Obi.BurstSolverImpl.GetConstraintCount (Oni+ConstraintType type) (at Assets/Obi/Scripts/Common/Backends/Burst/Solver/BurstSolverImpl.cs:406)
Obi.ObiSolver.EndStep (System.Single substepTime) (at Assets/Obi/Scripts/Common/Solver/ObiSolver.cs:1561)
Obi.ObiUpdater.EndStep (System.Single substepDeltaTime) (at Assets/Obi/Scripts/Common/Updaters/ObiUpdater.cs:92)
Obi.ObiFixedUpdater.FixedUpdate () (at Assets/Obi/Scripts/Common/Updaters/ObiFixedUpdater.cs:52)



RE: "ObjectDisposedException" in cloth objects on scene startup in Unity 2020.3.16f1 - josemendez - 28-09-2021

Hi Mattias! thanks for the additional info, will try and reproduce and get back to you asap.


RE: "ObjectDisposedException" in cloth objects on scene startup in Unity 2020.3.16f1 - timconkling - 28-09-2021

(28-09-2021, 05:30 PM)josemendez Wrote: Hi Mattias! thanks for the additional info, will try and reproduce and get back to you asap.

Thanks for the repro, Mattias - yes, this seems to be the same issue I'm seeing.

In the Obi Cloth "CharacterCloth" sample scene, for example, I rotated the camera to face away from the character, and pressed play:

[attachment=1118]


RE: "ObjectDisposedException" in cloth objects on scene startup in Unity 2020.3.16f1 - josemendez - 29-09-2021

Hi there,

I was able to reproduce this issue. I'll fix it asap and provide a patch. Thanks to you both for reporting it!