Search Unity

Bug "TouchScreenKeyboard.hideInput" triggers numerous errors & breaks functions in current Android/Unity

Discussion in 'Editor & General Support' started by mikejm_, Jul 3, 2022.

  1. mikejm_

    mikejm_

    Joined:
    Oct 9, 2021
    Posts:
    346
    Being able to hide the TouchScreenKeyboard's input field is essential in Android for creating a seamless or basically good experience with text input/messaging/etc. This function to do this is given by "TouchScreenKeyboard.hideInput = true". Documentation suggests:

    This would be absolutely fine. There is nothing wrong with simply providing the illusion of the input field being gone. However, this not currently working in present Android and it is in fact triggering numerous errors which break the basic Keyboard functions.

    1) Errors on Opening the Keyboard
    The first problem is that when you open the keyboard (click a text field), it responds with 7 error messages:

    Code (csharp):
    1.  14211 14211 Error Company.TextBo No package ID 3f found for ID 0x3f050003.
    2.  14211 14211 Error Company.TextBo No package ID 3f found for ID 0x3f050001.
    3.  14211 14211 Error Company.TextBo No package ID 3f found for ID 0x3f050003.
    4.  14211 14211 Error Company.TextBo No package ID 3f found for ID 0x3f050002.
    5.  14211 14211 Error Company.TextBo No package ID 3f found for ID 0x3f050003.
    6.  14211 14301 Error Company.TextBo No package ID 3f found for ID 0x3f050001.
    7.  14211 14301 Error Company.TextBo No package ID 3f found for ID 0x3f050003.
    I am not sure if this one is significant in any way though as these same seven errors are also triggered when TouchScreenKeyboard.hideInput = false. But if it matters, it may be worth mentioning.

    2) Auto-Correct Underlines are Still Visible
    The second problem is that when you start typing, it will show the underline still from the auto-correct suggestions, thus indicating there is still SOMETHING there in the area that the input field would be (it is not completely being hidden).

    Here you can see a horizontal blue underline in a simple bug demo project with "hideInput = true" I made to illustrate which would presumably be under the word "wha" as part of the autocorrect suggestions:

    Screenshot_20220702-231332_TextBox.jpg


    3) Clicking in the Area of Hidden Keyboard Input Field Crashes the Keyboard
    The third and most destructive problem is that if you have the keyboard open with "hideInput = true" and click anywhere within the area that the input field would usually be it closes the keyboard with a cascade of errors/warnings:

    Code (csharp):
    1.  14211 14211 Error ViewRootImpl Calling showInsets(8,true) on window that no longer has views.
    2.  14211 14211 Warn IInputConnectionWrapper getTextBeforeCursor on inactive InputConnection
    3.  14211 14211 Warn IInputConnectionWrapper getTextAfterCursor on inactive InputConnection
    4.  14211 14211 Warn IInputConnectionWrapper getTextBeforeCursor on inactive InputConnection
    5.  14211 14211 Warn IInputConnectionWrapper getTextAfterCursor on inactive InputConnection
    6.  14211 14211 Warn IInputConnectionWrapper requestCursorAnchorInfo on inactive InputConnection
    7.  14211 14211 Error ViewRootImpl sendUserActionEvent() mView returned.
    For example, in this screencap with keyboard input hidden, clicking anywhere in the red box approximately corresponding to the hidden input field will trigger this crash:

    Screenshot_20220702-231332_TextBox red line2.jpg


    Here is the same demo app with the input field NOT hidden - this shows the approximate range of the input field which corresponds to the area that clicking on crashes everything when the input field is hidden:

    Screenshot_20220702-232901_TextBox.jpg

    Presumably this is occurring for the same reason as issue #2 - the keyboard's input field is still there in some sense and capturing clicks in this region. This is then triggering abnormal behavior which is breaking the normal expected functions.

    Help Needed
    I am wondering if this can be fixed for current Android versions. Alternatively, perhaps you can please provide the code that was used to hide the input field, and we can update it ourselves and write our own code from it that will still work.

    I have been able to write Android code in Unity that tracks keyboard height and hides/shows status bars and nav bars, but I am not sure where to start for the input field. ie. What commands control this or what to manipulate.

    If you are unable to fix this or don't have resources to do so in a timely manner, can you please share the code behind TouchScreenKeyboard.hideInput or explain what commands it was using so those of us who need it to work can at least know where to start?

    This is absolutely necessary for my app so I appreciate any help you can provide. I submitted a bug report for it (IN-9117) with the screencapped simple demo project that shows these errors/bugs.

    Thanks.
     
    Last edited: Jul 3, 2022
  2. FreddyC-Unity

    FreddyC-Unity

    Unity Technologies

    Joined:
    Jun 9, 2021
    Posts:
    36
    Since you have posted the same question in the UI Toolkit section (post), I will answer and follow up in there :)