Open wd5gnr opened 1 year ago
Hi @wd5gnr, I really appreciate your feedback 👍🏻 and I will try to apply this solution for Linux. However, I would like to point out that other users have been able to run the software successfully under Linux and QT, so perhaps this solution only applies in certain particular cases such as KDE Neon. I will definitely take a closer look at this. Thank you again for sharing your experience with me!
@happenpappen, if you have time, as someone who also uses the software on Linux, do you have any insights on this matter? Thanks a lot :)
(I found this : https://github.com/r0x0r/pywebview/issues/890)
Also, have you installed this dependancy? pip3 install pyqt5 pyqtwebengine They talk about it in the discussion.
Yes both of those show satisfied. There is evidence that it isn't just me and the test.py shows it isn't you, it is some setup of pywebview[qt]:
https://github.com/r0x0r/pywebview/issues/929
I had not noticed the 890 one you mentioned ... will look at that. But no, all of that is already installed.
@wd5gnr and @happenpappen, what do you recommend to solve this issue for sure, given that I don't have a Linux to test it myself? Is it necessary to always force the use of GTK under Linux? Is there anything that needs to be added or modified in the Linux section of the repository readme? Thank you very much for your help!
(It is very simple indeed to force GTK but the installation changes a little if I understood correctly and moreover, depending on the use of the venv).
Without knowing the cause, I would hesitate to make too many big changes. Here's what I would propose:
In conf.py add a variable for webviewGUI:
WEBVIEW_GUI = ''
then in Start (app.py) I would say
if conf.WEBVIEW_GUI = '':
webview.start([stuff that is there now])
else:
webview.start([stuff that is there now],gui=config.WEBVIEW_GUI)
That's my suggestion. I don't think passing '' to gui= is the same as leaving it off, but there might be a better way to do that. I was thinking you could set it to None, but a quick test shows you'd still have to do the above but just test for none instead of '' and I don't think that really makes any difference.
Oh and then, of course, in the Linux readme, you might point out that change conf.py to set conf.WEBVIEW_GUI to 'gtk' is known to help instances where qt is broken and that other values are qt, and the others that can go there (I don't remember the one for Windows).
@jczic : I tried reproducing this on my laptop (which runs on Ubuntu 22.04 as well) by installing the Neon desktop, but ended in a mess regarding the installed packages. If i had sufficent ressources available on my laptop, i could try this in a virtual machine, but that's currently not possible.
I like @wd5gnr idea of making this a configuration option which has a safe default setting. Maybe it is possible to check the available engines on the first startup of the program and set the config option automatically?
Actually, if you want to have it where the config is None to take the default, here's how to do it (had to do some reading):
from functools import wraps
def remove_none_from_kwargs(func):
@wraps(func)
def wrapper(*args, **kwargs):
func(*args, **{k: v for k, v in kwargs.items() if v is not None})
return wrapper
def test(arg=100):
print(arg)
test=remove_none_from_kwargs(test)
test(arg=None)
test(arg=33)
So using a scheme like that you could pass None to start (probably need to add a self to wrapper) and get the default, but if you pass, say, 'gtk', you'd get that. I'd make the change and send a PR but it would be next week before I could do that so if you want to just grab it from here that's perfectly fine. You should probably make the call of exactly how far down this rabbit hole you want to go anyway ;)
:+1: Thank you both so much, I will see what I can do quickly, but tonight, for this option! I'll add the doc in the readme as well and tell you here when done :) Thanks again, it's good that it's moving in the right direction! See you soon.
Just @wd5gnr, if it does not work, you see 2 white screens but what exactly is going on? Does it crash the software and it close or do the 2 screens stay open indefinitely? Maybe a try...except on start(...) is raised?
( I would like to be able to detect the problem automatically because changing a configuration in the sources implies a desynchronization with the repository. Or maybe run app.py with an argument... )
You get two blank white screens and then they're hung up so they're not processing events. The only way I can stop it is to externally, kill it or press control z to put it to sleep and then I can kill it while it's asleep but clicking on the x or even pressing control. C does not cause it to exit when it gets into that mode.
I ran it through the debugger and essentially webview start. Just never enters the event loop. It's getting hung somewhere in there.
On Sat, Apr 1, 2023, 13:15 Jean-Christophe Bos @.***> wrote:
Just @wd5gnr https://github.com/wd5gnr, if it does not work, you see 2 white screens but what exactly is going on? Does it crash the software and it close or do the 2 screens stay open indefinitely? Maybe a try...except on start(...) is raised?
( I would like to be able to detect the problem automatically because changing a configuration in the sources implies a desynchronization with the repository. Or maybe run app.py with an argument... )
— Reply to this email directly, view it on GitHub https://github.com/jczic/ESP32-MPY-Jama/issues/35#issuecomment-1493065460, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARTDE7KTIPZ5NFDO57TFR3W7BWC3ANCNFSM6AAAAAAWO7JL44 . You are receiving this because you were mentioned.Message ID: @.***>
Ok I see, it does not receive the WebSocket (there is my little HTTP/WebSockets server inside). Normally, the second window is hidden at startup and the first one is the splash-screen but @happenpappen modified line 67 to not hide the second window anymore under Linux (maybe it didn't work) :
hidden = not (conf.IS_WIN32 | conf.IS_LINUX),
If you look at the side of this line, you will see the creation of the 2 UI windows.
There is also line 297 self._mainWin.show()
which is executed under Linux to show the second window (which is not hidden under Linux).
So the program does not crash and there would be a way to automatically detect it because the WebSocket does not connect after a certain time between the browser and the internal server.
Also, you can pass gui=None
without problem to start()
, I tested and pywebview takes the first best browser in a certain order (see https://pywebview.flowrl.com/guide/renderer.html).
Everything of pywebview arguments is here: https://pywebview.flowrl.com/guide/api.html#webview-start
Do you launch the app through the Linux shell or directly through the GUI? Maybe I could write some during the startup procedure in the terminal so we can see the steps :)
I thought that as well, but I was able to open a browser on the server socket mentioned in the config file. So I don't think it is that simple. The fact that it works with gtk tells me it is something with the qt rendering. The fact that I can make it work without the venv and my test case doesn't work with the venv tells me it is some sort of setup/version mismatch....
@wd5gnr, I added the management of an argument allowing to force the web engine (commit https://github.com/jczic/ESP32-MPY-Jama/commit/f3e2ab86313b8cf3a60a080438d38ed546c298f0). Try to run the program normally (when it crashes) and it should tell you how to do it. Then test with the gtk argument to see if it works as expected :) Thank you!
Hi @wd5gnr, is-it fixed for you?
I'm not sure what you are expecting to happen. The result for me is the same. I launch the code and I get what appears now to be a single window in the same state as before: blank and hung up. From the command line, the only thing I can do to get control back is Control+Z. Then I can kill the process. Running it again does nothing. There are no --help options.
So... no, unless I don't understand what to do, it is not working. I did not look at your commit, but I will do so now.
Ok -g gtk does work. But the code to detect it is hung isn't working. I'm not surprised because, well, it is hung ;-) Everything is blocked. Just to be clear, clicking the X on the window or using Control+C from the launching console does NOTHING. From the debugger, the webview start() is never returning ever.
Hmm :( I think it must be a blocking when launching the interface with GTK or that all the javascript on the interface crashes completely because the blocking detection code (line 1560) is not executed under Linux (no splash screen). If you see the UI, it's because it passed the startup otherwise, if you still have a white window, it's because there is a problem when loading GTK with pywebview. For the moment, I don't see where this problem could be located at my level and it's not easy to look for it (I don't have any Linux for test...).
some info’s from me as Ubuntu 22.04, Gnome user, it’s only info !!!
First of all, its work for me as described in the Jama Linux installation + running part of the readme!
When I install Jama the first time i see some names of the needed software with “...qt…” and I thought I’m running QT! But during the dialog “Args force GUI” i am surprised that I really use GTK!
I can start Jama (readme/Linux running) w/o parameter and after the fix “Args force GUI” I know and have tested also with “-g gtk” !
If I try to run Jama with “-g qt” (only test) I get still the same here described situation (white hanging window)!
I can see the following GTK processes:
and QT processes
Detail off the 4 QTWebEnginePro: 1.
2.
3.
4.
It must be a problem in cooperation gtk/qt. Maybe you can see something.
I agree it is nothing you are doing that is causing this because even my simple test program doesn't work without forcing gtk.Like I say, when you single step, the call to start on the webview is what hangs. I haven't traced further than that because it is upstream. But there are enough people using KDE that I think along with the switch just a note in the "how to run for Linux" would be sufficient and maybe one day the upstream will get it fixed.
In reality, the pyWebView library, which uses the best web browser available, decides to use QT or GTK depending on what it finds on your system. However, I added the possibility to force it to start with QT or GTK as an argument. On the other hand, when you force QT or GTK in this way, it will start with the first one, but if that doesn't work, it will try the other one anyway.
How do you see what can be explained in the Linux section of the readme?
From my point of view: nothing. It's only the try to confirm, that I can reproduce this (equal reason ?) situation!
I added the info to force the GUI in the readme, commit: https://github.com/jczic/ESP32-MPY-Jama/commit/937230d63a0daf1b5647aeb94ff07cb687a34dbc It's ok for you? Can I close this issue?
That's fine with me.
Thanks for working this.
On Sat, Apr 8, 2023, 10:45 Jean-Christophe Bos @.***> wrote:
I added the info to force the GUI in the readme, commit: 937230d https://github.com/jczic/ESP32-MPY-Jama/commit/937230d63a0daf1b5647aeb94ff07cb687a34dbc It's ok for you? Can I close this issue?
— Reply to this email directly, view it on GitHub https://github.com/jczic/ESP32-MPY-Jama/issues/35#issuecomment-1500918081, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARTDEYRMWL2SJBORHTBZRTXAGB2VANCNFSM6AAAAAAWO7JL44 . You are receiving this because you were mentioned.Message ID: @.***>
I consistently get two blank screens and a hang when trying to run under KDE Neon (basically Ubuntu). I tried a few things. To isolate the problem I did this:
If I am not in the venv and I have python3-webview installed it works. Without that package, of course, it doesn't.
If I go into the Jama venv, then it does not work (same as the app) with or without python3-webview (but with the pip-managed webview[qt].
However, if I do: pip3 install pywebview[gtk] and then modify the code to include gui='gtk' on the start line it works. Making the same change in app.py allows MPY-Jama to run also.