iOS Hard Crash with Draw.Polyline in Immediate draw mode

Avatar
  • updated
  • Unity's Fault

I am currently building for iOS using Shape immediate draw mode function. 

using(var p = new PolylinePath())
{
p.AddPoints(drawCallback.verts);
SetDrawMatrix();
SetDrawZTest(drawCallback.zTest);
Draw.ThicknessSpace = drawCallback.thicknessSpace;
Draw.Polyline(p, drawCallback.thickness, drawCallback.color);
}

This would hard crash the app in iOS14.6. I am currently using IPAD pro 2021 for testing. The error message is:

_MTLDebugValidateIndexBuffer:267: failed assertion 'indexCount(0) must be non-zero.

Reporting a bug? please specify Unity version:
Unity 2020.3.3f1c1
Reporting a bug? please specify Shapes version:
4.0.2
Reporting a bug? please specify Render Pipeline:
URP
Pinned replies
Avatar
yoonack
  • Answer

The problem is fixed so far. Thanks a lot for the update!!

Avatar
yoonack

I found that if I use using statement, the app crash. Instead I used private variable which works ok. Looks like the p is getting disposed before draw command trying to use it.

Avatar
Freya Holmér creator

it sounds like the drawCallback.verts might've been empty at the time of draw. Mind that if you use the Draw.Command, drawing happens slightly later in the pipeline, so timing of drawing will be slightly different

I've also very recently fixed other issues with polylines, it's possible something went wrong related to that issue, which is coming out soon in the next update!

Avatar
yoonack

I have no idea how that timing would affect the draw. It only happens in IPAD, but not in editor. 

public override void DrawShapes(Camera cam)
{
if (m_filterTag != null && m_filterTag.Contains(cam.tag))
{
using (Draw.Command(cam))
{
if (drawList.ContainsKey(cam.tag))
{
foreach (var draw in drawList[cam.tag])
{
//Debug.Log("Drawing " + Time.time);
draw.Draw();
}

drawList[cam.tag].Clear();
}
}
}
}

this is my drawing code. I store all draw into list and iterates it in draw command.

Avatar
Freya Holmér creator
  • Under Review

4.1.0 has been submitted to the asset store now, be sure to try it out again once you've updated!

Avatar
yoonack
  • Answer

The problem is fixed so far. Thanks a lot for the update!!

Avatar
Freya Holmér creator
  • Fixed

glad it worked out!

Avatar
yoonack

Hi, Sorry to reopen the old thread. I updated to new Unity Version 2020.3.16f1c1. The problem seems to exist again. I found that if I use xcode to debug the program, the above error appears. If I run the app in iPAD directly and connect to unity without xcode connected, the problem is gone. I am not sure how this happen.