Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TextMesh Pro SendMessage warnings from TextMeshProUGUI:OnValidate

Discussion in 'UGUI & TextMesh Pro' started by Baste, Jul 6, 2018.

  1. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    Hi!

    We have quite a few canvases in our scene with TextMeshProUGUI elements on them. Whenever we exit play mode, it seems like every one of them (about 200) spits out this stack trace:

    Code (csharp):
    1. SendMessage cannot be called during Awake, CheckConsistency, or OnValidate
    2. UnityEngine.Material:GetTexture(Int32)
    3. TMPro.TextMeshProUGUI:LoadFontAsset()
    4. TMPro.TextMeshProUGUI:OnValidate()
    This is somewhat annoying, as it obscures all other warning messages.

    The issue is relatively recent - I think it started showing up in 2018.1.

    Now, why Material.GetTexture would cause a SendMessage call is unclear - looking at the reference, the method simply calls an internal method.

    Anyone have any clue what's going on?
     
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This is the first report of this behavior.

    I would suggest checking if you get the same behavior in a new project. See if you can create a simple repro scene?

    If you get the same behavior in the new project, then update to version 1.2.4 of TextMesh Pro which is available via the package manager. If you still get that behavior, then submit a bug report with this new project for me to look at.
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    Hi!

    This took forever on getting back to, due to having a hard time updating to the package manager version, and having a hard time reproducing this consistently.

    It's still happening after the update, but it seems to not be directly due to TMP. Instead, it's the setter for RectTransform.sizeDelta calling GameObject::SendMessageAny in some/all code paths - I don't have source access, so this is just from reading off a full call stack. A bunch of UI components seem to be setting rect transform's size delta from OnValidate.

    I managed to reproduce it consistently with an aspect ratio fitter, the bug report is Case 1091720. I'm pretty sure it's exactly the same thing as is happening with TMP. Here's the full call stack from the aspect ratio fitter case:

     
  4. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    275
    @Baste do you have any information on your issue ?
    Cause since we used Unity 2018.3 (we didn't use any other 2018 version) we have a lot of these warnings (something like 170 :/)
     
  5. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    Not really. The bug I reported with the aspect ratio fitter is supposed to be fixed in 2018.3 (haven't checked), but the two issues are not necessarily connected. If you've got a consistent repro case, please file a bug report and link it here.
     
  6. aurelien-morel-ubiant

    aurelien-morel-ubiant

    Joined:
    Sep 27, 2017
    Posts:
    275
    As soon as I have a step in a repro project, I will !
     
  7. DrunkenMastah

    DrunkenMastah

    Joined:
    Sep 26, 2017
    Posts:
    51
    SendMessage cannot be called during Awake, CheckConsistency, or OnValidate
    Every time I stop the game in the Editor I get these warnings. (about 16 or so)
    I get these warnings even on my Jenkins build server logs.
     
  8. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,924
    This is definitely a Unity bug.

    I am currently getting this in latest 2018.2 (2018.2.20 as of Jan 2019), repro case:

    1. Create a custom LayoutGroup (as per Unity's docs)
    2. Override OnValidate to trigger re-layout (as per Unity's docs)
    3. Call Unity's SetSizeWithCurrentAnchors() method (the only correct way to set the size of a RectTransform, provdied by Unity's API)

    ...not much we can do until Unity fixes their bug.

    @Baste - do you have an active public issue link for this? Or is it now closed/resolved?
     
  9. a436t4ataf

    a436t4ataf

    Joined:
    May 19, 2013
    Posts:
    1,924
    NB: I found an official statement from Unity claiming they fixed what apepars to be the underlying problems in Unity 5.x (I think they did - I wasn't seeing the bug until I upgraded to 2018), but they locked the thread to prevent anyone re-opening or reporting cases where they incompletely fixed it / caused a regression, so ... I cannot comment there :(:

    https://forum.unity.com/threads/sen...-awake-checkconsistency-or-onvalidate.428580/
     
  10. CyRaid

    CyRaid

    Joined:
    Mar 31, 2015
    Posts:
    134
    I'm glad it wasn't just me receiving this error, I thought I have done something wrong! I'm using SetSizeWithCurrentAnchors in OnValidate and receiving these warnings. How do we avoid getting this warning while still using SetSizeWithCurrentAnchors?