machawk1 / wail

:whale2: Web Archiving Integration Layer: One-Click User Instigated Preservation
https://matkelly.com/wail
MIT License
350 stars 35 forks source link

Experiment with GTK Broadway backend instead of VNC in Docker #409

Open ibnesayeed opened 5 years ago

ibnesayeed commented 5 years ago

Here is an experiment to run GNONE Calculator using the native GTK to HTML5 transformation.

$ docker container run --rm -it -p 8085:8085 ubuntu bash
[CONTAINER] # apt update && apt install -y libgtk-3-bin gnome-calculator
[CONTAINER] # broadwayd :5 &
[CONTAINER] # GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 gnome-calculator

In a web browser open http://localhost:8085/

EDIT (by MK), screenshot of gcalc:

Screen Shot 2019-03-26 at 4 14 30 PM
machawk1 commented 5 years ago

Thanks for document this, @ibnesayeed. For my own self-reference, this would allow a Linux (or Mac/Windows) user that used Docker to access WAIL using their web browser instead of VNC. In @ibnesayeed's experiments, gedit and the native calculator app worked well and looked way better than WAIL does in its current Docker configuration. This may be due to the default windowing system in the Ubuntu basis image configuration.

This did not go smoothly with apps like Gimp and Evince (Linux's PDF viewer). When we tried it with WAIL per above by running these commands when logged into the container and manually installing the dependencies, the DISPLAY mapping did not seem to work. More details on this to come as I get time to try it out.

EDIT: @ibnesayeed has since been able to get Evince to work.

ibnesayeed commented 5 years ago

Similar to GDK, for QT-based applications there is something called WebGL Streaming.

machawk1 commented 5 years ago

Revised commands from the above adapted for WAIL execution:

$ docker container run -v ${PWD}:/wail -w="/wail" -e "TZ=Europe/Minsk" --rm -it -p 8085:8085 ubuntu bash
# apt update && apt install -y libgtk-3-bin apt-file libgtk-3-0 libnotify4 libsdl1.2debian libsm6 libxxf86vm1 python3 python3-pip
# pip3 install -U -f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-18.04 wxPython==4.0.4 &&  pip3 install pyinstaller==3.4
# pip3 install -r requirements.txt
# pyinstaller -p bundledApps ./bundledApps/WAIL.py --onefile --windowed --clean &&  mv /wail/dist/WAIL /wail/WAIL
# broadwayd :5 &
# GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 ./WAIL

This still returns:

User likely has the binary in the wrong location.
Unable to access the X Display, is $DISPLAY set properly?

as with the experiments with @ibnesayeed but the above should be replicable with respect to WAIL, as extracted from the Dockerfile.

ibnesayeed commented 5 years ago

I have a feeling that wxPython is by default using QT-based UI components in this situation, but I am not too sure.

machawk1 commented 5 years ago

I tried docker container run -v ${PWD}:/wail -w="/wail" -e "TZ=Europe/Minsk" -e "DISPLAY=:0" --rm -it -p 8085:8085 ubuntu bash with the same result.

I was under the impression that wxWidgets (and presumably wxPython) were using GTK under the hood. I may have to look into it more and maybe create a more fundamental example exhibiting this behavior before asking the wxPython community. (Unless @RobinD42 can chime in).

RobinD42 commented 5 years ago

wxPython/wxWidgets does use GTK by default. My understanding is that wxWidgets can be built to support broadway as the GTK backend, although last I checked not all features were available in that mode. It would take some work to get wxPython to support a broadway version of wxWidgets as there are a few places that assume that x11 is being used, and also that all required wxWIdgets features are always available. So although it's not supported currently, it should be doable.

ibnesayeed commented 5 years ago

Thanks @RobinD42, this was very informative. At least now we know that some UI libraries have an assumption that X11 must be available in Linux environment. This explains why some seemingly GTK-based applications were failing to run.