TextMeshPro IndexOutOfRangeException

I am updating a TMPro Ugui (Version 2.1.3) label and get this exception on a very different component lying in the scene and beeing hidden by an alpha blended canvasGroup?

Any help how to digg to the root cause is very appreciated. I have absolutley no clue where to begin digging.

I am looping through different character sets (english, korean, chinese) in a different labeltext causing this to happen.

IndexOutOfRangeException: Index was outside the bounds of the array.
TMPro.TMP_Text.FillSpriteVertexBuffers (System.Int32 i, System.Int32 index_X4) (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMP_Text.cs:6819)
TMPro.TextMeshProUGUI.GenerateTextMesh () (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMPro_UGUI_Private.cs:3905)
TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMPro_UGUI_Private.cs:1654)
TMPro.TextMeshProUGUI.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TextMeshProUGUI.cs:224)
UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at C:/Program Files/UnityHubInstall/2019.4.1f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/UI/Core/CanvasUpdateRegistry.cs:210)
UnityEngine.Canvas:SendWillRenderCanvases()

It happens on this component, on character 7 which is a sprite.

TMP_Text.cs : Line 6816

// i = 7
// index_X4 = 0
protected virtual void FillSpriteVertexBuffers(int i, int index_X4)
{
    int materialIndex = m_textInfo.characterInfo[i].materialReferenceIndex;
    // materialIndex = 2
    // but m_textInfo.meshInfo only has 2 entries => Index Out Of bounds Exception
    // it is a sprite on a different atlas which is configured and works the most time. only oin this constelation it throws an error
    // here should be a check if meshinfo has enough entries to get that, no need for an IndexOutOfBoundsException
    index_X4 = m_textInfo.meshInfo[materialIndex].vertexCount;
 }

Another watch

I am having the same issue after I update to TMPro (1.5.3) using Unity 2018.4.28f1 (same on Unity 2018.4.30f1)
Downgrading to TMPro (1.5.1) solved the issue for me, but I would like to keep using the latest version without this issue

1 Like

OK an update, an animation ping ponged the font alpha from zero to 1 and was causing the bug to happen. I do not have any clue what this means

@Stephan_B can you help us in this issue please

I just need someone to submit a bug report with project or whatever is needed for me to be able to reproduce the issue.

I am working on version 1.5.4 and equivalent release for other unity versions so if I can get this bug report, I can make sure the fix is included in there.

1 Like

On 2.1.3 same stack. Did not investigate further but it’s really recent (Main changes is I rebuilded Font-Awesome and updated TMP Pro to 2.1.3

IndexOutOfRangeException: Index was outside the bounds of the array.
TMPro.TMP_Text.FillSpriteVertexBuffers (System.Int32 i, System.Int32 index_X4) (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMP_Text.cs:6819)
TMPro.TextMeshProUGUI.GenerateTextMesh () (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMPro_UGUI_Private.cs:3905)
TMPro.TextMeshProUGUI.OnPreRenderCanvas () (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMPro_UGUI_Private.cs:1654)
TMPro.TextMeshProUGUI.UpdateSDFScale (System.Single scaleDelta) (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMPro_UGUI_Private.cs:4585)
TMPro.TextMeshProUGUI.InternalUpdate () (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMPro_UGUI_Private.cs:1573)
TMPro.TMP_UpdateManager.DoRebuilds () (at Library/PackageCache/com.unity.textmeshpro@2.1.3/Scripts/Runtime/TMP_UpdateManager.cs:153)
UnityEngine.Canvas.SendWillRenderCanvases () (at <4af5bea1b7b2442494fd73f6f9b3d7f4>:0)

Please see if making the change outlined in the following [post ]( https://discussions.unity.com/t/752139 page-2#post-6607135)resolves the issue.

Hello @Stephan_B ,
Thank you, this change fixed the issue for us.
But we will keep using the older version until you ship an updated version on Package Manager.

Glad to know that resolved this issue. This change will be in the next release which I am hoping to have available by the end of the week.

2 Likes

on line 1616 did if (true/*m_isInputParsingRequired || m_isTextTruncated*/) and the error is indeed gone.
Thank you very much for the hack.

1 Like

just wanted to mention we’ve run into this issue as well. the fix on line 1616 seems to have worked for us, but obviously it’s not a great solution, as modifying a package is not something we can easily maintain or even chare properly via source control for our project. Is there an ETA on an update to TMPro in the package manager with this fix implemented? we are very near a submission date on our project.

2 Likes

Trying to get this new release out this week.

3 Likes

I presume this release still hasn’t been completed, still showing 2.1.3 in Package Manager? I’m fighting this problem at the moment at a critical point in our release, it’s treacherous, as every time I close Unity and re-open it, the hack fix suggested above ([here]( https://discussions.unity.com/t/752139 page-2#post-6607135)) gets wiped out, making the release process quite risky. Any idea when a fix will be released?

1 Like

In final testing of these new releases. Unless I run into some unexpected issue, they will be available this week.

In terms of source code changes, in order to make them persistent, they have to be made in the Global Package Cache.

I’m guessing you ran into some unexpected issues?

I did but was able to resolve them over the weekend.

I’ll do additional testing tomorrow and if all goes well, will proceed with the release.

3 Likes

Hello. Is there any news about the release date?

Should be available later today.