Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Want more efficiency in your development work? Sign up to receive weekly tech and creative know-how from Unity experts.
    Dismiss Notice
  4. Build games and experiences that can load instantly and without install. Explore the Project Tiny Preview today!
    Dismiss Notice
  5. Nominations have been announced for this years Unity Awards. Celebrate the wonderful projects made by your peers this year and get voting! Vote here!
    Dismiss Notice
  6. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  7. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Unity 2017.4.8f1 LTS and rare TextMeshPro Exception

Discussion in 'Unity UI & TextMesh Pro' started by Lesha-VH, Sep 5, 2018.

  1. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    68
    TextMeshPro-2017.3-1.0.56-Runtime

    1) According Unity Dashboard Report about 0.58% (35 from 6000) of users faces with exception in TextMeshPro::Awake

    Managed Stack Trace:
    TMPro.TMP_Settings.get_defaultStyleSheet ()
    TMPro.TMP_StyleSheet.get_instance ()
    TMPro.TMP_StyleSheet.LoadDefaultStyleSheet ()
    TMPro.TextMeshProUGUI.Awake ()

    Native StackTrace:


    Exception starts after rebuild font asset and just re-place it,
    we never see these exception on local devices.

    Also we have tons of TextMeshProUGUI components in scenes - but exception count is very low (2-3 per user)

    2) and about the same amount of users have another not reproducible exception (1 per user)

    Managed Stack Trace:
    System.Array.Clear (System.Array array, Int32 index, Int32 length)
    System.Collections.Generic.Dictionary`2[System.Int32,System.Int32].Clear ()
    TMPro.TextMeshProUGUI.SetArraySizes (System.Int32[] chars)
    TMPro.TMP_Text.ParseInputText ()
    TMPro.TMP_Text.GetPreferredWidth ()
    TMPro.TextMeshProUGUI.CalculateLayoutInputHorizontal ()
    UnityEngine.UI.LayoutRebuilder.<Rebuild>m__2 (UnityEngine.Component e)
    UnityEngine.UI.LayoutRebuilder.PerformLayoutCalculation (UnityEngine.RectTransform rect, UnityEngine.Events.UnityAction`1 action)
    UnityEngine.UI.LayoutRebuilder.PerformLayoutCalculation (UnityEngine.RectTransform rect, UnityEngine.Events.UnityAction`1 action)
    UnityEngine.UI.LayoutRebuilder.PerformLayoutCalculation (UnityEngine.RectTransform rect, UnityEngine.Events.UnityAction`1 action)
    UnityEngine.UI.LayoutRebuilder.PerformLayoutCalculation (UnityEngine.RectTransform rect, UnityEngine.Events.UnityAction`1 action)
    UnityEngine.UI.LayoutRebuilder.PerformLayoutCalculation (UnityEngine.RectTransform rect, UnityEngine.Events.UnityAction`1 action)
    UnityEngine.UI.LayoutRebuilder.Rebuild (CanvasUpdate executing)
    UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate ()
    UnityEngine.UI.Extensions.HorizontalScrollSnap:Start()


    Native StackTrace:


    3) Can I fix using workaround? or how can I catch these exception on local device?
    Thanks!
     

    Attached Files:

    Last edited: Sep 5, 2018
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,862
    The challenge with all of these are being able to reproduce them to figure out what is causing these errors.

    With regards to (1), perhaps the TMP Settings or the reference to the default style sheet is missing from the TMP Settings. If these were truly missing, I am not sure why it would only show up at such low interval. perhaps timing related on some devices.

    With regards to (2) this is indicative of the arrays being out of sync between what TMP thinks it will need vs. what the layout phase ends up trying to create geometry for. This is text content related where a sprite or surrogate pair or fallback may end up being parsed incorrectly.

    Also had similar cases where on some platforms (IL2CPP vs. DotNet) some whitespaces characters were not categorized the same.

    This is hard to isolate without some repro.

    Are these text objects static (known text) or is the text dynamic / coming from use input or something else? Trying to rule out potential illegal characters or something like that.
     
  3. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    68
    > Are these text objects static (known text) or is the text dynamic / coming from
    > use input or something else?
    > Trying to rule out potential illegal characters or something like that.
    :
    I am sure exception start to appear after Korean/Japanese languages were added.
    (2к х 2k texture, about 3800 characters total)

    Also I notice we have characters with code 9,10,13 in localization somehow...

    character with code 9 is absent in TextMeshPro asset (not shown in Glyph Table)
    however when try to add it manually - TextMeshPro tell that such character exists...

    If we got thousand of exceptions from one user - clear, that all TextMeshPro components fails.
    But we have only few or one from one user..

    May be unprintable characters can cause exception?
    Thanks!
     
    Last edited: Sep 6, 2018
  4. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,862
    Characters such as Tab (9), Linefeed (10) and Carriage Return (13) are synthesized by TMP. As such they will always be available.

    Most likely the issue is some unprintable character or some character which TMP is getting confused about. The challenge is figuring out which one.

    Do you have use input in the project?
     
  5. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    68
    > Do you have use input in the project?
    :
    No Stephan, I do not use...
    I catch the idea about unprintable or some character...
     
  6. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    68
    Second exception was fixed - using workaround.

    I removed Layout Components (content size fitter) from game objects. Somehow multiple re-layouting with TMPro cause that exception...
     
    Last edited: Sep 19, 2018
  7. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    68
    We have only one (!) exception in project according Unity Dashboard (10k dau, 0.38% of users faced with it)

    Managed Stack Trace:


    TMPro.TMP_Settings.get_defaultStyleSheet ()
    TMPro.TMP_StyleSheet.get_instance ()
    TMPro.TMP_StyleSheet.LoadDefaultStyleSheet ()
    TMPro.TextMeshProUGUI.Awake ()


    Stephan, is the source code available for TMPro ?
    I would like to modify source code in that place and write down MORE information to figure out what happening)

    Current call stack is not enough to figure out what to do!
     
    Last edited: Sep 19, 2018
  8. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,862
    Unless you purchased the source code version of TextMesh Pro in the past, the source code is not available.

    The source code is available to all with versions of TextMesh Pro for Unity 2018.1 and up provided via the package manager.

    P.S. I have seen similar reports before which were device specific and timing related. Ie. like normally everything loads fine but in some rare cases, it looks like perhaps some loading delay or startup delay affects the execution of things.

    These are super rare and sadly users and I haven't been able to reproduce those,
     
  9. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    68
    Thanks Stephan!
    Now we are using 2017 LTS but I think I can get package from 2018 and modify sources a little bit)))
     
  10. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    68
    Stephan, we got 30к new users - and 2410 faced with exception
    Not so rare I think
    And we target only device with openGL 3.0 - so we do not have very old devices...
     

    Attached Files:

  11. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,862
    Make sure the project does include the "Default Style Sheet" which should be contained in "TextMesh Pro/Resources/Style Sheets/...".

    Make sure this Style Sheet is assigned in the TMP Settings.

    Then possibly the source of the issue which I guess could occur due to timing issues when trying to load resources...

    Please change the following line of code which perhaps has been wrong for a long time.

    In the TMP_StyleSheets.cs file around line 30, make the following changes.

    Code (csharp):
    1.  
    2. //
    3. if (s_Instance == null)
    4.     s_Instance = Resources.Load<TMP_StyleSheet>("Style Sheets/TMP Default Style Sheet");
    5.  
    6. // Change to
    7. if (s_Instance == null)
    8.     s_Instance = Resources.Load<TMP_StyleSheet>("Style Sheets/Default Style Sheet");
    9.  
    Simply put this was pointing to the wrong file name for the Default Style Sheet. I guess this would only be an issue if for whatever reason, the serialized reference to the default style sheet in the TMP Settings wasn't getting loaded / deserialized correctly for whatever reason.
     
    Last edited: Oct 1, 2018
  12. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    68
    Stephan - all clear. Yes you are right - I renamed "TMP Default Style Sheet" to another name somehow...

    Also, I reproduce this bug on local device - appearance is very irregular and rare. Device is Xiaomi Redmi 4.

    After "clear memory" bug disappear everytime. After launch many application and re-lauch our game it can happen (but not always)

    Visually it looks like no text label on start message box.
     
  13. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    68
    I think the right way is just rename asset to "TMP Default Style Sheet" inside Editor...
    I will check Dashboard on next release.
     
    Last edited: Oct 12, 2018
  14. Lesha-VH

    Lesha-VH

    Joined:
    Jul 3, 2012
    Posts:
    68
    Stephan, I would like to ask you one more question.

    If build Android apk with split obb - where Resource TMPro folder placed?
    As I understand they are places into obb and all clear (we have separate permission ask to access obb using message box with TMPro labels)

    Only Android 6.0(6.1) and some more devices on later Android version does not allow to read obb WITHOUT permission.

    Most devices on Android 7+ allow to read obb (even if permission "android.permission.READ_EXTERNAL_STORAGE" not granted)

    Stephan is it possible to modify TMPro to make it work without loading from Resource Folder?
     
    Last edited: Oct 14, 2018
  15. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    1,862
    Not really given the only API available to load resources at runtime is Resources.Load() which requires said resources be located in a Resources folder. Asset Bundles can be used but those also present their own challenges.

    There are also other issues that surface when using split binary (those are not specific to TMP but do affect TMP).