Error in Editor PhysicsShapeAuthoring

In Editor I have errors if set ShapeType to Mesh or ConvexHull in PhysicsShapeAuthoring

Version Phycis 1.0.16 Entities 1.0.16 Editor 2023.2.0b17
Error Stacktrace

InvalidOperationException: The Unity.Collections.NativeList1[Unity.Mathematics.float3] GetAabbJob.Points can no longer be accessed, since its owner has been invalidated. You can simply Dispose() the container and create a new one. Unity.Jobs.LowLevel.Unsafe.JobsUtility.Schedule (Unity.Jobs.LowLevel.Unsafe.JobsUtility+JobScheduleParameters& parameters) (at <9ed359828c3647ccacf057308e97ae3e>:0) Unity.Jobs.IJobExtensions.Run[T] (T jobData) (at <9ed359828c3647ccacf057308e97ae3e>:0) Unity.Physics.Authoring.PhysicsShapeAuthoring.BakePoints (Unity.Collections.NativeArray1[T] points) (at Assets/Samples/Unity Physics/1.0.16/Custom Physics Authoring/Unity.Physics.Custom/Bodies/PhysicsShapeAuthoring.cs:807)
Unity.Physics.Authoring.PhysicsShapeExtensions.GetBakedConvexProperties (Unity.Physics.Authoring.PhysicsShapeAuthoring shape, Unity.Collections.NativeList1[T] pointCloud) (at Assets/Samples/Unity Physics/1.0.16/Custom Physics Authoring/Unity.Physics.Custom/Utilities/PhysicsShapeExtensions.cs:294) Unity.Physics.Editor.PhysicsShapeAuthoringEditor+PreviewMeshData.GetInputHash (Unity.Physics.Authoring.PhysicsShapeAuthoring shape, Unity.Collections.NativeList1[T] currentPoints, Unity.Collections.NativeArray`1[T] hashedPoints, Unity.Physics.ConvexHullGenerationParameters hashedConvexParameters, Unity.Physics.ConvexHullGenerationParameters& currentConvexProperties) (at Assets/Samples/Unity Physics/1.0.16/Custom Physics Authoring/Unity.Physics.Custom.Editor/Editors/PhysicsShapeAuthoringEditor.cs:241)
Unity.Physics.Editor.PhysicsShapeAuthoringEditor+PreviewMeshData.SchedulePreviewIfChanged (Unity.Physics.Authoring.PhysicsShapeAuthoring shape) (at Assets/Samples/Unity Physics/1.0.16/Custom Physics Authoring/Unity.Physics.Custom.Editor/Editors/PhysicsShapeAuthoringEditor.cs:273)
Unity.Physics.Editor.PhysicsShapeAuthoringEditor.GetPreviewData (Unity.Physics.Authoring.PhysicsShapeAuthoring shape) (at Assets/Samples/Unity Physics/1.0.16/Custom Physics Authoring/Unity.Physics.Custom.Editor/Editors/PhysicsShapeAuthoringEditor.cs:450)
Unity.Physics.Editor.PhysicsShapeAuthoringEditor.OnSceneGUI () (at Assets/Samples/Unity Physics/1.0.16/Custom Physics Authoring/Unity.Physics.Custom.Editor/Editors/PhysicsShapeAuthoringEditor.cs:1098)
(wrapper dynamic-method) System.Object.lambda_method(System.Runtime.CompilerServices.Closure,UnityEditor.Editor)
UnityEditor.SceneView.CallOnSceneGUI () (at <27b422c9c8244ee7a30bfe3fd5fcfe7e>:0)
UnityEditor.SceneView.HandleSelectionAndOnSceneGUI () (at <27b422c9c8244ee7a30bfe3fd5fcfe7e>:0)
UnityEditor.SceneView.DoOnGUI () (at <27b422c9c8244ee7a30bfe3fd5fcfe7e>:0)
UnityEditor.SceneView.OnSceneGUI () (at <27b422c9c8244ee7a30bfe3fd5fcfe7e>:0)
UnityEngine.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 parentTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout, UnityEngine.Rect layoutSize, System.Action onGUIHandler, System.Boolean canAffectFocus) (at :0)
UnityEngine.UIElements.IMGUIContainer.HandleIMGUIEvent (UnityEngine.Event e, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Action onGUIHandler, System.Boolean canAffectFocus) (at :0)
UnityEngine.UIElements.IMGUIContainer.DoIMGUIRepaint () (at :0)
UnityEngine.UIElements.UIR.RenderChainCommand.ExecuteNonDrawMesh (UnityEngine.UIElements.UIR.DrawParams drawParams, System.Single pixelsPerPoint, System.Exception& immediateException) (at :0)
Rethrow as ImmediateModeException
UnityEngine.UIElements.UIR.RenderChain.Render () (at :0)
UnityEngine.UIElements.UIRRepaintUpdater.Update () (at :0)
UnityEngine.UIElements.VisualTreeUpdater.UpdateVisualTreePhase (UnityEngine.UIElements.VisualTreeUpdatePhase phase) (at :0)
UnityEngine.UIElements.Panel.UpdateForRepaint () (at :0)
UnityEngine.UIElements.Panel.Repaint (UnityEngine.Event e) (at :0)
UnityEngine.UIElements.UIElementsUtility.DoDispatch (UnityEngine.UIElements.BaseVisualElementPanel panel) (at :0)
UnityEngine.UIElements.UIElementsUtility.UnityEngine.UIElements.IUIElementsUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& eventHandled) (at :0)
UnityEngine.UIElements.UIEventRegistration.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr) (at :0)
UnityEngine.UIElements.UIEventRegistration+<>c.<.cctor>b__1_2 (System.Int32 i, System.IntPtr ptr) (at :0)
UnityEngine.GUIUtility.ProcessEvent (System.Int32 instanceID, System.IntPtr nativeEventPtr, System.Boolean& result) (at <4265ac2a042d44598570f09383687883>:0)

Yes. This is a known issue and fixed in the next release of 1.2.

It’s still not fixed as of 1.2.0-pre.6 I have no working solutions to creating a simple mesh collider. Not in 1.0.16 - 1.2.x. All of the ways available throw errors.

I can confirm I’m running into a bunch of similar errors when attempting to use PhysicsShapeAuthoring (on 1.0.16)

I too confirm that I get lots of these invalid operation exceptions of custom physics authoring components.
The read/write option is enabled for all the meshes I used. This issue makes really hard to work on colliders on sub scenes.

I can put you all at ease. This is an error which is entirely harmless and only occurs at edit time. It’s an error thrown in the preview display for the mesh when you select a game object with a PhysicsShape of type Mesh or Convex.

The fix is in our internal 1.2 development branch and will land with the next version of 1.2.

For the time being, you can safely ignore this error.

still throws in 2023.3.0b1 & 1.2.0-pre.6, also it breaks editor function like double click to focus, so really hard to ignore :frowning:

I’m very sorry for the inconvenience. And I can unfortunately not say at this point when the next 1.2 release will land but it’s coming. If this is too big an issue I can post a patch here which you can apply to the custom physics authoring code. Let me know if this would be required.

sounds great and i think pioneers arround here would love to patch them by ourself !

1 Like

Alright. No problem.
Since the fix is so easy, I’ll just provide you with a screenshot of the diff here.

it fix the problem, but seem causing new leak issue:

Internal: JobTempAlloc has allocations that are more than the maximum lifespan of 4 frames old - this is not allowed and likely a leak

What Unity version are you using?

2023.3.0b1

Thanks. I’ll have a look.
Any particular case in which you get these or it doesn’t matter?
I hadn’t observed these warnings with the editor version I was using. I will report back which version that was.

@filod : I think I found the issue.
Could you please try adding a using at the marked locations below, in front of var pointCloud and var point, respectively?

That should resolve the leak warning.

Note that TempJob allocations are automatically freed after 4 frames. So, while this warning is annoying, given that the leak is only temporary and given that this code is only executed in the editor, it’s not an issue for production.
However, I hope that my fix above resolves this problem. It did on my end, but I am using a slightly different editor version at the moment. That shouldn’t make any difference though.

1 Like

solved ! thx

1 Like