-
Notifications
You must be signed in to change notification settings - Fork 84
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
X11 with VNC, Fatal server error: (EE) Failed to activate virtual core keyboard: 2(EE) , termux workaround #75
Comments
With regards to the apparent "hanging", I failed to notice that xclock didn't have a second hand, of course it looked stuck. :P |
xinput shows:
|
See also https://wiki.archlinux.org/index.php/TigerVNC and https://wiki.archlinux.org/index.php/X11vnc . I'm going to try with x11vnc, maybe it will do something better resulting in things working. |
x11vnc works for the above! You just have to disable the shmem feature (* see error below and noshm in https://jlk.fjfi.cvut.cz/arch/manpages/man/x11vnc.1) to be able to use the display over the network (remember, the X11 server is running on the termux side).
*shmem error when trying to access a remote display:
It remains an open question what went wrong with no input with x0vncserver. |
That's some determination! I suggest you to make it into a wiki article, even if you don't consider that finished. Couple of notes:
AFAIK, strace or anything using ptrace doesn't work in proot in general, something about ptrace not being able to nest. There is a chance of something has changed since, but I don't recall that changing.
My favourite has always been bVNC. Just look at this beauty --- active since forever and still going strong.
Sorry, I didn't exactly get that: why this combination instead of a single vnc server like tigervnc? |
I think the Xvfb + x11vnc combination was kind of accidental. I didn't figure out if I can pass arguments on to X11 when starting the vnc server (probably yes?) - so I just started Xvfb appropriately and ran x0vncserver; but then there were the input problems so I tried switching to x11vnc because it seemed fancier, and then it worked. Edit: thanks for the client suggestion, I'll check it out! Always happy to have tool recommendations instead of haphazard searching. Edit2: the vnc server and x11 are separate because the current variant needs the vnc server started from nix (x11vnc isnt in termux), while x11 needs to run in termux - but it might work if I try going back to vncserver with my new knowledge, let's see what happens. Edit3: OK, I'm not sure right now where this leaves me, but it seems using Edit4: I rediscovered the first reason that I separated the VNC and X components: I hoped it would help ease debugging, back when I thought I might find a way to debug the X11 error. Running vncviewer (on nix) also yields the X error in the title, presumably through Xvnc. |
By the way, xterm doesn't work for some reason (window doesn't show up) - but other terminals like urxvt (rxvt-unicode package) work. |
With regards to debugging, guided by the hint of https://unix.stackexchange.com/questions/314335/how-to-run-xvfb-without-root/316240 ( https://ericdraken.com/running-xvfb-on-a-shared-host-without-x/ ), which has the same error, but different goal - and from which as of yet I haven't been able to gain much insight - I realized that we should be able to intercept the input and output of xkbcomp by writing a wrapper script that captures these to some file. Hopefully this will lead to diagnosing some fixable issue. Alternative ideas were:
But I finally figured out how to get past some Issues I had with multiprocess/threaded GDB debugging*, which does work**. *https://sourceware.org/gdb/onlinedocs/gdb/Background-Execution.html **The general procedure is to set a breakpoint on Popen, set the breakpoint command to Code (and a cloneable repo) is at https://github.com/freedesktop/xorg-xserver/blob/f33cb4264387ed14a586ba080885b4d21e4aa48b/xkb/ddxLoad.c#L139 Tangentially, |
TODO: figure out why Xvfb + x0vncserver had input issues. |
TL;DR: wasted too much time thinking xkbcomp was even being run at all. After some more GDB shenanigans; it turns out x11 has it's own Popen function, which causing a premature exit at https://github.com/freedesktop/xorg-xserver/blob/2902b78535ecc6821cc027351818b28a5c7fdbdc/os/utils.c#L1433 . Running
Which is probably a proot issue(TODO proot docs?). I will try to stub out setgid with a noop and LD_PRELOAD to get past this. Edit: Hey! I think it works! id.c:
compiled with:
□ Edit 2: for some reason the printfs don't seem to actually show up anywhere. let
ov = self: super: {
xorg = super.xorg // {
xkbcomp = super.writeShellScriptBin "xkbcomp" ''
tbasedir=$(mktemp -d comp.XXXXXXXXX -p /tmp )/
echo $tbasedir
tee ''${tbasedir}stdin.txt | {
${super.xorg.xkbcomp}/bin/xkbcomp "$@"
} 1> >(tee ''${tbasedir}stdout.txt ) 2> >(tee ''${tbasedir}stderr.txt >&2 )
'';
};
};
#I didn't check but Xvfb probably uses an xkbcomp built with it since they are the same codebase, so we have to do a two-staged build to get one with a wrapper
ov2 = self: super: {
xorg = super.xorg // {
xorgserver = super.xorg.xorgserver.overrideAttrs (old: {
configureFlags = old.configureFlags ++ [ "--with-xkb-bin-directory=${super.xorg.xkbcomp}/bin" ];
});
};
};
in
with import <nixpkgs> { overlays = [ ov ov2 ]; };
mkShell {
buildInputs = [ rxvt-unicode xorg.xorgserver xorg.xkbcomp xorg.xinput xorg.xclock awesome xterm xdotool x11vnc nano gdb which ];
} TODO: why does this lead to that particularly unhelpful error message? |
Updated tut:
with import <nixpkgs> {};
let
id_c = writeText "id.c" ''
#include <sys/types.h>
#include <stdio.h>
int setgid(gid_t gid){ printf("WARNING: setgid stubbed"); return 0; }
int setuid(uid_t uid){ printf("WARNING: setuid stubbed"); return 0; }
'';
id_so = runCommand "id.so" { buildInputs = [ gcc ]; } ''
mkdir -p $out
gcc -std=c99 -shared -fPIC ${id_c} -o $out/id.so
'';
myx = writeShellScriptBin "myx" ''
export DISPLAY=$1 #TODO dynamic?
LD_PRELOAD=${id_so}/id.so ${xorg.xorgserver}/bin/Xvfb $1 -ac -listen tcp &
sleep 5
${x11vnc}/bin/x11vnc -display $1 -passwd test -rfbport 5902 -noshm -forever & #not sure why noshm still needed
awesome &
urxvt -e env TERM=xterm tmux & #TODO probably wrong
'';
in mkShell { buildInputs = [ myx awesome rxvt-unicode tmux ]; }
|
It could have been a bit of a shortcut to check the termux packaging, which in fact involves some similar patches:
|
This can probably be closed after adding an overlay with the patches or something? |
Great work @deliciouslytyped! Yes I think documenting your results in a wiki page would be nice. And of course contributing an overlay would be good idea as long as the fix is as robust as it can be. I have to admit, I don't have such in deep knowledge about what you did here so I am not able to give feedback to the nix expression you mentioned earlier.. |
If anyone wants to pick my brain for clarifications please do so. but it's actually pretty simple once you get rid of all the "work in progress" cruft. There's two variants
I do the first one, the termux patches do the second one. |
I'm not sure how they've done it but FWIW TermuxArch pretty much works out of the box with tightvnc for me. I can't imagine they have any patches so there must be a difference in the proot technique. |
It looks like TermuxArch has it's own workaround TermuxArch/TermuxArch#34 |
IMHO TermuxArch has a fix via it's proot work not a workaround like those that Termux uses (package modifications). But I'm willing to be convinced otherwise. Alas doesn't seem that nix-on-droid supports this use case so I've long since given up on it and switched to TermuxArch full time. |
That's a very long thread - do you have any idea what they do? |
I get |
Sorry, I don't have time to look into this right now, but that error message looks like it should give you a string to pull on. |
I get the same error with nixpkgs-unstable |
|
For the inNixShell error, this looks relevant https://discourse.nixos.org/t/nix-shell-error-called-with-unexpected-argument-innixshell/20356 . |
|
Ok, I wasn't paying attention to the command line. It looks like there might have been a mistake in my original post; If this fix works I'll edit the original post. |
Yes, that made it work. Thank you! |
Thanks for this! I've managed to get { pkgs, config, lib, ... }:
let
id_c = pkgs.writeText "id.c" ''
#include <sys/types.h>
#include <stdio.h>
int setgid(gid_t gid){ printf("WARNING: setgid stubbed"); return 0; }
int setuid(uid_t uid){ printf("WARNING: setuid stubbed"); return 0; }
'';
id_so = pkgs.runCommand "id.so" { buildInputs = [ pkgs.gcc ]; } ''
mkdir -p $out
gcc -std=c99 -shared -fPIC ${id_c} -o $out/id.so
'';
xvnc-wrapped = pkgs.writeShellScriptBin "Xvnc" ''
LD_PRELOAD=${id_so}/id.so ${pkgs.tigervnc}/bin/Xvnc $@
'';
password-file = password:
pkgs.runCommand "password-file" { } ''
echo "${password}" | ${pkgs.tigervnc}/bin/vncpasswd -f > $out
'';
inherit (lib) types options;
cfg = config.services.tigervnc;
in {
options.services.tigervnc = {
enable = lib.mkEnableOption "tigervnc";
autostart = lib.mkOption {
type = types.bool;
default = false;
};
password = lib.mkOption {
type = types.str;
default = "password";
};
};
config = lib.mkIf cfg.enable {
supervisord.programs.tigervnc = {
path = [ xvnc-wrapped ];
command = "Xvnc :1 -PasswordFile ${password-file cfg.password}";
autostart = cfg.autostart;
};
};
} |
Has anyone gotten GLX support working with tigervnc? Things like gears from mesa-demos don't work and the extension isn't listed by xdpyinfo |
Update: termux not needed with #75 (comment)
I've been fiddling with #34 , and made something akin to progress, but there are some issues;
the hybridization approach seems to leave everything visible in VNC hanged, whatever that means.*cc @ShamrockLee
As a temporary workaround for #34, I tried installed and running X11 in termux.
I successfully installed and ran Xvfb, and connected nix-built applications to the remote display via the
$DISPLAY
variable over the loopback device. So a hybrid termux/nix-on-droid approach seems to work*.A thrown together tutorial (no authentication, etc, the point was just to see if I can even get this to work):
VNC Viewer
(by RealVNC) from the play store, or MultiVNC from F-Droid. Sadly the UI design of the former seems to work somewhat better. For example: the MultiVNC keyboard overlaps with the screen area for me, which is irritating Feature request: shift the canvas up/down when the keyboard is toggled bk138/multivnc#76 (comment)tigervnc
, providing thevncserver
andx0vncserver
commands, which spawn an Xvnc process, and the X11 stuff which provides Xvnc, Xvfb, etc.Xvfb -listen tcp -ac &
TERMUX: run x0vncserver to attach a vnc server to an existing display (TODO: check how to do it without password) (TODO: check if setting env var is needed) (TODO: the passwd file is created by running vncserver probably?):DISPLAY=:0 x0vncserver -rfbauth /data/data/com.termux/files/home/.vnc/passwd
Edit: NIX: start a nix-shell with x11vnc and run
DISPLAY=127.0.0.1:0 x11vnc -passwd whatever -rfbport 5901 -noshm -forever
see X11 with VNC, Fatal server error: (EE) Failed to activate virtual core keyboard: 2(EE) , termux workaround #75 (comment)export DISPLAY=127.0.0.1:0 && awesome & xclock &
enjoy your frozen windowsTODO: script that sshes to the termux and handles everythig in one place
The text was updated successfully, but these errors were encountered: