Search Unity

TextMesh Pro TMPro: Input runtime assignment rethrow errs with Unicode

Discussion in 'UGUI & TextMesh Pro' started by MrLucid72, Mar 19, 2020.

  1. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    I noticed some strange things happening when I assign input text:

    upload_2020-3-19_13-56-11.png

    If I use ASCII, text assignment is fine.
    When I use Unicode, sometimes I'll get a crazy System.AggregateException:

    Code (CSharp):
    1. newInput.text = decodedName + decodedMsg;
    2. System.AggregateException: One or more errors occurred. ---> Mono.Debugger.Soft.InvocationException: Exception of type 'Mono.Debugger.Soft.InvocationException' was thrown.
    3.    at Mono.Debugger.Soft.ObjectMirror.EndInvokeMethodInternalWithResult(IAsyncResult asyncResult)
    4.    at SyntaxTree.VisualStudio.Unity.Debugger.ValueExtensions.<>c__DisplayClass6_0.<InvokeAsync>b__1(ObjectMirror o)
    5.    at SyntaxTree.VisualStudio.Unity.Debugger.ValueExtensions.Dispatch[TRet](Value value, Func`2 onObject, Func`2 onStruct, Func`2 onPrimitive)
    6.    at SyntaxTree.VisualStudio.Unity.Debugger.ValueExtensions.<>c__DisplayClass6_0.<InvokeAsync>b__0()
    7.    at SyntaxTree.VisualStudio.Unity.Debugger.UnityThread.<>c__DisplayClass15_0`1.<Execute>b__0()
    8.    at System.Threading.Tasks.Task`1.InnerInvoke()
    9.    at System.Threading.Tasks.Task.Execute()
    10.    --- End of inner exception stack trace ---
    11.    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
    12.    at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
    13.    at SyntaxTree.VisualStudio.Unity.Debugger.Evaluation.ExpressionEvaluator.VisitAssignmentExpression(AssignmentExpressionSyntax node)
    14.    at Microsoft.CodeAnalysis.CSharp.Syntax.AssignmentExpressionSyntax.Accept(CSharpSyntaxVisitor visitor)
    15.    at SyntaxTree.VisualStudio.Unity.Debugger.Evaluation.ExpressionEvaluator.VisitExpressionStatement(ExpressionStatementSyntax node)
    16.    at Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax.Accept(CSharpSyntaxVisitor visitor)
    17.    at SyntaxTree.VisualStudio.Unity.Debugger.UnityExpression.<>c__DisplayClass9_0.<EvaluateAsync>b__0()
    18.    at System.Threading.Tasks.Task`1.InnerInvoke()
    19.    at System.Threading.Tasks.Task.Execute()
    20. ---> (Inner Exception #0) Mono.Debugger.Soft.InvocationException: Exception of type 'Mono.Debugger.Soft.InvocationException' was thrown.
    21.    at Mono.Debugger.Soft.ObjectMirror.EndInvokeMethodInternalWithResult(IAsyncResult asyncResult)
    22.    at SyntaxTree.VisualStudio.Unity.Debugger.ValueExtensions.<>c__DisplayClass6_0.<InvokeAsync>b__1(ObjectMirror o)
    23.    at SyntaxTree.VisualStudio.Unity.Debugger.ValueExtensions.Dispatch[TRet](Value value, Func`2 onObject, Func`2 onStruct, Func`2 onPrimitive)
    24.    at SyntaxTree.VisualStudio.Unity.Debugger.ValueExtensions.<>c__DisplayClass6_0.<InvokeAsync>b__0()
    25.    at SyntaxTree.VisualStudio.Unity.Debugger.UnityThread.<>c__DisplayClass15_0`1.<Execute>b__0()
    26.    at System.Threading.Tasks.Task`1.InnerInvoke()
    27.    at System.Threading.Tasks.Task.Execute()<---
    If I run the exact snippet again after that error, it works fine!

    This specific phrase repros every time - I'll minimize it to a repro if this giant error above offers no hints, but I'd prefer not to - I've spent wayy too much time making TMPro repros :)
     
    Last edited: Mar 19, 2020
  2. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The above errors reference Visual Studio Tools for Unity (VSTU) and appear to be related to perhaps to inspecting / debugging strings / text that happens to contain unicode characters which VSTU is not expecting.

    Do you perhaps still have the old VSTU plugin in your project or maybe some package related to Visual Studio? Microsoft acquired VSTU a few years ago so seeing SynthaxTree in there is why I am thinking about the old plugin.

    P.S. I certainly understand the potential annoyance of running into stuff and having to take the time to repro / provide a bug report. I am very grateful for all the feedback and reports you have submitted thus far.

    Mark me down as owing you at least one beer if you ever run into me at some event / show :)
     
    Last edited: Mar 19, 2020
  3. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    Interesting - I'll look for an old version. I got nothing special aside from VSTU. Thanks for the tip!
     
  4. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    You are most welcome as usual.

    Let me know what you find out.

    P.S. I have run into many lock up in Visual Studio overtime. Copy / pasting emojis / UTF32 characters in strings used to make VS very unhappy.
     
  5. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    No lingering old VSTU; not even a lingering old version of Visual Studio:

    upload_2020-3-19_16-4-47.png

    upload_2020-3-19_16-4-58.png

    upload_2020-3-19_16-5-6.png

    I also tried the installer, just in case (where they show installed components). I'm going to see if I still get the error with VS closed completely.

    EDIT: With VS closed, I still get that error (I think it's the same):

    Code (CSharp):
    1. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
    2.  
    3.   at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x0001e] in <7d97106330684add86d080ecf65bfe69>:0
    4.  
    5.   at TMPro.TextMeshProUGUI.GenerateTextMesh () [0x00c35] in C:\Repos\ToL\tol-game-win\i42-tol-win64\Packages\com.unity.textmeshpro@2.1.0-preview.4\Scripts\Runtime\TMPro_UGUI_Private.cs:2074
    6.  
    7.   at TMPro.TextMeshProUGUI.OnPreRenderCanvas () [0x0016b] in C:\Repos\ToL\tol-game-win\i42-tol-win64\Packages\com.unity.textmeshpro@2.1.0-preview.4\Scripts\Runtime\TMPro_UGUI_Private.cs:1680
    8.  
    9.   at TMPro.TextMeshProUGUI.ForceMeshUpdate (System.Boolean ignoreActiveState, System.Boolean forceTextReparsing) [0x00021] in C:\Repos\ToL\tol-game-win\i42-tol-win64\Packages\com.unity.textmeshpro@2.1.0-preview.4\Scripts\Runtime\TextMeshProUGUI.cs:535
    10.  
    11.   at TMPro.TMP_InputField.UpdateLabel () [0x0025d] in C:\Repos\ToL\tol-game-win\i42-tol-win64\Packages\com.unity.textmeshpro@2.1.0-preview.4\Scripts\Runtime\TMP_InputField.cs:3166
    12.  
    13.   at TMPro.TMP_InputField.SetText (System.String value, System.Boolean sendCallback) [0x000f1] in C:\Repos\ToL\tol-game-win\i42-tol-win64\Packages\com.unity.textmeshpro@2.1.0-preview.4\Scripts\Runtime\TMP_InputField.cs:573
    14.  
    15.   at TMPro.TMP_InputField.set_text (System.String value) [0x00001] in C:\Repos\ToL\tol-game-win\i42-tol-win64\Packages\com.unity.textmeshpro@2.1.0-preview.4\Scripts\Runtime\TMP_InputField.cs:503
    16.  
    17.   at PlayerGUI.ILADSIO_v1 (System.Int16 encodedType, System.Byte[] name, System.Byte[] msg, System.Int16[] receivers, System.Boolean psychic, System.Int16 num, System.Int16 whisperTo) [0x01115] in C:\Repos\ToL\tol-game-win\i42-tol-win64\Assets\_Imperium42\_Scripts\UI\PlayerGUI.cs:4791
    18.  
    19.   at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
    20.  
    21.   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00032] in <7d97106330684add86d080ecf65bfe69>:0
    22.  
    23.    --- End of inner exception stack trace ---
    24.  
    25.   at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00048] in <7d97106330684add86d080ecf65bfe69>:0
    26.  
    27.   at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <7d97106330684add86d080ecf65bfe69>:0
    28.  
    29.   at NetworkingPeer.ExecuteRpc (ExitGames.Client.Photon.Hashtable rpcData, System.Int32 senderID) [0x004bb] in C:\Repos\ToL\tol-game-win\i42-tol-win64\Assets\Libs\Photon PUN Wrapper\Photon Unity Networking\Plugins\PhotonNetwork\NetworkingPeer.cs:3057
    30.  
    31.   at NetworkingPeer.RPC (PhotonView view, System.String methodName, PhotonTargets target, PhotonPlayer player, System.Boolean encrypt, System.Object[] parameters) [0x00249] in C:\Repos\ToL\tol-game-win\i42-tol-win64\Assets\Libs\Photon PUN Wrapper\Photon Unity Networking\Plugins\PhotonNetwork\NetworkingPeer.cs:3892
    32.  
    33.   at PhotonNetwork.RPC (PhotonView view, System.String methodName, PhotonTargets target, System.Boolean encrypt, System.Object[] parameters) [0x00057] in C:\Repos\ToL\tol-game-win\i42-tol-win64\Assets\Libs\Photon PUN Wrapper\Photon Unity Networking\Plugins\PhotonNetwork\PhotonNetwork.cs:2951
    34. (at ?)
    35.   at PhotonView.RPC (System.String methodName, PhotonTargets target, System.Object[] parameters) [0x00001] in C:\Repos\ToL\tol-game-win\i42-tol-win64\Assets\Libs\Photon PUN Wrapper\Photon Unity Networking\Plugins\PhotonNetwork\PhotonView.cs:597
    36.  
    37.   at StartGameCtrl.sendMsg (System.Int16 encodedNum, System.Int16 encodedType, System.Byte[] nameByteArr, System.Byte[] msg, System.Int32 pNum, System.Boolean isMysticMsg, System.Boolean isNight) [0x014dd] in C:\Repos\ToL\tol-game-win\i42-tol-win64\Assets\_Imperium42\_Scripts\MP\StartGameCtrl.cs:9932
    38. UnityEngine.Debug:LogError(Object) (at ?)
    39. StartGameCtrl:sendMsg(Int16, Int16, Byte[], Byte[], Int32, Boolean, Boolean) (at Assets/_Imperium42/_Scripts/MP/StartGameCtrl.cs:9942)
    40. StartGameCtrl:OIFDGJKS_v1(Int16, Int16, Byte[], Byte[], Int32, Boolean, Boolean) (at Assets/_Imperium42/_Scripts/MP/StartGameCtrl.cs:9967)
    41. System.Reflection.MethodBase:Invoke(Object, Object[])
    42. NetworkingPeer:ExecuteRpc(Hashtable, Int32) (at Assets/Libs/Photon PUN Wrapper/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3057)
    43. NetworkingPeer:RPC(PhotonView, String, PhotonTargets, PhotonPlayer, Boolean, Object[]) (at Assets/Libs/Photon PUN Wrapper/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3892)
    44. PhotonNetwork:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/Libs/Photon PUN Wrapper/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:2951)
    45. PhotonView:RPC(String, PhotonTargets, Object[]) (at Assets/Libs/Photon PUN Wrapper/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:597)
    46. PlayerGUI:checkLengthAndSend(Type, Int16, ObscuredString, ObscuredString) (at Assets/_Imperium42/_Scripts/UI/PlayerGUI.cs:2688)
    47. <_InitGameMC>d__59:MoveNext() (at Assets/_Imperium42/_Scripts/MP/TutorialGameCtrl.cs:1229)
    48. <CancelWith>d__0:MoveNext() (at Assets/Plugins/Timing.cs:2599)
    49. MEC.Timing:Update() (at Assets/Plugins/Timing.cs:324)
    50.  
    `KeyNotFoundException: The given key was not present in the dictionary.`
    What key is this looking for when setting a txt.text?
     
    Last edited: Mar 19, 2020
  6. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    If I double click on the error, here is the exact place this happens:
     

    Attached Files:

  7. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    There was something similar reported related to a missing key ... in that case it was the End of Text character 0x03 which can be injected when Truncate or Ellipsis mode are used. This should be address in preview 8.
     
  8. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    I believe I'm on prev4 - I'll give it a shot! However... I'm not on truncate/ellip mode. At least I shouldn't be - I'll double check.

    EDIT: Welp, it was on truncate mode - this may fix things.
     
    Last edited: Mar 19, 2020
  9. MrLucid72

    MrLucid72

    Joined:
    Jan 12, 2016
    Posts:
    988
    FIXED IT (via upgrade)! Yesss...... thanks for that.

    Is there a way to "subscribe" to new TMPro preview updates? Like get a notification upon release? These prev releases have been dramatically improving Unicode.
     
  10. Stephan_B

    Stephan_B

    Joined:
    Feb 26, 2017
    Posts:
    6,595
    The only way inside Unity is to open the Package Manager once in a while to see if there is a new version.

    Besides that, I usually update the top sticky which I usually do a few days after the release is out.
     
    MrLucid72 likes this.