Unity 6.5 UI Toolkit TextElement throws

Switched to Unity 6.5 from 6.3, I’m using UI Toolkit
Got logic hooked to Label.PostProcessTextVertices
Now I receive error:

ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index

In here:

public class FadeInTypewriter :
        ITextTypewriter
    {
        public void Apply(
            TextElement.GlyphsEnumerable glyphs,
            float progress)
        {
            var scaledProgress = progress * glyphs.Count;
            var i = 0;

            foreach (var glyph in glyphs)
            {
                var glyphProgress = Mathf.Clamp01(scaledProgress - i);
                SetGlyphAlpha(glyph, (byte)(255 * glyphProgress));
                i++;
            }
        }
    }

Enumerating foreach (var glyph in glyphs) throws
TextElement, this line:

this.Current = new TextElement.Glyph(this.m_Vertices[glyphRenderInfo.meshIndex].Slice<Vertex>(glyphRenderInfo.textElementInfoIndex * 4, 4), glyphRenderInfo.lineIndex, linkID, (TextElement.GlyphKind) glyphRenderInfo.kind);

The text that I try to print:

<i>(booming, furious)</i><br><b>WHAT IS GOING ON IN HERE?!</b>

After this all texts are broken and invisible
Other places seems fine, but not this one
Is this Unity Bug?

Please file a bug report. Unity QA will tell you if this is from Unity or not.

If a foreach over an enumeration supplied to you by implementing a Unity interface is throwing, then yes that’s a Unity bug.

Yes to both of you, I was just hoping it’s a known bug, but seems not
Anyway, reported to Unity, hope it’ll get fixed

Hi @stroibot! Thanks for bringing this up.

We have a fix in the main branch that’s currently pending backports. You can track its progress here: Unity Issue Tracker - OOR Exception in PostProcessTextVertices

Oh good, thanks!

But I guess I will postpone upgrade for now :smiley:

Of course! Thanks again for bringing this up. Heads up, the fix is landing in 6000.5.0b6.