Soft keyboard seems to hang app

A user has informed me that Android’s soft keyboard and my app hang (probably means stop reacting) when my app opens the soft keyboard. What could be the issue with using the soft keyboard, has anybody ever had problems with it? He has Android 8.1 on a One+ 3. I have tested my app on the emulator with 8.0 and on a tablet with Android 4.2 - no problems.

He sent a screen shot: Keyboard shows up (it is opened in mousePressed() when the user taps a custom text field) and apparently at least one more draw() after mousePressed() is executed because my code starts to render a cursor.

It can’t be the keyboard per se because he has another app from me which uses the soft keyboard, too, and that one works. That one is locked into portrait mode, while the problematic app is landcape. The problematic app sets the “screen always on flag” (*). There are far more differences but those are two “on the Android side”.


*:

void onCreate(Bundle bundle) 
{
    // override onCreate(): disable sleep mode
  
    super.onCreate(bundle);
    
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}

It is not exactly clear what the problem is. I would guess both apps use a different version of Android mode. That would be good to document and that would be the first step to check in your journey to find your problem: make sure you are using the same Android mode. You mention the problem is in landscape mode only. Can you confirm you do not have this problem in portrait mode?

Related to the flag FLAG_KEEP_SCREEN_ON, I do not think that is a problem. However, if you think it is, remove it as it should not affect your application during this testing.

Kf

@dtmr===
It’s difficult to help without seeing the code and knowing how you create and use the editText; - As for the flag, i dont believe that it is the cause, except (battery drain) if the phone is running with low battery level; as for the orientation it does not matter if config changes are really blocked. So, the first thing to know is the kind of error message this user got: is it a crash or is it an ANR??? - Other one would be to know at what point this happens: was the phone rotated or not??? Does it happens at the very beginning?? - Does it happens each time???: well, a screenshot tells nothing about these questions!

the kind of error message this user got: is it a crash or is it an ANR???

No error message. The user told me that my app and the keyboard just stop taking input. At that moment, the app looks perfectly normal. The app is there, the keyboard is there:

how you create and use the editText

I don’t think that matters because the edit code runs on my Windows, my Linux, my Mac OS X, my Android tablet and the Android emultator. It’s very simple anyway: Listen to keystrokes (keyPressed()), append 0…9 and “.” to a string, which is displayed. Backspace is implemented, too. Nothing else. No GUI library, no text marking, no cursor movements. Just used to enter a number.

IMHO it must be something on the Android side. Is there a way to install the 8.1.1 emulator for use with Processing without installing the entire Android Studio?

@dtmr====
looks like an ANR , which happens (depending of the phone) often, because your app is doing too much on the main ui thread: i see that the input is an IP and i suppose that you try to connect to this IP: if that is done on the main ui thread ANR is possible, or if you try to modify the GUI while the user is typing its input or…Any case, in order to be sure a) try to ask to this user if after the freeze he has got some message (ANR are very typical but not send immediately, it takes 5 seconds to appear) and if yes try to create a runnable…
more details here: https://developer.android.com/training/articles/perf-anr

The user has provided more information:

  • He doesn’t really have Android. He has two Lineageos devices (equivalent to 8.1). My app hangs on all of them after opening the keyboard. Lots of memory, Full HD, AOSP standard keyboard.

  • No error messages

  • Removing FLAG_KEEP_SCREEN_ON makes no difference.

input is an IP and i suppose that you try to connect to this IP

The app connects to the IP but only after the IP has been entered. Networking or blocking can’t be the issue when the keyboard is opened.

  • He says there is no visual feedback from the keyboard if keys are tapped or if the device is rotated and it is not possible to switch to another layer (from a-z to numbers)

  • It seems to affect not only the app but the system in the following way: If the extended start menu is opened (“shutdown restart screenshot”), this menu is non-responsive:

  • If the user bypasses the keyboard (clicking ok and accepting IP from configuration file), the app starts normally, the network connection works and everyhing else works. It is a complex app. With one exception: There is a toolbar button in the app that opens the soft keyboard. That hangs, too.

@dtmr ====
looking at your last post and what says the user i think that there could be some specific problem with its OS: there is not any ANR message (but is it implemented by this 0S, i dont know) and yes it seems to be an OS crash…without crash! = in this case i cannot help; what i cannot understand is why the keyboard does not hang at the very beginning and works till (looking to the IP) last char…

cannot understand is why the keyboard does not hang at the very beginning and works till (looking to the IP) last char…

It hangs at the beginning - the displayed IP is a default, not user input.

@dtmr===

ah! - ok: that 's more logical! - Anyway i persist to think to something ANR like and in this case i would try to put the whole editext stuff inside a runnable…

In the meantime, the user has found out that the hanging keyboard is related to "the display size (dpi)" setting of his device:

The keyboard apparently works with the second-smallest setting.

At that point, everything on the smartphone is too small to be read without glasses. There is nothing special about the resolution of this device. Full HD.

@dtmr=== so the inquiry is going on…By curiosity i would know what is exactly this “smallest setting” value…

According to the user with that problem, around 400 dpi: 384 dpi works, 432 and 480 dpi not.

Update: Couldn’t solve this problem. Wrote my own soft keyboard.