flet icon indicating copy to clipboard operation
flet copied to clipboard

Regression: TextField not working on Linux Mint

Open Birnendampf opened this issue 1 year ago • 14 comments

Duplicate Check

  • [X] I have searched the opened issues and there are no duplicates

Describe the bug

When trying to use a TextField, it is not possible to input text, and the window stops being closeable as soon as the TextField is focused. Any other interaction also fails when the TextField is focused. Flet becomes completely unresponsive.

Code sample

Code
import flet as ft


async def main(page: ft.Page):
    field = ft.TextField(on_change=print, on_submit=print)
    page.add(field)


ft.app(main)

To reproduce

On linux (in my case mint):

  1. run code
  2. select text field
  3. try to type (no text appears, nothing is being printed)
  4. try to hit enter (nothing is being printed)
  5. try to close window

Expected behavior

at step 3: text is being entered at step 5: the window closes

Screenshots / Videos

after resize

state of Flet window after focusing the text field and resizing

Operating System

Linux

Operating system details

Linux Mint 21.3 Cinnamon

Flet version

0.24.0

Regression

Yes, it used to work in a previous Flet version (please specify the version in additional details)

Suggestions

No response

Logs

Logs when run with debug level logging, and executing the steps to reproduce:
DEBUG:asyncio:Using selector: EpollSelector
INFO:flet_runtime:Assets path configured: /home/[username]/.config/JetBrains/PyCharm2024.1/scratches/assets
DEBUG:flet_core:Creating new PubSubHub instance
DEBUG:flet_core:Creating new PubSubHub instance
INFO:flet_runtime:Starting up UDS server on /tmp/OK1ms9Ei21
INFO:flet_runtime:Flet app has started...
INFO:flet_runtime:App URL: /tmp/OK1ms9Ei21
INFO:flet_runtime:Starting Flet View app...
INFO:flet_runtime:Flet View found in: /home/[username]/.flet/bin/flet-0.24.0
package:media_kit_libs_linux registered.
DEBUG:flet_runtime:Connected new TCP client
DEBUG:flet_runtime:_on_message: {"action":"registerWebClient","payload":{"pageName":"tmp/OK1ms9Ei21","pageRoute":"/","pageWidth":"1280.0","pageHeight":"720.0","windowWidth":"1280.0","windowHeight":"720.0","windowTop":"25.0","windowLeft":"1945.0","isPWA":"false","isWeb":"false","isDebug":"false","platform":"linux","platformBrightness":"dark","media":"{\"padding\":{\"top\":0.0,\"right\":0.0,\"bottom\":0.0,\"left\":0.0},\"view_padding\":{\"top\":0.0,\"right\":0.0,\"bottom\":0.0,\"left\":0.0},\"view_insets\":{\"top\":0.0,\"right\":0.0,\"bottom\":0.0,\"left\":0.0}}","sessionId":""}}
DEBUG:flet_runtime:__send: {"action":"registerWebClient","payload":{"session":{"id":"","controls":{"page":{"i":"page","t":"page","p":"","c":[],"route":"/","width":"1280.0","height":"720.0","windowwidth":"1280.0","windowheight":"720.0","windowtop":"25.0","windowleft":"1945.0","pwa":"false","web":"false","debug":"false","platform":"linux","platformBrightness":"dark","media":"{\"padding\":{\"top\":0.0,\"right\":0.0,\"bottom\":0.0,\"left\":0.0},\"view_padding\":{\"top\":0.0,\"right\":0.0,\"bottom\":0.0,\"left\":0.0},\"view_insets\":{\"top\":0.0,\"right\":0.0,\"bottom\":0.0,\"left\":0.0}}"}}},"error":"","appInactive":false}}
DEBUG:flet_core:_process_command: get ['page', 'route'] {}
DEBUG:flet_core:_process_command: get ['page', 'pwa'] {}
DEBUG:flet_core:_process_command: get ['page', 'web'] {}
DEBUG:flet_core:_process_command: get ['page', 'debug'] {}
DEBUG:flet_core:_process_command: get ['page', 'platform'] {}
DEBUG:flet_core:_process_command: get ['page', 'platformBrightness'] {}
DEBUG:flet_core:_process_command: get ['page', 'media'] {}
DEBUG:flet_core:_process_command: get ['page', 'width'] {}
DEBUG:flet_core:_process_command: get ['page', 'height'] {}
DEBUG:flet_core:_process_command: get ['page', 'windowWidth'] {}
DEBUG:flet_core:_process_command: get ['page', 'windowHeight'] {}
DEBUG:flet_core:_process_command: get ['page', 'windowTop'] {}
DEBUG:flet_core:_process_command: get ['page', 'windowLeft'] {}
DEBUG:flet_core:_process_command: get ['page', 'clientIP'] {}
DEBUG:flet_core:_process_command: get ['page', 'clientUserAgent'] {}
INFO:flet_runtime:App session started
DEBUG:flet_core:_process_command: add [] {'to': 'page', 'at': '0'}
DEBUG:flet_core:_process_command: add [] {'to': 'page', 'at': '1'}
DEBUG:flet_runtime:__send: {"action":"pageControlsBatch","payload":[{"action":"addPageControls","payload":{"controls":[{"t":"view","i":"_1","p":"page","c":["_2"],"at":"0"},{"t":"textfield","i":"_2","p":"_1","c":[],"onchange":"true"}],"trimIDs":[]}},{"action":"addPageControls","payload":{"controls":[{"t":"offstage","i":"_3","p":"page","c":[],"at":"1"}],"trimIDs":[]}}]}
DEBUG:flet_runtime:sent to TCP: 604
DEBUG:flet_runtime:sent to TCP: 347
DEBUG:flet_runtime:_on_message: {"action":"pageEventFromWeb","payload":{"eventTarget":"_2","eventName":"focus","eventData":""}}
DEBUG:flet_core:page.on_event_async: _2 focus 
DEBUG:flet_runtime:Gracefully terminating Flet app...
DEBUG:flet_runtime:Flet View process 6056
DEBUG:flet_runtime:Closing connection...
DEBUG:flet_runtime:Disconnecting all pages...
DEBUG:flet_core:page.on_event_async: page disconnect 
DEBUG:flet_runtime:Shutting down thread pool...

Process finished with exit code 0

Additional details

This is a new regression with 0.24.0, it used to work in 0.23.2. I have tested both versions after each other to make sure the issue is not caused by anything else. I have also tested the code sample on windows and macOS, it works just fine there.

Birnendampf avatar Sep 03 '24 13:09 Birnendampf

Same behavior for SearchBar and CupertinoTextField

Birnendampf avatar Sep 03 '24 14:09 Birnendampf

Hello,

In my Linux (Mint 22 - Cinamon 6.2.9) they work fine, exept the accents.

If I type something like "Aló", appears "Al´ó" (a first nonesense accent and then the correct one)

Thanks, best regards

nastiliano avatar Sep 03 '24 20:09 nastiliano

Hello,

In my Linux (Mint 22 - Cinamon 6.2.9) they work fine, exept the accents.

If I type something like "Aló", appears "Al´ó" (a first nonesense accent and then the correct one)

Thanks, best regards

Opps... and another strange behaviour. I can't delete completely their values... Always remains the first character.

If I want to remove "Aló", always remains "A"

nastiliano avatar Sep 03 '24 20:09 nastiliano

I can't delete completely their values... Always remains the first character.

image

https://python.plainenglish.io/whats-new-in-flet-v0-24-0-83f758245f4d

ndonkoHenri avatar Sep 04 '24 07:09 ndonkoHenri

When trying to use a TextField, it is not possible to input text, and the window stops being closeable as soon as the TextField is focused. Any other interaction also fails when the TextField is focused. Flet becomes completely unresponsive.

Works normally on my Mac. @Birnendampf do you have Linux too? Please can you guys share a video?

ndonkoHenri avatar Sep 04 '24 07:09 ndonkoHenri

Found a Flutter issue related this: https://github.com/flutter/flutter/issues/153560 I subscribed so I get notified on any updates.

ndonkoHenri avatar Sep 04 '24 07:09 ndonkoHenri

I can't delete completely their values... Always remains the first character.

image

https://python.plainenglish.io/whats-new-in-flet-v0-24-0-83f758245f4d

Ok!! Thanks

nastiliano avatar Sep 04 '24 08:09 nastiliano

Hello,

In my Linux (Mint 22 - Cinamon 6.2.9) they work fine, exept the accents.

also using mint and for you its fine? that's strange, maybe its my system. I will try upgrading to Mint 22 maybe its the OS

Birnendampf avatar Sep 04 '24 14:09 Birnendampf

Hello, In my Linux (Mint 22 - Cinamon 6.2.9) they work fine, exept the accents.

also using mint and for you its fine? that's strange, maybe its my system. I will try upgrading to Mint 22 maybe its the OS

Hello. I was facing this issue too on Mint 22 and I re-installed mint and the issue went away. I don't think it is an OS problem because users using Mint 21.3 or 22 and other versions are also facing this issue https://github.com/flutter/flutter/issues/153560. But this for sure is happening with 3.24.0. Updating your mint might fix this for you as my fresh installation helped me.

ShubhamVG avatar Sep 04 '24 15:09 ShubhamVG

didn't fix it for me sadly, is there any more info I should provide or do we wait until it's fixed upstream? At the risk of sounding inexperienced, is there a way to use the new version of flet with an old version of flutter?

Birnendampf avatar Sep 04 '24 16:09 Birnendampf

Hello,

In my Linux (Mint 22 - Cinamon 6.2.9) they work fine, exept the accents.

If I type something like "Aló", appears "Al´ó" (a first nonesense accent and then the correct one)

Thanks, best regards

Hello,

Just now I reviewed it again with Linux (Mint 22 - Cinnamon 6.2.9) and Flet v.0.24.1 and doing the right steps explained at:

https://python.plainenglish.io/whats-new-in-flet-v0-24-0-83f758245f4d

And all works perfect for me, I can't help you sorry.

Thanks, best regards.

nastiliano avatar Sep 04 '24 20:09 nastiliano

didn't fix it for me sadly, is there any more info I should provide or do we wait until it's fixed upstream? At the risk of sounding inexperienced, is there a way to use the new version of flet with an old version of flutter?

That is interesting. I did a fresh mint installation so there was no backup involved apart from my old code. Did you use timeshift or something to create a snapshot or backup of either the entire machine or just the home folder? If so, did you install it too before or after installing flutter? I have a hypothesis that nothing from the home directory is causing the flutter TextField to not function properly like a binary or lib*.so from somewhere else. However, I have neither any reasoning to back that up nor any means to try it out at the moment. By the way, did you try to remove your flutter folder and install it again? Ah also, I installed arch linux on my machine before re-installing mint so I was fiddling around with secure boot and other things. Maybe you can try to toggle those around tho' that is very unlikely to work.

ShubhamVG avatar Sep 05 '24 16:09 ShubhamVG

I have some bad news. I just went to try if TextField is still working on my mint or not and I realized that it is not :sob: When I had my fresh mint installation, everything was working fine. Hmm, maybe I installed or apt autopurge-d something I shouldn't have.

ShubhamVG avatar Sep 05 '24 17:09 ShubhamVG

@Birnendampf and others, I would like to bring your attention to this https://github.com/flutter/flutter/issues/153560#issuecomment-2336682859. If you have an urgent project and don't want to downgrade flutter, then you can just change your desktop environment. I am using i3wm for a while and didn't have the textfield issue so far. I tried on KDE Plasma and didn't have issue there either but my KDE setup was not configured or anything i.e., it was the bare minimum KDE setup so cannot say for sure if switching to KDE Plasma is a guaranteed workaround or not but worth a try if it is urgent.

ShubhamVG avatar Sep 20 '24 09:09 ShubhamVG

Seems like we have a workaround, which we could try: https://github.com/flutter/flutter/issues/153560#issuecomment-2497160535

ndonkoHenri avatar Nov 25 '24 08:11 ndonkoHenri

Please install the latest Flet prerelease and let know if the issue is resolved: pip install flet --pre -U

ndonkoHenri avatar Nov 25 '24 23:11 ndonkoHenri

as I mentioned upstream, all widgets that Internally use the EditableText widget are affected, i forgot to mention this here sorry. This means that

import flet as ft


async def main(page: ft.Page):
    page.add(ft.Text("select me!", selectable=True), ft.FilledButton("hi"))


ft.app(main)

also hangs when selecting the text, because it uses SelectableText which uses EditableText. TextField works though!

Birnendampf avatar Nov 27 '24 13:11 Birnendampf

also ft.SelectionArea(ft.Text("select me!")) works, because it just uses Text

Birnendampf avatar Nov 27 '24 13:11 Birnendampf

Makes sense, thanks for sharing. Any other?

ndonkoHenri avatar Nov 27 '24 14:11 ndonkoHenri

Yes, I just realized this applies to CuppertinoTextField, SearchBar, TimePicker, DatePicker, the Cupertino Variants of Those, anything where you can type in text is affected I am not sure if it is worth it to wrap all of those in ExcludeSemantics especially since disabling the virtual keyboard fixes the Issue and a solution is already being worked on in Flutter.

For anybody else who is affected by this (@ShubhamVG ?): Go to Accessibility > Keyboard and make sure "Enable the on-screen keyboard" is turned off.

Birnendampf avatar Nov 27 '24 20:11 Birnendampf

Alright, let's just leave it as-is for now while waiting for an upstream fix.

ndonkoHenri avatar Nov 27 '24 21:11 ndonkoHenri

Yes, I just realized this applies to CuppertinoTextField, SearchBar, TimePicker, DatePicker, the Cupertino Variants of Those, anything where you can type in text is affected I am not sure if it is worth it to wrap all of those in ExcludeSemantics especially since disabling the virtual keyboard fixes the Issue and a solution is already being worked on in Flutter.

For anybody else who is affected by this (@ShubhamVG ?): Go to Accessibility > Keyboard and make sure "Enable the on-screen keyboard" is turned off.

I think I tried that previously but it didn't work. I use flutter not flet btw and someone did mention this hack to get TextField to work and they said that this trick works sometimes. Anyways, I won't be affected by this anymore cuz I use arch (BTW) xD Jokes aside, it sounds somewhat impractical to ask app users to turn off that setting just to get 1 app to work. I'd rather use ExcludeSemantics. Anyways, I believe there will be an upstream fix very soon judging from the progress in https://github.com/flutter/flutter/issues/153560 so that's great too!

ShubhamVG avatar Nov 28 '24 16:11 ShubhamVG