Search Unity

InputField ArgumentOutOfRangeException

Discussion in 'UGUI & TextMesh Pro' started by giano574, Feb 4, 2015.

  1. giano574

    giano574

    Joined:
    Nov 28, 2013
    Posts:
    76
    Sometimes, when typing in an InputField I get an ArgumentOutOfRangeException error. It only happens when starting with an uppercase letter.
    I cannot reproduce it in an empty project, so I assume I am doing something that makes this happen. I have no idea what though, because when it happens the only thing I have done is storing a reference through the inspector.

    I hope someone can tell me what is going on.

    The error is:
    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[UnityEngine.UICharInfo].get_Item (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    UnityEngine.UI.InputField.SetDrawRangeToContainCaretPosition (UnityEngine.TextGenerator gen, Int32 caretPos, System.Int32& drawStart, System.Int32& drawEnd) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:1482)
    UnityEngine.UI.InputField.UpdateLabel () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:1371)
    UnityEngine.UI.InputField.OnUpdateSelected (UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:984)
    UnityEngine.EventSystems.ExecuteEvents.Execute (IUpdateSelectedHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:101)
    UnityEngine.EventSystems.ExecuteEvents.Execute[IUpdateSelectedHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:269)
    UnityEngine.EventSystems.EventSystem:Update()
     
  2. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    We've seen this and i think we've fixed it for 4.6.2p1. It was trying to get a invalid length of some string.
     
  3. giano574

    giano574

    Joined:
    Nov 28, 2013
    Posts:
    76
    I am using 4.6.2p1 right now. Do you think it will be in the next patch?
     
  4. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    how are you using 4.6.2p1 right now? Its not release/ even been built (i've talked with the build guy). its also not on the patch release page. http://unity3d.com/unity/qa/patch-releases

    you sure you're not using f1?
     
  5. synchrok

    synchrok

    Joined:
    Feb 5, 2015
    Posts:
    6
    I have same problem with typing korean. (version: 4.6.0f3)

    Situation:

    1. InputField's ContentType = Password
    2. type any text and do not focus to InputField
    3. touch InputField (to make all texts selected)
    4. type korean
    5. ArgumentOutOfRangeException: Cannot be negative. (Parameter name: length)

    will this problem be fixed in next version(4.6.2p1)?
     
  6. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Your exact problem i dont know i would need to test but i'm thinking yes.
     
  7. giano574

    giano574

    Joined:
    Nov 28, 2013
    Posts:
    76
    Oh right. It is 4.6.2f1. Woops.
     
  8. giano574

    giano574

    Joined:
    Nov 28, 2013
    Posts:
    76
    I have just updated to 4.6.2p1 (this time I am sure) and the exact same error happens. I click the InputField to give it focus and type in a capitalized letter, and the exception is thrown. Now, when clicking the InputField the exception is thrown again. I then leave play mode, and when I enter and try again the error is gone. So far it has happened twice.
     
  9. giano574

    giano574

    Joined:
    Nov 28, 2013
    Posts:
    76
    Interestingly, it only happened the two first times. It has not happened again since (I've tested around 100 times).
     
  10. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Hmm anything happen in between? Saving the scene, restarting unity anything?
     
    Bobnis likes this.
  11. giano574

    giano574

    Joined:
    Nov 28, 2013
    Posts:
    76
    No, nothing. It just stopped happening.
     
  12. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    So its fixed :)
     
  13. giano574

    giano574

    Joined:
    Nov 28, 2013
    Posts:
    76
    It seems so.
    However, I have just discovered another problem. Sometimes when typing in an InputField on android the text ends up dublicated in all of the other active InputFields.
     
  14. synchrok

    synchrok

    Joined:
    Feb 5, 2015
    Posts:
    6
    My problem is not fixed in 4.6.2p1(exact checked).
    Please check this error.

    ArgumentOutOfRangeException: Cannot be negative.
    Parameter name: length
    System.String.Substring (Int32 startIndex, Int32 length) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System/String.cs:348)
    UnityEngine.UI.InputField.Delete () (at C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/InputField.cs:1179)
    UnityEngine.UI.InputField.Insert (Char c) (at C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/InputField.cs:1230)
    UnityEngine.UI.InputField.Append (Char input) (at C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/InputField.cs:1293)
    UnityEngine.UI.InputField.KeyPressed (UnityEngine.Event evt) (at C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/InputField.cs:888)
    UnityEngine.UI.InputField.OnUpdateSelected (UnityEngine.EventSystems.BaseEventData eventData) (at C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/UI/Core/InputField.cs:941)
    UnityEngine.EventSystems.ExecuteEvents.Execute (IUpdateSelectedHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/EventSystem/ExecuteEvents.cs:101)
    UnityEngine.EventSystems.ExecuteEvents.Execute[IUpdateSelectedHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/BuildAgent/work/d63dfc6385190b60/Extensions/guisystem/guisystem/EventSystem/ExecuteEvents.cs:269)
    UnityEngine.EventSystems.EventSystem:Update()

     
  15. giano574

    giano574

    Joined:
    Nov 28, 2013
    Posts:
    76
    I just had the error again. Definately not fixed. It is however in a different part of the code it seems. The line numbers are different this time.

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[UnityEngine.UICharInfo].get_Item (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    UnityEngine.UI.InputField.SetDrawRangeToContainCaretPosition (UnityEngine.TextGenerator gen, Int32 caretPos, System.Int32& drawStart, System.Int32& drawEnd) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:1482)
    UnityEngine.UI.InputField.UpdateLabel () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:1371)
    UnityEngine.UI.InputField.OnUpdateSelected (UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:984)
    UnityEngine.EventSystems.ExecuteEvents.Execute (IUpdateSelectedHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:101)
    UnityEngine.EventSystems.ExecuteEvents.Execute[IUpdateSelectedHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:269)
    UnityEngine.EventSystems.EventSystem:Update()
     
  16. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Ok bug reports would be helpful
     
  17. giano574

    giano574

    Joined:
    Nov 28, 2013
    Posts:
    76
    It is extremely difficult to trigger this to happen, since I have absolutely no idea what is causing it. I am trying to make a new project that demonstrates it, but I've had no luck yet.
     
  18. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    Its happening to me in 4.6.2p2. I have no idea how to isolate it.

    EDIT - might be helpful to someone: switching my line type to Single Line makes it go away

    EDIT2 - If I change the child text component's vertical overflow to overflow, I'm able to use multi line. The deadly combination seems to be Multi Line on the input field and Truncate on the vertical overflow of the text component.
     
    Last edited: Feb 15, 2015
  19. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    I've also found that it has something to do with the height of the parent rectTransform being to small to accommodate the text. I filed a bug.

    The deadly combination is:
    -Small rectTransform height
    -InputField set to multi-line
    -child text component overflow set to truncate
     
  20. taneichi

    taneichi

    Joined:
    Feb 13, 2015
    Posts:
    4
    Coincidentally found this bug as well. It's occurs when set Text inside Vertically Overflow.
    Sometimes the error shown up but even if error not show, the text inside doesn't overflow and lost. Like Inputfield do override any settings done in it's children.
     
  21. giano574

    giano574

    Joined:
    Nov 28, 2013
    Posts:
    76
    I have just discovered that when the dublication on Android happens, the text value is actually not altered in the other InputFields. It just shows the text of the active InputField.
     
  22. rakeshmalik91

    rakeshmalik91

    Joined:
    Aug 16, 2014
    Posts:
    9
    i am having the issue in 4.6.3f1 too.... it happens only twice after each run of unity.
     
  23. DDG29

    DDG29

    Joined:
    Mar 23, 2015
    Posts:
    1
    I am also having this problem, although Unity also crashes. The problem is directly related to entering data into the input field. Sometimes it works, sometimes I get the ArgumentOutOfRangeException, and sometimes the Unity process's CPU usage jumps to 100% and eventually Unity becomes non-responsive. When Unity freezes, I get no feedback to console and none of my debug print statements are triggered.
     
  24. michael_bulls

    michael_bulls

    Joined:
    Mar 11, 2015
    Posts:
    2
    I don't think the problem has been fixed now.Because it also happens in 5.0.1f1 when i'm typing chinese.
     
  25. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    yes, happens to me now in 5.0.1f1, my string could just be a single number generated by a JSON converter... This seems to happen if you attempt to set the text of the input field on the same frame that the input field is created, thats as far as I've analyzed it anyway. I actually see this error 4 times in the console thrown by the text component of the input field
     
    Last edited: Apr 25, 2015
  26. nporaMep

    nporaMep

    Joined:
    Oct 31, 2014
    Posts:
    33
    I got more details on why does this happen:
    1) You have prefab with small rectTransform width/height (imagine it is defined by layout group in your design)
    2) You have InputField on it with Multiline turned on
    3) You Instantiate + set Text in same frame then you get exception in SetDrawRangeToContainCaretPosition in height -= lines[endLine].height; because code below uses small rect.Size and TextGenerator returns gen.lines with Length == 0:

    Code (CSharp):
    1. Vector2 extents = m_TextComponent.rectTransform.rect.size;
    2. var settings = m_TextComponent.GetGenerationSettings(extents);
    3. settings.generateOutOfBounds = true;
    4. cachedInputTextGenerator.Populate(processed, settings);
    Also if you have it on 2nd frame it crashes sometimes via something like OnRectTransformDimensionChanged which then is calling callback from Graphic: line 100 to which InputField is registed in OnEnable via:
    m_TextComponent.RegisterDirtyVerticesCallback(MarkGeometryAsDirty);
    m_TextComponent.RegisterDirtyVerticesCallback(UpdateLabel);

    I worked around of this by settings Width/Height to 1000 in prefab which then resized by Layout group as needed. But problem now is if I do any changed to prefab on scene inside Layout group and click Apply then Width/Height of everything is reset to 0/0 again and I need to set to 1000 again.
     
    Last edited: Jun 3, 2015
  27. jmcclure

    jmcclure

    Joined:
    May 5, 2009
    Posts:
    48
    Thanks for that information, it saved me a lot of trouble! Did you submit that information as a bug report? I'll bet that information could be crucial in getting it identified and fixed.
     
  28. StephanieRowlinson

    StephanieRowlinson

    Joined:
    Jul 23, 2014
    Posts:
    137
    I'm still getting this bug in Unity 5.2.03f. Does anyone know if a bug report has been submitted for it yet? If not I'll create a sample project and submit one.
     
  29. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    want to try 5.2.2f1 before submitting a bug?
     
  30. StephanieRowlinson

    StephanieRowlinson

    Joined:
    Jul 23, 2014
    Posts:
    137
    Sure, I'll try it in 5.2.2f1 before submitting a bug report. We had some trouble with textures in our GUI getting warped when we tried upgrading to 5.2.1f1 so we hadn't upgraded yet. I'll see if that problem has disappeared in 5.2.2f1 too. :)
     
  31. StephanieRowlinson

    StephanieRowlinson

    Joined:
    Jul 23, 2014
    Posts:
    137
    Hi, just tested it in 5.2.2f1 and it works now, provided I set the size directly before setting the text. It looks like our framework which sets it based on the gridcell it's in comes in too late, but that's our problem.

    The GUI is also no longer messed up like it was in 5.2.1f1 so we're all upgraded to 5.2.2f1 now. :)
     
  32. holyjewsus

    holyjewsus

    Joined:
    Mar 7, 2011
    Posts:
    624
    I get an error that the I cannot set the graphic while updating and that this is not supported... :( I did not used to get this error, away from my dev machine atm but will post the message and more info later
     
  33. Manumoi

    Manumoi

    Joined:
    Oct 31, 2014
    Posts:
    10
    Hello

    Just got the same bug. I m doing nothing fancy. I just have a form-like UI, and I upload text from a cloud database, so i can edit it directly from the app.
    When the setting is on "single line", the program works smoothly, but some of my inputfields need to be on multiline. And with this setting the ArgumentOutOfRangeException is then triggered.

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[UnityEngine.UILineInfo].get_Item (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    UnityEngine.UI.InputField.SetDrawRangeToContainCaretPosition (Int32 caretPos) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:1544)
    UnityEngine.UI.InputField.UpdateLabel () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:1468)
    UnityEngine.UI.InputField.SendOnValueChangedAndUpdateLabel () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:1350)
    UnityEngine.UI.InputField.set_text (System.String value) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:290)
    ContentInfoPanelScript.initialize () (at Assets/_scripts/CanvasScripts/ContentManagementCanvas/ContentInfoPanelScript.cs:64)
    ContentManagementCanvasScript.setContentInfoMode () (at Assets/_scripts/CanvasScripts/ContentManagementCanvasScript.cs:40)
    ContentItemScript.processItemClick () (at Assets/_scripts/listItems/ContentItemScript.cs:44)
    UnityEngine.Events.InvokableCall.Invoke (System.Object[] args) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:149)
    UnityEngine.Events.InvokableCallList.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:626)
    UnityEngine.Events.UnityEventBase.Invoke (System.Object[] parameters) (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:766)
    UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:54)
    UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:35)
    UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:44)

    I m using the "text" property of the inputfield to update it, like in
    Code (CSharp):
    1.  this.descriptionInput.text = this.gms.DataManager.ActiveContent.Description;
    where the right part of the code returns a string.

    I followed this thread, uploaded the 5.2.2f1 ... Still occurring.

    Any idea or fix?
     
  34. Manumoi

    Manumoi

    Joined:
    Oct 31, 2014
    Posts:
    10
    ok was able to figure out a ~dirty fix... but unable to reproduce the bug...
    • When doing simple test projects, everything works fine.
    • The fix on my complete project is to put my form initialization within a coroutine, and after a
    Code (CSharp):
    1. yield return new WaitForEndOfFrame();
    So with this approach, my complete project initializes the inputField normally, and no exception is triggered. I actually made a second test, this time with just
    Code (CSharp):
    1. yield return null;
    just to force one yield before actually loading data.... and it works too.

    The rationale for this (successful) fix attempt was that maybe the inputField dimensions, etc. were not taken into account at the time of the initialization, since the object was "setActive(true)" just moment before the data initialization call. Made a project test for that... but it actually works smoothly as well, at least on a simple project. So I don't really know where my bug comes from.
     
  35. prestonmatterport

    prestonmatterport

    Joined:
    May 7, 2015
    Posts:
    28
    Getting the same stacktrace on Unity 5.2.0f3. Same symptoms, and possibly the same issue as the OP's.

    Can reproduce by entering special characters (in this case, emoji) into the text field while running the player.

    UPDATE: Apparently, Unicode surrogate-pair characters are not supported by Unity. (I assume this means Unicode code points U+D800 to U+DFFF)

    Bug report: https://fogbugz.unity3d.com/default.asp?745520_lu4pldpv9gtpvk13
     
    Last edited: Nov 19, 2015
  36. Mloren

    Mloren

    Joined:
    Aug 20, 2011
    Posts:
    83
    Getting this error in 5.3.1f1 by setting the Input Field to use Multi Line Newline and then entering enough text and newlines to go below the bottom of the text box, forcing it to scroll. Once the text box has more text in it than it can fit, using the arrow keys to scroll the text up and down causes the error every time you scroll off the bottom.
     
  37. BlaceX

    BlaceX

    Joined:
    Oct 28, 2015
    Posts:
    7
    Are getting the same error on many client devices. We havent been able to reproduce it ourselves but our error reporter on client devices (iOS and Android) often give us the following stacktrace:

    ArgumentOutOfRangeException: Argument is out of range. Parameter name: index
    ----------------
    System.Collections.Generic.List`1[UnityEngine.UICharInfo].get_Item (Int32 index)
    UnityEngine.UI.InputField.SetDrawRangeToContainCaretPosition (Int32 caretPos)
    UnityEngine.UI.InputField.UpdateLabel ()
    UnityEngine.UI.InputField.SendOnValueChangedAndUpdateLabel ()
    UnityEngine.UI.InputField.LateUpdate ()

    Observed in Unity 5.3.3 and 5.3.4
     
  38. flashmandv

    flashmandv

    Joined:
    Mar 26, 2015
    Posts:
    156
    The error still is present in the latest Unity 5.4.0 f3
     
  39. VetalPav

    VetalPav

    Joined:
    Nov 9, 2015
    Posts:
    1
    Unity 5.3.6f1
    ArgumentOutOfRangeException: Argument is out of range. Parameter name: index
    System.Collections.Generic.List`1[UnityEngine.UICharInfo].get_Item (Int32 index)
    UnityEngine.UI.InputField.LineUpCharacterPosition (Int32 originalPos, Boolean goToFirstChar)
    UnityEngine.UI.InputField.MoveUp (Boolean shift, Boolean goToFirstChar)
    UnityEngine.UI.InputField+<MouseDragOutsideRect>c__Iterator4.MoveNext ()
    UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress)
    UnityEngine.EventSystems.EventSystem:Update()
     
  40. junghee

    junghee

    Joined:
    Mar 15, 2015
    Posts:
    1
    Unity 5.6.0b3

    ArgumentOutOfRangeException: Cannot be negative.
    Parameter name: length
    System.String.Substring (Int32 startIndex, Int32 length) (at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System/String.cs:348)
    UnityEngine.UI.InputField.Delete () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:1420)
    UnityEngine.UI.InputField.Insert (Char c) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:1473)
    UnityEngine.UI.InputField.Append (Char input) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:1550)
    UnityEngine.UI.InputField.KeyPressed (UnityEngine.Event evt) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:1129)
    UnityEngine.UI.InputField.OnUpdateSelected (UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/InputField.cs:1175)
    UnityEngine.EventSystems.ExecuteEvents.Execute (IUpdateSelectedHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:99)
    UnityEngine.EventSystems.ExecuteEvents.Execute[IUpdateSelectedHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:261)
    UnityEngine.EventSystems.EventSystem:Update()


    I have exact same problem.
    When I try to type Korean into a inputfield, I got this error message.
     
  41. flashmandv

    flashmandv

    Joined:
    Mar 26, 2015
    Posts:
    156
    Please @phil-Unity fix this already. It is still not fixed
    My email is spammed daily with exceptions from this. I use latest Unity 5.6.0.
    My game has half million active players and this Exception keeps throwing.

    ArgumentOutOfRangeException: Argument is out of range. Parameter name: index
    [STACK]
    +System.Collections.Generic.List`1[UnityEngine.UICharInfo].get_Item (Int32 index) UnityEngine.UI.InputField.SetDrawRangeToContainCaretPosition (Int32 caretPos) UnityEngine.UI.InputField.UpdateLabel () UnityEngine.UI.InputField.SendOnValueChangedAndUpdateLabel () UnityEngine.UI.InputField.LateUpdate ()

    A have a 3D game board on which I have text fields in canvas. When people start using some input - it throws this exception. I can't reproduce, it is not so often, but when you have 0.5M active players with all kinds of devices - it happens a lot.
     
  42. Maplewing

    Maplewing

    Joined:
    Jun 12, 2013
    Posts:
    2
    This error can be reproduced by just inputing two emojis together in the textfield.
    We use Unity 5.6.1f1.
     
    sylwesterFGG likes this.
  43. Coredumping

    Coredumping

    Joined:
    Dec 17, 2014
    Posts:
    51
    Switch keyboard layout to Korean, press letters randomly in an inputfield and you will eventually get a:
    Code (CSharp):
    1. ArgumentOutOfRangeException: Cannot be negative.
    2. Parameter name: length
    3. System.String.Substring (Int32 startIndex, Int32 length)
    4. UnityEngine.UI.InputField.Delete ()
    5. UnityEngine.UI.InputField.Insert (Char c)
    6. UnityEngine.UI.InputField.Append (Char input)
    7. UnityEngine.UI.InputField.KeyPressed (UnityEngine.Event evt)
    8. UnityEngine.UI.InputField.OnUpdateSelected (UnityEngine.EventSystems.BaseEventData eventData)
    9. UnityEngine.EventSystems.ExecuteEvents.Execute (IUpdateSelectedHandler handler, UnityEngine.EventSystems.BaseEventData eventData)
    10. UnityEngine.EventSystems.ExecuteEvents.Execute[IUpdateSelectedHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor)
    11. UnityEngine.EventSystems.EventSystem:Update()
    Could you just clamp the values for String.Substring? Having your application break for such a small error kind of sucks.

    *Using Unity 5.5 by the way.
     
  44. hippogames

    hippogames

    Joined:
    Feb 5, 2015
    Posts:
    233
    The same exception in Unity 2019.4.4 reported my by users. I can't reproduce it by myself.

     
  45. michaeleconomy

    michaeleconomy

    Joined:
    Aug 28, 2018
    Posts:
    58
    Ditto but on 2019.4.10f1, did you submit a bug report?
     
  46. SyedUmair

    SyedUmair

    Joined:
    Sep 2, 2013
    Posts:
    43
    Similar exception occurred using Unity 2019.4.12f1. Reported by Unity Cloud Diagnostics.

    Situation:
    1. InputField's ContentType = Name
    2. Hide Mobile Input = true

    Affected OS:
    Screenshot 2020-10-21 at 4.20.34 PM.png

    Affected Devices:
    Screenshot 2020-10-21 at 4.20.42 PM.png

    Metadata:
    Screenshot 2020-10-21 at 4.23.39 PM.png

    @phil-Unity let me know, if further info is required.
    regards,
     
  47. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Anyone filed a bug report for the 19.4 version? i *think* this should have been resolved we've done a few fixes. Might be that it never got backported.
     
  48. SyedUmair

    SyedUmair

    Joined:
    Sep 2, 2013
    Posts:
    43
    Thanks for reply, can you confirm me which Unity version has the fix. So, I may try to upgrade my project to that version.
     
  49. phil-Unity

    phil-Unity

    Unity UI Lead Developer

    Joined:
    Nov 23, 2012
    Posts:
    1,226
    Cant find the exact versions they landed in i would try the latest 2020.1 cycle.
     
  50. roointan

    roointan

    Joined:
    Jan 8, 2018
    Posts:
    78
    I'm still getting having similar exceptions reported, in a game built with Unity 2020.3.0f1

    I'm not sure if it's the same problem, but this is the stack trace:

    System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ThrowHelper)
    System.ThrowHelper.ThrowArgumentOutOfRangeException (System.ThrowHelper)
    System.Collections.Generic.List`1[T].get_Item (System.Collections.Generic.List`1[T])
    UnityEngine.UI.InputField.SetDrawRangeToContainCaretPosition (UnityEngine.UI.InputField)
    UnityEngine.UI.InputField.UpdateLabel (UnityEngine.UI.InputField)
    UnityEngine.UI.InputField.LateUpdate (UnityEngine.UI.InputField)
     
    OxDEADFACE likes this.