Draw calls with empty strings very slow

I’ve raised the issue on Github, for Github users the video should be accessible. I just don’t think this repo is the correct place to raise this bug so duplicating here…
Draw performance heavily degraded when using empty strings · Issue #542 · mcneel/rhino3dm (github.com)

I’m rendering text to the viewport via a conduit and I recently decided to remove the text if the value being represented is close to zero. My hacky fix was just to convert to an empty string if the value was close to 0… it was the least effort option. However, the draw performance is painfully slow. When I reverted this back to displaying the 0 value, the performance was back to normal.

I believe this is a bug so more for the rhino team.

Hi @Mike26,

Can you provide a code sample, that we can easily run here, that reproduces the slowness you’re seeing?

Thanks,

– Dale

Do you want a complete sample project/addin. This conduit should replicate the problem.

internal class CustomConduit : DisplayConduit 
{
    private string _testString = string.Empty;

    protected override void CalculateBoundingBox(CalculateBoundingBoxEventArgs e)
    {
        base.CalculateBoundingBox(e);
    }

    protected override void PreDrawObjects(DrawEventArgs e)
    {
        for (int i = 0; i < 1000; i++)
        {
            e.Display.Draw2dText(_testString, Color.Red, new Point3d(), true, 11);
        }
    }
}

Hi @Mike26,

So if you know the string is null or empty, why try drawing it?

– Dale

yer I have since excluded all empty strings from rendering. I.e. filter out all doubles close to 0 before converting to text (and apply the same filtering over the points). This means I am no longer trying to draw these. I can confirm there are no null values, all strings are empty.

I just thought it odd behaviour (i.e. rendering “0” vs string.Empty greatly improved performance).