- Home /
Question by
Sakuwwz · Jan 20, 2020 at 05:19 AM ·
webglexceptionmemory usage
Retrieving Data from websocket for Unity WebGL game leads to an exception : “Uncaught RuntimeError: memory access out of bounds at wasm-function”
I've been trying to retrieve data from websocket to my unity webgl game. It's working fine and validating successfully to authorize the user. But As soon as calling the function to retrieve the data and populate the lists, arrays and Dictionaries that I defined, Its throwing and error like below in the build and deploy in the instance.
This is how I do the stuff.
IEnumerator RetrieveWordsAndDefs(string accessTokenGetData)
{
string getDataFromURLLocal = "https://api.samplecloud.com/gamequestion?site=" + site + "&game=" + gameId + "&access_token=" + accessToken + "&token_type=Bearer";
using (UnityWebRequest uwr = UnityWebRequest.Get(getDataFromURLLocal))
{
uwr.SetRequestHeader("Content-Type", CONTENT_TYPE);
uwr.SetRequestHeader("x-api-key", X_API_KEY);
bool onetimeGet;
yield return uwr.SendWebRequest();
if (uwr.isNetworkError)
{
Debug.Log("Error While Sending: " + uwr.error + " respose Code : " + uwr.responseCode + " isNetworkError : " + uwr.isNetworkError);
//messageText5.text = "Error While Sending: " + uwr.error + " respose Code : " + uwr.responseCode + " isNetworkError : " + uwr.isNetworkError;
}
else
{
Debug.Log("Received: Data" + uwr.downloadHandler.text + " respose Code : " + uwr.responseCode + " isNetworkError : " + uwr.isNetworkError);
string jsonWordAndDefs = uwr.downloadHandler.text;
DeserializeJsonData(jsonWordAndDefs);
}
}
}
private void DeserializeJsonData(string jsonWordAndDefs)
{
words = null;
def = null;
singleText = null;
if (!String.IsNullOrEmpty(jsonWordAndDefs))
{
RootObjectData rootObjectData = JsonUtility.FromJson<RootObjectData>(jsonWordAndDefs);
int count = rootObjectData.tasks[0].words.Count;
def = rootObjectData.tasks[0].words.Zip(rootObjectData.tasks[0].definitions, (k, v) => new { k, v }).ToDictionary(x => x.k, x => x.v);
words = rootObjectData.tasks[0].words.ToArray();
singleText = rootObjectData.tasks[0].definitions.ToArray();
words = words.Where(x => !string.IsNullOrEmpty(x)).ToArray();
words = words.Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
foreach (KeyValuePair<string, string> kvp in def)
{
//messageText1.text += string.Format("{0} : {1} \n", kvp.Key, kvp.Value);
}
}
}
But when I deploy it in my websocket and and Run, I'm getting this errors to be appear in console of web browser
exception thrown: RuntimeError: index out of bounds,@blob:https://sample
Uncaught RuntimeError: memory access out of bounds
at wasm-function[19588]:0x81e4f1
at wasm-function[42109]:0xcaa7fc
at Object.dynCall_iii...
does anyone know how to solve this issue? any suggestion would be really helpful. Thanks
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612221824im_/https://answers.unity.com/themes/thub/images/avi.jpg)