TMPro: Input runtime assignment rethrow errs with Unicode

I noticed some strange things happening when I assign input text:

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

newInput.text = decodedName + decodedMsg;
System.AggregateException: One or more errors occurred. ---> Mono.Debugger.Soft.InvocationException: Exception of type 'Mono.Debugger.Soft.InvocationException' was thrown.
   at Mono.Debugger.Soft.ObjectMirror.EndInvokeMethodInternalWithResult(IAsyncResult asyncResult)
   at SyntaxTree.VisualStudio.Unity.Debugger.ValueExtensions.<>c__DisplayClass6_0.<InvokeAsync>b__1(ObjectMirror o)
   at SyntaxTree.VisualStudio.Unity.Debugger.ValueExtensions.Dispatch[TRet](Value value, Func`2 onObject, Func`2 onStruct, Func`2 onPrimitive)
   at SyntaxTree.VisualStudio.Unity.Debugger.ValueExtensions.<>c__DisplayClass6_0.<InvokeAsync>b__0()
   at SyntaxTree.VisualStudio.Unity.Debugger.UnityThread.<>c__DisplayClass15_0`1.<Execute>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at SyntaxTree.VisualStudio.Unity.Debugger.Evaluation.ExpressionEvaluator.VisitAssignmentExpression(AssignmentExpressionSyntax node)
   at Microsoft.CodeAnalysis.CSharp.Syntax.AssignmentExpressionSyntax.Accept(CSharpSyntaxVisitor visitor)
   at SyntaxTree.VisualStudio.Unity.Debugger.Evaluation.ExpressionEvaluator.VisitExpressionStatement(ExpressionStatementSyntax node)
   at Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax.Accept(CSharpSyntaxVisitor visitor)
   at SyntaxTree.VisualStudio.Unity.Debugger.UnityExpression.<>c__DisplayClass9_0.<EvaluateAsync>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()
---> (Inner Exception #0) Mono.Debugger.Soft.InvocationException: Exception of type 'Mono.Debugger.Soft.InvocationException' was thrown.
   at Mono.Debugger.Soft.ObjectMirror.EndInvokeMethodInternalWithResult(IAsyncResult asyncResult)
   at SyntaxTree.VisualStudio.Unity.Debugger.ValueExtensions.<>c__DisplayClass6_0.<InvokeAsync>b__1(ObjectMirror o)
   at SyntaxTree.VisualStudio.Unity.Debugger.ValueExtensions.Dispatch[TRet](Value value, Func`2 onObject, Func`2 onStruct, Func`2 onPrimitive)
   at SyntaxTree.VisualStudio.Unity.Debugger.ValueExtensions.<>c__DisplayClass6_0.<InvokeAsync>b__0()
   at SyntaxTree.VisualStudio.Unity.Debugger.UnityThread.<>c__DisplayClass15_0`1.<Execute>b__0()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   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 :slight_smile:

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 :slight_smile:

Interesting - I’ll look for an old version. I got nothing special aside from VSTU. Thanks for the tip!

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.

No lingering old VSTU; not even a lingering old version of Visual Studio:

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

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

5605456--579949--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):

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.

  at System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) [0x0001e] in <7d97106330684add86d080ecf65bfe69>:0

  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

  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

  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

  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

  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

  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

  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

  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)

  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

   --- End of inner exception stack trace ---

  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

  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <7d97106330684add86d080ecf65bfe69>:0

  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

  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

  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
(at ?)
  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

  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
UnityEngine.Debug:LogError(Object) (at ?)
StartGameCtrl:sendMsg(Int16, Int16, Byte[], Byte[], Int32, Boolean, Boolean) (at Assets/_Imperium42/_Scripts/MP/StartGameCtrl.cs:9942)
StartGameCtrl:OIFDGJKS_v1(Int16, Int16, Byte[], Byte[], Int32, Boolean, Boolean) (at Assets/_Imperium42/_Scripts/MP/StartGameCtrl.cs:9967)
System.Reflection.MethodBase:Invoke(Object, Object[])
NetworkingPeer:ExecuteRpc(Hashtable, Int32) (at Assets/Libs/Photon PUN Wrapper/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3057)
NetworkingPeer:RPC(PhotonView, String, PhotonTargets, PhotonPlayer, Boolean, Object[]) (at Assets/Libs/Photon PUN Wrapper/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:3892)
PhotonNetwork:RPC(PhotonView, String, PhotonTargets, Boolean, Object[]) (at Assets/Libs/Photon PUN Wrapper/Photon Unity Networking/Plugins/PhotonNetwork/PhotonNetwork.cs:2951)
PhotonView:RPC(String, PhotonTargets, Object[]) (at Assets/Libs/Photon PUN Wrapper/Photon Unity Networking/Plugins/PhotonNetwork/PhotonView.cs:597)
PlayerGUI:checkLengthAndSend(Type, Int16, ObscuredString, ObscuredString) (at Assets/_Imperium42/_Scripts/UI/PlayerGUI.cs:2688)
<_InitGameMC>d__59:MoveNext() (at Assets/_Imperium42/_Scripts/MP/TutorialGameCtrl.cs:1229)
<CancelWith>d__0:MoveNext() (at Assets/Plugins/Timing.cs:2599)
MEC.Timing:Update() (at Assets/Plugins/Timing.cs:324)

KeyNotFoundException: The given key was not present in the dictionary.
What key is this looking for when setting a txt.text?

If I double click on the error, here is the exact place this happens:

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.

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.

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.

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.

1 Like