IndexOutOfRangeException on FillCharacterVertexBuffers method call

I’ve just recently switched over to the integrated Unity version of TMP, before this I’ve been using the package version from Digital Native Studios website.

I always get a lot of IndexOutOfRangeExceptions showing up on my Unity Online Services Performance report for my Google Play Android build. The full exception log I get back is along the lines of:

TMPro.TextMeshProUGUI.GenerateTextMesh ()
TMPro.TextMeshProUGUI.GenerateTextMesh ()
TMPro.TextMeshProUGUI.OnPreRenderCanvas ()
TMPro.TextMeshProUGUI.Rebuild (CanvasUpdate update)
UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate ()
UnityEngine.Canvas:SendWillRenderCanvases()```

I've been unable to recreate this exception my end and don't really have a sense of where/how this exception is caused. 

Any ideas how I can fix this or what causes this issue?

It is probably because of the graphics cards memory. Your PC has a lot of it, the phone not.
Not sure though, if the size of the font texture is the problem or the number of rendered characters on the screen. probably the latter. So, write less text and see if it solves your problem.
If yes, you probably need to go for a workaround and display your text in several text field. This should be possible then because the graphics card doesn’t render the whole text in one batch…
Another option could be the details of the font characters. if they have a lot of details, more vertices are needed to form it… So choosing another font could also fix your problem.

These are just best guesses. I am not so deep into TMP, so maybe some thoughts are not correct.

Make sure you are using the latest version of the TMP UPM package which is version 1.2.4.

This error is indicative of the buffers being allocated during parsing of the text not matching those during layout. For example, given a certain block of text, during the parsing phase, TMP might think it needs to allocated buffers for 10 visible characters whereas in the layout phase (on that platform) it somehow ends up trying to display 11 characters (one too many thus resulting in this out of range exception.

Without looking at the actual project, this is hard to isolate but here are a few things to look through.

(1) Look for any text that might contain special characters (non breaking space, no width space, carriage return without a linefeed, etc)?

(2) Are you using sprites within the text or using the tag?

(3) Are you using any fallback font assets?