Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

window_sdl2.py: TextInput crashes on numeric input in Android #5043

Open
ScissorHill opened this issue Mar 8, 2017 · 6 comments
Open

window_sdl2.py: TextInput crashes on numeric input in Android #5043

ScissorHill opened this issue Mar 8, 2017 · 6 comments

Comments

@ScissorHill
Copy link

Versions

  • Python: 2.7.6
  • OS: Ubuntu 14.04
  • Kivy: 1.9.2
  • Kivy installation method: kivy-daily PPA

Description

Trying to use TextInput on Android. Works perfectly on Desktop, but app crashes when attempting to input anything on Android.

Code and Logs

Example taken from the Kivy Basic documentation:

from kivy.app import App
from kivy.uix.gridlayout import GridLayout
from kivy.uix.label import Label
from kivy.uix.textinput import TextInput


class LoginScreen(GridLayout):

    def __init__(self, **kwargs):
        super(LoginScreen, self).__init__(**kwargs)
        self.cols = 2
        self.add_widget(Label(text='User Name'))
        self.username = TextInput(multiline=False)
        self.add_widget(self.username)
        self.add_widget(Label(text='password'))
        self.password = TextInput(password=True, multiline=False)
        self.add_widget(self.password)


class MyApp(App):

    def build(self):
        return LoginScreen()


if __name__ == '__main__':
    MyApp().run()

The app runs on Android, the keyboard also comes up. But crashes on typing anything. Output of $adb logcat | grep python (last few lines only):

03-07 10:19:48.972  7842  7857 I python  : [INFO   ] [GL          ] Texture max units <16>
03-07 10:19:48.976  7842  7857 I python  : [INFO   ] [Window      ] auto add sdl2 input provider
03-07 10:19:48.978  7842  7857 I python  : [INFO   ] [Window      ] virtual keyboard not allowed, single mode, not docked
03-07 10:19:48.981  7842  7857 W linker  : /data/data/org.test.textinput_tester/files/app/lib/python2.7/site-packages/jnius/jnius.so: is missing DT_SONAME will use basename as a replacement: "jnius.so"
03-07 10:19:49.379  7842  7857 I python  : [WARNING] [Base        ] Unknown <android> provider
03-07 10:19:49.379  7842  7857 I python  : [INFO   ] [Base        ] Start application main loop
03-07 10:19:49.383  7842  7857 I python  : [INFO   ] [GL          ] NPOT texture support is available
03-07 10:19:49.386  7842  7857 I python  : [ERROR  ] [Base        ] Failed to import "android" module. Could not remove android presplash.
03-07 10:20:14.940  7842  7857 I python  : [INFO   ] [Base        ] Leaving application in progress...
03-07 10:20:14.941  7842  7857 I python  :  Traceback (most recent call last):
03-07 10:20:14.942  7842  7857 I python  :    File "/home/guru/EclipseWorkspace1/ScratchArea/.buildozer/android/app/main.py", line 27, in <module>
03-07 10:20:14.944  7842  7857 I python  :    File "/home/guru/EclipseWorkspace1/ScratchArea/.buildozer/android/platform/build/dists/textinput_tester/private/lib/python2.7/site-packages/kivy/app.py", line 828, in run
03-07 10:20:14.946  7842  7857 I python  :    File "/home/guru/EclipseWorkspace1/ScratchArea/.buildozer/android/platform/build/dists/textinput_tester/private/lib/python2.7/site-packages/kivy/base.py", line 504, in runTouchApp
03-07 10:20:14.947  7842  7857 I python  :    File "/home/guru/EclipseWorkspace1/ScratchArea/.buildozer/android/platform/build/dists/textinput_tester/private/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 658, in mainloop
03-07 10:20:14.948  7842  7857 I python  :    File "/home/guru/EclipseWorkspace1/ScratchArea/.buildozer/android/platform/build/dists/textinput_tester/private/lib/python2.7/site-packages/kivy/core/window/window_sdl2.py", line 580, in _mainloop
03-07 10:20:14.950  7842  7857 I python  :  AttributeError: 'LogFile' object has no attribute 'encoding'
03-07 10:20:15.002  7842  7857 I python  : Python for android ended.

Tested on Android 6.0.1, and 5.1.1 (separate devices). FWIW, @Tommstein confirmed the same issue on IRC.

The error seems to be coming from line#580 added in commit#9246486.

@Fogapod
Copy link
Contributor

Fogapod commented Mar 8, 2017

#5045

@KeyWeeUsr
Copy link
Contributor

KeyWeeUsr commented Mar 8, 2017

@inclement possibly a missing thing for sdl2 start.c and other start.c files? Maybe just an alias would be enough? Or setting it to UTF8 as it's a linux anyway? I experienced encoding issues only on Windows, so... 🐱

@inclement
Copy link
Member

inclement commented Mar 8, 2017

I guess so - it would be simplest to just copy the encoding from the normal sys.stdout object, or even to forward arbitrary attribute access.

Edit: Or maybe that wouldn't be the right thing to do, I'm not sure.

@Fogapod
Copy link
Contributor

Fogapod commented Mar 21, 2017

After last commit TextInput start ignoring all entering buttons at some moment instead of crash the whole app. I need to deselect it and select again to continue entering symbols

@stale
Copy link

stale bot commented Oct 7, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Oct 7, 2017
@dessant dessant removed the stale label May 13, 2018
@Julian-O
Copy link
Contributor

Julian-O commented Nov 8, 2023

Appears to be fixed - window_sdl2.py checks if the attribute is present.

Closing as fixed, but please let us know if it is still happening.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants