wit-ai / wit-unity

Wit-Unity is a Unity C# wrapper around the the Wit.ai rest APIs and is a core component of Voice SDK.
Other
78 stars 20 forks source link

error when publishing response debugger demo on ios (iphone) (using wit Version 0.0.7) #30

Closed eonianvr closed 2 years ago

eonianvr commented 2 years ago

I opening this issue using 0.0.7 as I didn't see anyone mentioning it before, so I'm guessing it is still here in the new version.

compiling the response debugger demo with xcode works but when hitting the SEND button ) after entering a sentence (from the Iphone after built is successful and sent to the phone), no answer from wit visible on the screen , and Xcode shows the following error in the console:


**ArgumentException: Specified value has invalid Control characters.**
Parameter name: value
  at System.Net.WebHeaderCollection.CheckBadChars (System.String name, System.Boolean isHeaderValue) [0x00000] in <00000000000000000000000000000000>:0 
  at System.Net.WebHeaderCollection.SetInternal (System.String name, System.String value) [0x00000] in <00000000000000000000000000000000>:0 
  at com.facebook.witai.WitRequest.StartRequest (System.Uri uri) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Events.UnityAction.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.Events.UnityEvent.Invoke () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1].Invoke (T1 handler, UnityEngine.EventSystems.BaseEventData eventData) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.EventSystems.ExecuteEvents.Execute[T] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.ExecuteEvents+EventFunction`1[T1] functor) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchPress (UnityEngine.EventSystems.PointerEventData pointerEvent, System.Boolean pressed, System.Boolean released) [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.EventSystems.StandaloneInputModule.ProcessTouchEvents () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.EventSystems.StandaloneInputModule.Process () [0x00000] in <00000000000000000000000000000000>:0 
UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchPress(PointerEventData, Boolean, Boolean)
UnityEngine.EventSystems.StandaloneInputModule:ProcessTouchEvents()
UnityEngine.EventSystems.StandaloneInputModule:Process()
eonianvr commented 2 years ago

not sure but seems like wit is sending back unwanted special characters

yolanother commented 2 years ago

In WitRequest there is an action called OnRawResponse. Can you add a log statement with the string provided in that callback and check for invalid characters? It would be great if you would attach it here as well.

eonianvr commented 2 years ago

I figure out you wanted the log on the stringResponse variable?

here it is from a PC. let me know if you want me to provide it from Xcode as well:


stringResponse{"text":"hi","intents":[{"id":"198060945675965","name":"greetings","confidence":0.9371}],"entities":{"subject:subject":[{"id":"265914631568286","name":"subject","role":"subject","start":0,"end":2,"body":"hi","confidence":0.7827,"entities":[],"suggested":true,"value":"hi","type":"value"}]},"traits":{"wit$sentiment":[{"id":"5251aff2-e6f3-4614-81a9-093fb33bdead","value":"positive","confidence":0.7336}],"wit$greetings":[{"id":"5900cc2d-41b7-45b2-b21f-b950d3ae3c5c","value":"true","confidence":0.9999}]}}
yolanother commented 2 years ago

Well, it looks like all of the characters in that string are valid. Did you still get the error even with the raw string? Yes, please try to grab the string from xcode as well. The onRawResponse string event happens before it tries to parse the json so we're looking for invalid characters in the json response.

eonianvr commented 2 years ago

Hey,

what variable host the raw string?

You should have no problem reproducing the bug on your side if you have xcode and an iphone.

As stated before

I previously copied above the error code XCODE gave back while trying to use Response Debugger on iphone.

Thank you

eonianvr commented 2 years ago

any news?

yolanother commented 2 years ago

Sorry about the delayed response, I'm not getting notifications on messages for some reason. I am not setup to develop for IPhone so I can't repro this. Maybe someone else from the team has some IPhone experience, I'll ask around. To get the logs we're after add this somewhere with a reference to your Wit component: wit.events.OnRequestCreated.AddListener((r) => r.onRawResponse += (str) => Debug.Log(str));

yolanother commented 2 years ago

You might also try updating Wit to v0.0.10+ there were some bugfixes in there, but I don't think anything specifically related to what you're doing.

eonianvr commented 2 years ago

Will install the new 0.0.10 version, do a build for iPhone and let you know if the problem is still here . Thanks

eonianvr commented 2 years ago

Hey Mate. I had a few hours to kill today so I looked at your code and was able to identify the line that create the error mentioned above. it happens in the file WitRequest.cs and is related to the UserAgent.

request.UserAgent = $"wit-unity-{WIT_SDK_VERSION},{operatingSystem},{deviceModel},{deviceName}";

which on my phone generate the string below: wit-unity-0.0.7,iOS 14.7.1,iPhone12,1,christophe schmitt’s iPhone

I didnt investigate more ( I suspect the ' is responsible) ,

I just replaced it by

request.UserAgent = "wit-unity";

and now the Iphone built is working as expected and the ArgumentException: Specified value has invalid Control characters is gone.

tested on 0.0.7 but should work on 0.0.10 since same problem was still here.

yolanother commented 2 years ago

Great find. I got a fix for this pushed and it will go live with v0.0.12 release.

eonianvr commented 2 years ago

thanks, Happy to help.