Description
Description
I believe there is an issue when building the flet/client
for debugging the flet client. It particularly makes it very difficult for further flutter module development in a Linux WSL2 distro.
This issue has been discussed in #2535 where I thought I was just lacking documentation and now I wish to document my understanding of the issue and assist resolving,
NOTE in the additional information I was able to get a VM based instance to build and operate as intended but required a remote ssh session from the VM host to the VM. whilst this could enable current development requirements I believe it should work in the WSL2 instance for general use and simple IDE operation ( please see additional information below)
Code and method example to reproduce the issue:
DEBUG build
- build and run a debug client with
flutter run-d linux --debug
in terminal 1 - a blank window appears with the turning in progress icon. This i believe is expected with a stream of Websocket connection failures in the Terminal
- create a 2nd Terminal window and cd to the
sdk/python/playground
- config the Flet DEBUG instance to use in the playground
export FLET_VIEW_PATH=$HOME/dev/SANDBOX/SANDBOX-flet/modules/flet/client/build/linux/x64/debug/bundle
- run the playground
poetry run flet run main.py -p 8550
- ❌A 2nd blank window appears with the turning in progress icon., the client in terminal 1 shows connected websockets and responds to key presses [R, h ....etc], but no main.py defined page is drawn
- in Terminal 2 logging show the connection happening but no message traffic regarding page building
In contrast, if I build the client with the profiling profile
PROFILING build
- build and run
flutter run -d linux --profile
in terminal 1 - a blank window appears (WITHOUT the turning in progress icon). and the terminal sits ideal waiting for a keypress [h,c,q etc...]
- create a 2nd Terminal window and cd to the
sdk/python/playground
- config the Flet instance to use in the playground
export FLET_VIEW_PATH=$HOME/dev/SANDBOX/SANDBOX-flet/modules/flet/client/build/linux/x64/profile/bundle
- run the playground
poetry run flet run main.py -p 8550
- ✅Flet creates a 2nd window and draws the appropriate page, nothing changes i the first blank window
- in Terminal 2 logging shows the message traffic regarding the page build
the very simple main.py
page definition is in the flet/sdk/python/playground
and reads as follows
def main(page: ft.Page):
flet_session_id = 12
print(
f"------------------------------ Main called --- adding to page a ft.Text: session {flet_session_id}"
)
page.add(
ft.Text(f"Hello, World of Flet!, current session is {flet_session_id}")
)
ft.app(
main,
# Disable to test in production format
# port=8550,
)
Describe the results you received:
see above
Describe the results you expected:
I expect in the WSL2 environment that the page presented in Linux GDI should be drawn and have the hot reloading working for debugging the flutter module integration when using the debug build of a Flet client.
Additional information you deem important (e.g. issue happens only occasionally):
In the logging in terminal 2 i have noticed a slight difference in the socket connection
The line flutter: Connected to: 127.0.0.1:8550
does not appear in the attempt to run the debugging build
in the case of the profiling build
flutter: Connecting to Flet server tcp://localhost:8550...
flutter: Connecting to Socket server tcp://localhost:8550...
flutter: Connected to: 127.0.0.1:8550
flutter: registerWebClientInternal
flutter: Sending: 532
------------------------------ Main called --- adding to page a ft.Text: session 12
flutter: Received packet: 598
and in the case of the debugging build
flutter: Connecting to Flet server http://localhost:8550...
flutter: Connecting to WebSocket server ws://localhost:8550/ws...
flutter: registerWebClientInternal
flutter: New page size: Size(1280.0, 720.0)
additionally I setup a virtual box vm with ubuntu22.04 desktop and have had the same issue, except with 1 working solution
If i ssh into the vm and execute the following it works
- config the Flet instance to use in the playground
export FLET_VIEW_PATH=$HOME/dev/SANDBOX/SANDBOX-flet/modules/flet/client/build/linux/x64/debug/bundle
- run the playground
poetry run flet run main.py -p 8550
- ✅Flet creates a 2nd window in the vm host with the appropriate page drawn, and the 1st page (from the
flutter run --debug
) also updates. Both pages draw identically - in the SSH Terminal there is no Debug logging, only the print from the main.py (as follows)
➜ playground git:(main) : poetry run flet run main.py -p 8550 -vv
http://127.0.0.1:8550
------------------------------ Main called --- adding to page a ft.Text: session 10
package:media_kit_libs_linux registered.
Flet version (pip show flet
):
using cloned from github.com and checkout to 0.22.0
flet 0.1.0 /home/fletdev/dev/SANDBOX/SANDBOX-flet/modules/flet/sdk/python/packages/flet
flet-core 0.1.0 /home/fletdev/dev/SANDBOX/SANDBOX-flet/modules/flet/sdk/python/packages/flet-core
flet-runtime 0.1.0 /home/fletdev/dev/SANDBOX/SANDBOX-flet/modules/flet/sdk/python/packages/flet-runtime
Give your requirements.txt
file (don't pip freeze
, instead give direct packages):
N/A and is none in this instance, just plain FLET
Operating system:
WSL2 ubuntu 22.04 distro on Windows 11
Additional environment details: