SDL icon indicating copy to clipboard operation
SDL copied to clipboard

Displaying the Android soft keyboard causes serious rendering issues when combined with controller input

Open leonstyhre opened this issue 1 year ago • 5 comments

Hi!

I have come across a very strange issue when using the Android soft keyboard (on-screen keyboard). The keyboard itself works perfectly fine, and it displays and disappears as it should. My application (ES-DE) supports both touch input using an overlay as well as controller and keyboard input. If the touch overlay is used everything works perfectly and there are no issues, but if using a physical keyboard or a controller there is a green border displayed along three sides of the screen after closing the soft keyboard, and the bottom of the screen has a number of pixels that don't get rendered at all.

Please see the attached screenshots which demonstrate the problem. Navigating back to the text input field makes the keyboard appear again, and the green borders are removed. But as soon as the keyboard is closed again the borders come back and they will remain indefinitely, requiring an application restart to fix.

I have spent a lot of time trying to figure out this issue and what I've concluded is that it has nothing to do with the keyboard itself, as commenting out the code that spawns it still makes the green border appear. What is causing the problem is when calling mSurface.requestFocus() in SDLCommandHandler(). So commenting out this line will temporarily fix the issue. However input focus is then not moved back to the main window so the application doesn't work correctly. As well switching to the home screen and back to the app introduces the green border as requestFocus() is called via onResume().

Adding mLayout.removeView(mTextEdit); to the end of the ShowTextInputTask::run() method will make the keyboard get displayed briefly, then immediately disappear and the green border is not shown. So something with the DummyEdit View is causing the problem but it's really bizarre as it only happens if you navigate using a controller or physical keyboard and not if using the touch input overlay. It's almost as if any controller input consumed by mTextEdit is introducing the problem. I guess something with the dummy/invisible DummyEdit View is somehow confusing the SDLSurface but this way beyond my knowledge of SDL to figure out.

I'm having real difficulties describing this problem as it's so strange, I hope the above makes sense. Unfortunately it's quite serious as it makes the Android soft keyboard unusable with my application as most users will probably use some kind of controller rather than the touch overlay.

Let me know if you want me to test something further to try to pinpoint the cause of the issue.

Thanks in advance!

ES-DE_Android_issue_01 ES-DE_Android_issue_02

leonstyhre avatar Feb 08 '24 17:02 leonstyhre

@slouken Would it be possible to look into resolving this? It may seem like a small issue but it's making the Android soft keyboard unusable unfortunately. I'm very happy to test things to try to resolve the problem, what I have been doing so far is turning my application inside out trying to fix it but it really seems to be an issue in SDL and I don't have enough experience with your library to pinpoint and resolve the problem there. Thanks! :)

leonstyhre avatar Feb 11 '24 15:02 leonstyhre