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 Text does not show in build with macOS METAL

Discussion in 'UGUI & TextMesh Pro' started by mons00n, Oct 19, 2018.

  1. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    304
    I'm having an odd issue I'm not sure how to resolve. When I run my build on a mac & metal everything appears fine at my login screen etc; but as soon as I change scenes to enter the game most of the text that should be there is not. If I launch the game with -force-glcore the text shows up as expected; everything also shows up fine when running my client on windows via direct x. There is nothing glaringly obvious in the build log or the player log.

    I've been encountered this issue on 2017.3, 2018.1 and 2018.2. Seems to happen regardless of if the build was made on a windows or mac machine. Any ideas?

    more info: this problem does not occur with 3D TMP objects. Some 2D assets continue to show but there is no common thread linking the ones that are shown and ones that are not shown.
     
    Last edited: Oct 19, 2018
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Just to recap, this only happens using Metal and only for TMP UGUI text objects?

    Are you using a mixture of normal (3D) TMP text objects with TMP UGUI objects where these would share the same font assets / material presets? Although this should impact all platform builds, maybe it behaves differently on Metal.
     
  3. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    304
    Hey Stephan thanks for the reply. I think your assesment is correct as I have only seen this happen with UI TMP objects. I do use the same font on some 3D objects and those appear to be fine. Tomorrow I can try and separate them out and see what happens.

    I just find it peculiar that it only happens after a level load. For example:
    - login scene appears fine with only UI TMP
    - load game level that has mixture of 2d/3D and some 2d is not showing
    - return to login scene to find that some (not all) UI text is no longer showing.
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    This behavior is likely due to using a mixture of normal TMP and TMP UGUI object which share the same material preset. The reason some text objects might disappear is because the Canvas system is fighting with the Mesh Renderer for control over the ZTest.

    The solution is to use one set of material presets for the Canvas system and another for those text objects using the normal TextMesh Pro component. Note that it is fine for both sets of objects (normal TMP vs. TMP UGUI) to share the same font asset but not the same materials (which you have to be careful as font assets have their own default materials so in this case, you do have to assign a preset to avoid them sharing those materials again).
     
  5. mons00n

    mons00n

    Joined:
    Sep 18, 2013
    Posts:
    304
    Hot damn that was it! I moved all of my 3D TMP assets to use a different material preset and the 2D ones started drawing again. This seems to be another odd quirk with METAL since it works with other graphics APIs; is this a bug you need/want me to file or you can investigate from here? Either way thanks for the replies and assistance!
     
  6. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    In theory, it is not a bug as having two objects which share the same material where their respective renderers have different ZTest settings / requirements should be a problem.

    Basically, imagine having two objects which share the same material where one object sets material color to blue and the other to red. You would end up with these two objects ping-ponging / messing each other's color.

    In this case, instead of color it is the ZTest that is getting changed by their renderers which based on potential timing and who draws what and when can result in text disappearing.

    I guess this could be handled under the hood / hidden from the user but it would require some potentially complex system to manage all of this to detect potential conflicts where instances of those materials would need to be created to handle conflicts. In the end, you would still end up with different materials for these conflicts settings and as such I prefer knowing / managing these resources myself.
     
    mons00n likes this.
  7. rhys_vdw

    rhys_vdw

    Joined:
    Mar 9, 2012
    Posts:
    110
    Hi we seem to be having this problem in our build now (with some mac computers). I'm assuming that this is the issue as we have a mix of TextMeshPro and TextMeshProUGUI in use.

    Unity 2019.4.28f1
    TextMeshPro 2.1.6

    This is pretty complicated because we're using a bunch of different font weights spread through various scenes and prefabs, and we're using font overrides to use font weights in rich text:

    upload_2021-7-26_16-17-57.png

    I can't see a way to set which material is used when rich text tags are encountered. Can you advise a workaround @Stephan_B? It looks like maybe the best move to double the entire set of font assets? Realistically this might mean banning rich text from the scene (as we can't do without it in the UI)... However then I still have the problem of enforcing the separate material assignments in each context.

    Please advise.
     
  8. rhys_vdw

    rhys_vdw

    Joined:
    Mar 9, 2012
    Posts:
    110
  9. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    Didn't have a chance to reply until now. Glad you found a potential way to get around the issue.

    Out of curiosity, I understanding that you do have a mixture of normal and UI TMP text objects in your scene where the issue occurs. Do you also happen to have a mixture of UI TMP objects that use a Canvas in World or Camera space as well as text object in Overlay space?
     
  10. rhys_vdw

    rhys_vdw

    Joined:
    Mar 9, 2012
    Posts:
    110
    It appears to be caused by a material shared between a TextMeshPro and a TextMeshProUGUI that is childed to a "Screen Space - Overlay" canvas. No world space canvas loading occurs before the error is seen.
     
  11. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    By error, you mean the text disappearing on the objects using the Screen Space - Overlay?

    P.S. I am currently investigating with the UI team a potential solution. We just need to be able to reliably reproduce the issue which is why I was asking about whether or not you also had UI TMP text objects using a world space canvas.
     
  12. rhys_vdw

    rhys_vdw

    Joined:
    Mar 9, 2012
    Posts:
    110
    Yes I do.

    I'd love to make a minimal example but I don't have a mac machine to test that it reproduces, and we're very busy readying for release.

    Here's a photo of a screen with the problem from a tester:



    My understanding (not deeply tested) is that the regular style font on this (overlay) UI is invisible because its material was shared with a TextMeshPro object in the title screen (before this). There are no TextMeshPro objects in this scene specifically. The italic text is a separate material provided by rich text and style overrides (and has not been shown on a TextMeshPro object), so it succeeds to render.

    Happy to provide more info, I have the broken commit tagged.
     
  13. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    That is interesting. Did the previous scene with the Title contain both types of TMP components?

    Was the previous scene containing the title unloaded or is it still present when this new scene is loaded?

    Since this issue seems to only affect text objects in Overlay space, the developers who work on the Canvas batcher are looking into this. In theory this issue should not occur but it is likely due to some device / driver optimization done on some platforms and not others.

    I'll provide an update as soon as I hear from them.
     
  14. rhys_vdw

    rhys_vdw

    Joined:
    Mar 9, 2012
    Posts:
    110
    Yes it did. Here's the system info for one of the machines that had the issue.

     
  15. rhys_vdw

    rhys_vdw

    Joined:
    Mar 9, 2012
    Posts:
    110
    Also might be worth mentioning that the scene text object is still loaded the whole time but disabled the background