Puzzling rare exception in WebGL: ArgumentOutOfRangeException
I have a fairly simple 2-D WebGL game that uses scripting to control game elements. The game has run well for the last year during development and testing - maybe a total of 600 runs.
On several very rare occasions, in our WebGL build, we get seemingly random ArgumentOutOfRangeExceptions. This has occurred 4 times that we know of out of the approximately 500 runs.
It has been impossible to identify the cause because it occurs so infrequently. We have not been able to reproduce this issue on development WebGL builds and the exception has never occurred in the Unity Editor.
We are currently running 2018.2.20f1 and we have experienced this issue as we updated across various 2017-2018 Unity versions.
Here is the exception that is displayed in the browser console:
UnityLoader.js:4 ArgumentOutOfRangeException: Argument is out of range. UnityLoader.js:4 Parameter name: index UnityLoader.js:4 at System.Collections.Generic.List`1[System.Int32].get_Item (Int32 index) [0x00000] in :0 UnityLoader.js:4
UnityLoader.js:4 (Filename: currently not available on il2cpp Line: -1) UnityLoader.js:4
Has anyone experienced this?
hmm interesting, Usually that error comes up when an int or float value is below or above the constant set values.
Below if i use this method with a slider it's values cannot extend the preset values 0-1 if so you get an exception error. i'd check All of your value changers, and see if in the inspector if their values don't match your script aka if i had my slider be able to go -0.01 $$anonymous$$ and 1.01 max then i'd get this error every time i have the slider at the lowest value and the highest value. if i had the slider set to 0.0001 $$anonymous$$ and 0.9999 max then i'd never get the error. if you have it go to 1 or 0 sometimes you get this weird bug where is will call the exception 1/100 times or so.
public static void Set$$anonymous$$asterVolume (float value)
{
if (value >= 0f && value <= 1f) {
SetFloat ($$anonymous$$asterSFXVolumeSave$$anonymous$$ey, value);
} else {
Debug.LogException (new System.Exception ("SFX volume slider out of range. Set slider between 0 and 1 and Not whole numbers."));
}
}
if you are using whole numbers: make sure the slider is set to whole number as well
are You able to replicate it on a build? on the web GL? if so figure out when exactly it happens. Is it the same instance each time aka are you tying to do the same thing each time the error comes up? and if so, what is it that is causing the error. further more in the editor you can use the attribute
[SelectionBase]
Above your class' to be able to select the actual GameObject with the script and not just it parent when clicking on an object in the scene view. sure is a confusing bug to say the least though. hope you can get 'r figured.
Thank you @zereda-games for your replies.
The exception is not related to a slider or control - it only occurs on the WebGL build so I cannot get a line number. There are actually 7 very similar games that use shared infrastructure. The error has occurred on different games and occurs right after the games load.
I setup some additional automated testing to try to simulate 100's of game loads on the WebGL build but I cannot reproduce it.
Your answer
Follow this Question
Related Questions
WebGL Build doesn't fully load on Github Pages 0 Answers
Base64 to texture decoding, js -> webgl 1 Answer
[WebGL 2.0] Texture2DArray support? 1 Answer