Crash/Editor freeze with TextOverflowModes.Ellipsis + multiline + subscript

I’m on 2.1.0-preview.8. Steps to reproduce:

  • Create a TextMeshProUGUI element in an empty scene
  • In Inspector, set height to 100 (or enable Auto Size) to fit more than one line
  • In Inspector, set overflow to Ellipsis
  • In Inspector, begin text with and start typing until a new line wouldn’t fit anymore and text should be truncated with ellipsis shown.

I wonder what’s going on here and would there be a workaround?

I was able to reproduce the behavior with the steps you provided.

This issue is an edge case related to using superscript on the first character. I’ll try taking a look at this later today and provide some feedback once I have more information.

Out of curiosity, what is the use case for using superscript on the first character of the text?

The use case is allowing user input with rich text. Some seem to love their subscript…

Users exploiting :eyes:

I’ll follow up as soon as I have more information, I should be able to get this resolve in Preview 9.

The following changes in both TMPro_Private.cs around line 3090 and TMPro_UGUI_Private.cs around line 3188 should resolve this issue. This change will need to be made in the Global Package cache.

// Replace this single line
float textHeight = m_maxAscender - m_ElementDescender + (m_lineOffset > 0 && m_IsDrivenLineSpacing == false ? m_maxLineAscender - m_startOfLineAscender : 0);

// With the following
float ascender = Mathf.Max(elementAscender, m_maxAscender);
float textHeight = ascender - m_ElementDescender + (m_lineOffset > 0 && m_IsDrivenLineSpacing == false ? m_maxLineAscender - m_startOfLineAscender : 0);

Please confirm this change is working as expected on your end.

This change will be included in Preview 9 of the TMP package which I will try to release over the weekend.

Unfortunately that doesn’t help, I’m still getting the same even after making those changes.

Make sure the change is made in the Global Cache otherwise the changes are lost whenever you close / open Unity.

I will re-check again on my end.

Hi Stephan, any update on this? I can still reproduce this using the same steps. Unity 2019.2.21f.

I added some log output to make sure the altered versions of the classes are in use, even tried replacing the other similar lines of code (around 2444 in TMPro_Private.cs and 2542 in TMPro_UGUI_Private.cs).

I am still working on Preview 9 and working on making sure these issues are resolved. There are some edge cases that I was not covering well like the use of superscript (the entire text) or or crazy mix of the above.