Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Feedback Abnormal video memory usage of TextMesh Pro plugin with WebGL 2.0

Discussion in 'Web' started by catdocqq, Dec 6, 2023.

  1. catdocqq

    catdocqq

    Joined:
    Sep 19, 2017
    Posts:
    6
    I discovered an issue while developing a WebGL project using the TextMesh Pro plugin.

    When using WebGL 1.0 as the graphics API, the engine uses a text atlas texture size of 2048x2048 with a texture format of GL_ALPHA, occupying 4 MB of VRAM.

    However, when switching to WebGL 2.0, the text atlas texture size remains the same, but the texture format changes to GL_RGBA8, increasing the VRAM usage to 16 MB. It seems that the texture format in WebGL 2.0 is problematic.

    I tested this in Unity version 2021.3.16f1 LTS and it might be present in other Unity versions as well. Are there any plans from Unity officials to address this issue?
    I've attached a Unity project that reproduces this issue.


    This is a screenshot of a frame:
    upload_2023-12-6_20-36-9.png
     

    Attached Files:

  2. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,010
    That's really weird, especially since WebGL 2.0 still supports GL_ALPHA as a format the same way 1.0 did.
     
  3. catdocqq

    catdocqq

    Joined:
    Sep 19, 2017
    Posts:
    6
    Yes, it looks like an internal bug in the Unity engine.
     
  4. PanthenEye

    PanthenEye

    Joined:
    Oct 14, 2013
    Posts:
    2,005
    Latest version of the engine for 2021 cycle is 2021.3.33f1. This might've already been addressed in a later release of the engine or TMPro package release. Your first move should be to update, or at least scan the changelogs of both the engine and the package.
     
    Ryiah likes this.
  5. catdocqq

    catdocqq

    Joined:
    Sep 19, 2017
    Posts:
    6
    Developers are unlikely to easily upgrade Unity engine versions. Isn't it more efficient to provide immediate feedback and seek help from the community when issues are discovered, rather than downloading a new engine version for testing or sifting through lengthy update logs? Of course, if no one responds in the end, then perhaps following your suggestion is a viable option.
     
  6. Murgilod

    Murgilod

    Joined:
    Nov 12, 2013
    Posts:
    10,010
    It's an LTS branch so it's never API changes, just bugfixes.
     
    Ryiah likes this.
  7. catdocqq

    catdocqq

    Joined:
    Sep 19, 2017
    Posts:
    6
    Thank you for letting me know. Unfortunately, it seems that the issue still persists in Unity 2021.3.33f1.
     
  8. catdocqq

    catdocqq

    Joined:
    Sep 19, 2017
    Posts:
    6
    The font texture indeed shows an allocation of 16MB in the Memory Profiler.
    upload_2023-12-8_17-8-20.jpeg
     
  9. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    2,032
    My memory is really fuzzy on this, but I swear while updating a project from Unity 2018 to a more modern version, I ran into a problem with alpha8 atlases no longer working, maybe just for sprites, maybe also for TMPro.

    I wish I could remember the exact details, but I do vividly remember something somewhere messing up my painstaking efforts to minimise ram usage via using alpha8 for all my icons, text, and other UI elements, that had worked fine for nearly a decade.

    Perhaps the issue you've found with TMPro in webgl2 is symptomatic of a different issue/bug that I ran into, where by alpha8 for some tasks is not permitted, where it once was.

    I'll add more details once I get back to that project, but currently with everything that happened with Unity in the last few months i've lost interest in putting much effort into it and am busy with other commitments.
     
  10. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,223
    This is the general discussion forum - for a serious issue ask it in the TextMesh Pro or webgl forum and report a bug
     
  11. catdocqq

    catdocqq

    Joined:
    Sep 19, 2017
    Posts:
    6
    I apologize, this post was placed in the wrong location.
     
    Last edited: Dec 12, 2023