WireSphere exception: "Cannot call Join when there are no line segments written"

Hi,

I am getting the exception “Cannot call Join when there are no line segments written” when drawing a single WireSphere. Here’s the code:

using Drawing;
using UnityEngine;

namespace Hello
{
    public class Test : MonoBehaviour
    {
        void Update()
        {
            Draw.ingame.WireSphere(Vector3.zero, 1f, Color.white);
        }
    }
}

I’ve tested various things, e.g. wrapping it with using (draw.WithLineWidth(1f, false)), but the exception still occurs. Other shapes do not give this exception (I’ve tested CircleXY, WireBox, WireCylinder).

I’m using URP and I’m developing for singlepass VR, but the exception only occurs when playing from editor (with a single camera). It does not occur on device (Oculus Quest 2). However, I need it to work in editor play mode as well, for debugging purposes.

Here’s the full stracktrace for the first time this exception occurs:

Exception: Cannot call Join when there are no line segments written
Drawing.CommandBuilder+Builder.Join (System.Int32 lineByteOffset) (at Assets/ALINE/CommandBuilder.cs:2587)
Drawing.CommandBuilder+Builder.AddCircle (Drawing.CommandBuilder+CircleData circle) (at Assets/ALINE/CommandBuilder.cs:2780)
Drawing.CommandBuilder+Builder.Next (Unity.Collections.LowLevel.Unsafe.UnsafeAppendBuffer+Reader& reader, Unity.Collections.NativeArray`1[Unity.Mathematics.float4x4]& matrixStack, Unity.Collections.NativeArray`1[UnityEngine.Color32]& colorStack, Unity.Collections.NativeArray`1[Drawing.CommandBuilder+LineWidthData]& lineWidthStack, System.Int32& matrixStackSize, System.Int32& colorStackSize, System.Int32& lineWidthStackSize) (at Assets/ALINE/CommandBuilder.cs:2949)
Drawing.CommandBuilder+Builder.Execute () (at Assets/ALINE/CommandBuilder.cs:3041)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <0847a0faf94444ccbaf1958021b27f54>:0)

The exception then keeps happening even though play mode has been paused because of the exception, but with a longer stacktrace:

Exception: Cannot call Join when there are no line segments written
Drawing.CommandBuilder+Builder.Join (System.Int32 lineByteOffset) (at Assets/ALINE/CommandBuilder.cs:2587)
Drawing.CommandBuilder+Builder.AddCircle (Drawing.CommandBuilder+CircleData circle) (at Assets/ALINE/CommandBuilder.cs:2780)
Drawing.CommandBuilder+Builder.Next (Unity.Collections.LowLevel.Unsafe.UnsafeAppendBuffer+Reader& reader, Unity.Collections.NativeArray`1[Unity.Mathematics.float4x4]& matrixStack, Unity.Collections.NativeArray`1[UnityEngine.Color32]& colorStack, Unity.Collections.NativeArray`1[Drawing.CommandBuilder+LineWidthData]& lineWidthStack, System.Int32& matrixStackSize, System.Int32& colorStackSize, System.Int32& lineWidthStackSize) (at Assets/ALINE/CommandBuilder.cs:2949)
Drawing.CommandBuilder+Builder.Execute () (at Assets/ALINE/CommandBuilder.cs:3041)
Unity.Jobs.IJobExtensions+JobStruct`1[T].Execute (T& data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at <0847a0faf94444ccbaf1958021b27f54>:0)
Unity.Jobs.JobHandle:ScheduleBatchedJobsAndComplete(JobHandle&)
Unity.Jobs.JobHandle:Complete()
Drawing.ProcessedBuilderData:BuildMeshes(DrawingData) (at Assets/ALINE/DrawingData.cs:270)
Drawing.ProcessedBuilderDataContainer:SubmitMeshes(DrawingData, Camera, Int32, Boolean, Boolean) (at Assets/ALINE/DrawingData.cs:712)
Drawing.DrawingData:Render(Camera, Boolean, CommandBuffer, Boolean, DetectedRenderPipeline) (at Assets/ALINE/DrawingData.cs:1101)
Drawing.DrawingManager:Submit(Camera, CommandBuffer, Boolean, Boolean) (at Assets/ALINE/DrawingManager.cs:553)
Drawing.DrawingManager:SubmitFrame(Camera, CommandBuffer, Boolean) (at Assets/ALINE/DrawingManager.cs:415)
Drawing.DrawingManager:ExecuteCustomRenderPass(ScriptableRenderContext, Camera) (at Assets/ALINE/DrawingManager.cs:353)
Drawing.AlineURPRenderPass:Execute(ScriptableRenderContext, RenderingData&) (at Assets/ALINE/AlineURPRenderPassFeature.cs:16)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

Thanks for your time.

Hmm. Where in the scene is your camera in this case?

The camera is at 0,0,0, same as the WireSphere.

I tried moving the camera and WireSphere around, and my conclusion is that this exception only occurs when the camera and WireSphere are in the exact same position (and not necessarily at world origin 0,0,0).

1 Like

Yeah, that was my suspicion. I think there might be some division by zero in that case. I’ll investigate.

2 Likes

I have the same exception.

It happens if I try to draw something on start, if I delay it by 0.1f seconds the exceptions aren’t thrown.

Most likely it is the same issue at the start the camera and the drawing is at the same spot just for one frame.

Yup. I think that’s the case.