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


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

Found and fixed the issue. Quick explanation of the cause:

Every simulation step, the solver allocates a temporary native array to hold contact information if collision constraints are enabled. This array is disposed at the end of each timestep.

When the solver is not visible by any camera and deactivated, the contacts array is no longer allocated. However, contact callbacks are still being called, and asking for the size of the (disposed) array. Hence, ObjectDisposedException: Cannot access a disposed object.

Possible solutions are to either stop calling contact callbacks while the solver is out of view, or simply check whether the array exists before asking for its length. I've opted for the second solution, to not break consistency with older versions.

To apply the patch, download and replace the files I'm attaching to this post. They're found in

Assets/Obi/Scripts/Common/Backends/Burst/Constraints/ColliderCollision/

and

Assets/Obi/Scripts/Common/Backends/Burst/Constraints/ParticleCollision/

Let me know how it goes!


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

(29-09-2021, 10:58 AM)josemendez Wrote: Found and fixed the issue. Quick explanation of the cause:

Every simulation step, the solver allocates a temporary native array to hold contact information if collision constraints are enabled. This array is disposed at the end of each timestep.

When the solver is not visible by any camera and deactivated, the contacts array is no longer allocated. However, contact callbacks are still being called, and asking for the size of the (disposed) array. Hence, ObjectDisposedException: Cannot access a disposed object.

Possible solutions are to either stop calling contact callbacks while the solver is out of view, or simply check whether the array exists before asking for its length. I've opted for the second solution, to not break consistency with older versions.

To apply the patch, download and replace the files I'm attaching to this post. They're found in

Assets/Obi/Scripts/Common/Backends/Burst/Constraints/ColliderCollision/

and

Assets/Obi/Scripts/Common/Backends/Burst/Constraints/ParticleCollision/

Let me know how it goes!

It worked. Thanks!


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

(29-09-2021, 03:21 PM)mattiaswargren Wrote: It worked. Thanks!

Fixed here as well. Thanks, Jose!