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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

eonianvr opened this issue · comments

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

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

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.

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}]}}


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.

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 just used your github project Response Debugger .
  • I made sure Response Debugger was configure properly and working on PC
  • then, switch the unity project to IOS and generated a built for XCODE.
  • Open the project in Xcode and generated a build for Iphone directly connected to the Mac to have access to debug info.
  • the build was successful
  • open the app on an Iphone
  • Whatever sentence you try to send to wit, it generate the same error mentioned above as soon at you hit the SEND button of Response Debugger. you dont see any json back on the screen.

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

Thank you

any news?

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));

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.

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

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.

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

thanks, Happy to help.