Search Unity

TextMesh Pro Bug: <br> Tag and Overflow mode "Truncate" causes StackOverflow Exception

Discussion in 'Unity UI (uGUI) & TextMesh Pro' started by odysoftware, Aug 15, 2019.

  1. odysoftware

    odysoftware

    Joined:
    Jul 21, 2015
    Posts:
    53
    There is a bug in TMP 2.0.1 from latest Unity Version 2019.2.0 - which causes a StackOverflow in TMPro.

    Code (CSharp):
    1. StackOverflowException: The requested operation caused a stack overflow.
    2. UnityEngine.Object.EnsureRunningOnMainThread () (at /Users/builduser/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:147)
    3. UnityEngine.Object.GetInstanceID () (at /Users/builduser/buildslave/unity/build/Runtime/Export/Scripting/UnityEngineObject.bindings.cs:68)
    4. TMPro.MaterialReference..ctor (System.Int32 index, TMPro.TMP_FontAsset fontAsset, TMPro.TMP_SpriteAsset spriteAsset, UnityEngine.Material material, System.Single padding) (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/MaterialReferenceManager.cs:545)
    5. TMPro.TextMeshProUGUI.GenerateTextMesh () (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs:1699)
    6. TMPro.TextMeshProUGUI.GenerateTextMesh () (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs:2733)
    7. TMPro.TextMeshProUGUI.GenerateTextMesh () (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs:2733)
    8. TMPro.TextMeshProUGUI.GenerateTextMesh () (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs:2733)
    9. TMPro.TextMeshProUGUI.GenerateTextMesh () (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs:2733)
    10. TMPro.TextMeshProUGUI.GenerateTextMesh () (at Library/PackageCache/com.unity.textmeshpro@2.0.1/Scripts/Runtime/TMPro_UGUI_Private.cs:2733)
    11. TMPro.TextMeshProUGUI.GenerateTextMesh ().........
    Its should be easy to reproduce
    - Add a new UI -> Text - TextMeshPro Element to the scene
    - Switch Overflow mode to "Truncate"
    - Resize the object so that at least 2 or more lines of text will fit in scene view
    - Add a few lines of text
    - Now add a <br> tag in one of the first lines so that some text after the <br> will move outside the area (it gets truncates).
    - the error should appear.
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,746
    Good timing.

    I just happened to be re-working the line breaking handling to address a potential issue with Soft Hyphenation and Text Auto-sizing as well as remove the use of recursion and improve performance when using Truncate, Ellipsis, Soft Hyphenation, etc.

    I just tested the above in 1.4.1 and was able to reproduce the issue. Did the same testing in the latest release I am working on with the above changes and it works correctly.

    The above issue will be resolved in the next release of the TMP package. This will be version 2.1.0 and not 2.0.2 as it includes important changes / improvements.

    I am hoping to have this release out in preview within the next 7 days (provided I don't run into any unforeseen issues). Ie. I am close but want to make sure it is good first :)
     
  3. odysoftware

    odysoftware

    Joined:
    Jul 21, 2015
    Posts:
    53
    That sounds great thanks :)
     
  4. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    692
  5. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,746
    Today is my final day of testing on the new release. Unless I run into some unforeseen issue (today) I am planning on releasing the new package tomorrow.
     
    MrLucid72 likes this.
  6. ooochris

    ooochris

    Joined:
    Jul 21, 2013
    Posts:
    2
    Any update on this? Version 2.1 is still in preview. Any plan for the release?
     
  7. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    3,746
    Preview 3 is now available. I would strongly recommend testing with Preview 3 and if all is good to go with that version until the final release is available.
     
unityunity