Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

TextMesh Pro TextMesh Pro InputField Incorrect Editing Behavior on Emojis

Discussion in 'Unity UI & TextMesh Pro' started by foundway, Nov 8, 2018.

  1. foundway

    foundway

    Joined:
    May 30, 2013
    Posts:
    14
    Hi,

    I am trying default emoji support with unicode in the out-of-box package (with EmojiOne). What I found is that displaying is perfect, but while I use the provided 16 emojis in TMP_InputField. Something unwanted happened when I try to Backspace or Select and Edit.

    To reproduce:
    1. Import TextMesh Pro
    2. Create a new scene
    3. Create a TextMesh Pro - InputField (TMP_InputField)
    4. Type one of the 16 provided emoji (for test purpose, just copy and paste this character: )
    5. The emoji should display correctly at this point
      01.PNG
    6. While Caret is at the end, hit Backspace and it becomes:
      02.PNG
      And we got unstopping errors:
      Assertion failed: TLS Allocator ALLOC_TEMP_THREAD, underlying allocator ALLOC_TEMP_THREAD has unfreed allocations, size 71680
    7. The same thing happen if you hit Delete while caret is at the beginning of the input field.
    Seems like Emoji 6.0 uses two characters in Unity's text field but keyboard operation works only one character at a time. So far I haven't able to find any work around. Anyone runs into the same issue?
     
  2. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    2,505
    This is a known issue and something I need to address.

    Most Emojis are mapped in the UTF32 range and require the use of surrogate pairs. So when you delete / use backspace, you end up deleting half of the surrogate pair which is an invalid character and leads to this issue.
     
  3. faleoc

    faleoc

    Joined:
    Aug 13, 2018
    Posts:
    1
    Thanks for your prompt response!

    I plan to try two possible workarounds:
    (1) Process TMP_InputField.text at OnValueChanged to remove the left over invalid character. But problem with this method is that the Assertion failure will probably still happen.
    (2) Use <sprite=xxx> fallback in text and process it at OnValueChanged with REGEX to remove unpaired "<" or ">". This method is probably more reliable than former one.

    Any other ideas? I'll post how the workaround works here when I get to it.
     
  4. iansp

    iansp

    Joined:
    Nov 21, 2016
    Posts:
    4
  5. Stephan_B

    Stephan_B

    Unity Technologies

    Joined:
    Feb 26, 2017
    Posts:
    2,505
    Thank for submitting a bug report.

    I just took a look at it and the handling of sprites / emojis which use surrogate pairs has been addressed in the latest version of the TextMesh Pro package which is version 1.4.0. Please upgrade to this latest release.

    Be sure to backup your project first and make sure you close all open scenes before updating TMP via the package manager.

    Below is a video of the new behavior.

    https://imgur.com/RVX6Ts1