termux / termux-x11

Termux X11 add-on application.
https://termux.dev
GNU General Public License v3.0
1.96k stars 301 forks source link

Unable to get Termux:X11 working in a proot-distro #299

Closed LukeShortCloud closed 1 year ago

LukeShortCloud commented 1 year ago

Using Termux:X11 works perfectly when using Termux itself.

(termux)$ XDG_RUNTIME_DIR="${TMP}" termux-x11 &
(termux)$ DISPLAY=:0 dbus-launch --exit-with-session xfce4-session

termux.log

When using a proot-distro, nothing happens in Termux:X11. It shows a black screen with the signature Xorg "X" cursor which means that the termux-x11 process is running and working. Apparently the proot-distro is not able to utilize that Xwayland environment. I do see all of the related Xorg files in /tmp in the Arch Linux proot, too.

(termux)$ proot-distro login archlinux --shared-tmp
(archlinux)$ XDG_RUNTIME_DIR=/tmp DISPLAY=:0 dbus-launch --exit-with-session xfce4-session

proot-distro-archlinux.log

I have attached the standard output and error of running the xfce4-session command in both Termux and in the proot-distro for comparison. Thank you in advance for any help you can provide!

sylirre commented 1 year ago

In your log file:

dbus[20579]: Unable to set up transient service directory: XDG_RUNTIME_DIR "/tmp" can be written by others (mode 041777)

Does it work if you do chmod o-rwx /tmp inside the proot-distro?

LukeShortCloud commented 1 year ago

After removing permissions for others, the same warning appears but it complains about the new permissions.

dbus[20579]: Unable to set up transient service directory: XDG_RUNTIME_DIR "/tmp" can be written by others (mode 041770)

I then tried chmod 0755 to make the temporary file a normal folder (which can break things for other programs). That removes the above warning entirely. But Termux:X11 is still not working and all I get is a black screen with a mouse cursor.

All of the other warnings still appear about failing to launch various XFCE4 related programs:

Unable to launch "<XFCE_PROGRAM>": Failed to close file descriptor for child process (Invalid argument)
twaik commented 1 year ago

Read this. https://github.com/termux/termux-packages/issues/14039

twaik commented 1 year ago

Maybe it is some error in dbus-launch, try to run DISPLAY=:0 xfce4-session

LukeShortCloud commented 1 year ago

Thanks everyone for all the hints. Here's everything new I've tested so far based on the latest suggestions:

I also tried a few things that did end up working:

I can only come to the conclusion that either (A) there's a bug in Arch Linux or (B) I'm missing other dependencies in Arch Linux. I've cross-checked many Termux:X11 guides about Arch Linux and installed everything that should be needed.

Here are all of the packages I have installed in Arch Linux:

$ sudo pacman -S dbus firefox networkmanager pulseaudio xfce4 xfce4-goodies lightdm xorg xorg-server

I don't think a display manager such as LightDM is necessary since we are manually starting a session via the CLI but it was listed in one of the guides I as following.

For reference, here are all of the guides I've been reading over:

Saikatsaha1996 commented 1 year ago

After removing permissions for others, the same warning appears but it complains about the new permissions.

dbus[20579]: Unable to set up transient service directory: XDG_RUNTIME_DIR "/tmp" can be written by others (mode 041770)

I then tried chmod 0755 to make the temporary file a normal folder (which can break things for other programs). That removes the above warning entirely. But Termux:X11 is still not working and all I get is a black screen with a mouse cursor.

All of the other warnings still appear about failing to launch various XFCE4 related programs:

Unable to launch "<XFCE_PROGRAM>": Failed to close file descriptor for child process (Invalid argument)

I think it is not termux-x11 issue.. same issue with me.. Even vnc also not working.. you can better understand..

https://github.com/termux/proot-distro/issues/293#issue-1669129587

LukeShortCloud commented 1 year ago

Agreed. We can rule out Termux:X11 as being the issue because (1) individual X11 apps do work with Arch Linux and (2) the XFCE4 desktop environment does work with Debian. I'll go ahead and close this issue.

Thanks everyone for your help and insight! I'll report back if I can ever get Arch Linux to fully work.

ochakov commented 1 year ago

I have the same issue and would like to add my five cents. I have a Samsung S7 FE tablet and a Pixel phone. Running proot-distro Ubuntu 22.04. With the same setup exactly, the problem only occurs on Samsung, but not on Pixel. I tried other distros as well with no luck.

Looks like the problem is related to Samsung.

Saikatsaha1996 commented 1 year ago

I have the same issue and would like to add my five cents. I have a Samsung S7 FE tablet and a Pixel phone. Running proot-distro Ubuntu 22.04. With the same setup exactly, the problem only occurs on Samsung, but not on Pixel. I tried other distros as well with no luck.

Looks like the problem is related to Samsung.

No i checked.. it is actually our vendor issue..

Don't have any issues with miui device

mio-19 commented 11 months ago

Looks like the problem is related to Samsung.

I also have two devices available and the problem only occurs on Samsung

Saikatsaha1996 commented 11 months ago

Looks like the problem is related to Samsung.

I also have two devices available and the problem only occurs on Samsung

Gki kernel? Kernel version 5.4 or 5.10 ?

szw0407 commented 11 months ago

Same on Samsung Galaxy Tab S7 FE, using ArchLinux proot, following the steps of https://ivonblog.com/en-us/posts/termux-proot-distro-archlinux/

Quite puzzled... Is there anything different between One UI and other Android based Operate systems?

mio-19 commented 11 months ago

Same on Samsung Galaxy Tab S7 FE, using ArchLinux proot, following the steps of https://ivonblog.com/en-us/posts/termux-proot-distro-archlinux/

Quite puzzled... Is there anything different between One UI and other Android based Operate systems?

It is caused by glib2. You need to disable close range related code blocks in glib/gspawn.c

mio-19 commented 11 months ago

Same on Samsung Galaxy Tab S7 FE, using ArchLinux proot, following the steps of https://ivonblog.com/en-us/posts/termux-proot-distro-archlinux/

Quite puzzled... Is there anything different between One UI and other Android based Operate systems?

There is something different on 5.4 gki android kernel but I don't know what exactly

mio-19 commented 11 months ago

Same on Samsung Galaxy Tab S7 FE, using ArchLinux proot, following the steps of https://ivonblog.com/en-us/posts/termux-proot-distro-archlinux/ Quite puzzled... Is there anything different between One UI and other Android based Operate systems?

It is caused by glib2. You need to disable close range related code blocks in glib/gspawn.c

I made a patched package here https://github.com/mio-19/aur-patches-aarch64/tree/3049fa6c9ecfe008aa58cbdf5dce69389088b69b/_kernel5_4/glib2-no-close-range

szw0407 commented 11 months ago

Same on Samsung Galaxy Tab S7 FE, using ArchLinux proot, following the steps of https://ivonblog.com/en-us/posts/termux-proot-distro-archlinux/ Quite puzzled... Is there anything different between One UI and other Android based Operate systems?

It is caused by glib2. You need to disable close range related code blocks in glib/gspawn.c

I made a patched package here https://github.com/mio-19/aur-patches-aarch64/tree/3049fa6c9ecfe008aa58cbdf5dce69389088b69b/_kernel5_4/glib2-no-close-range

Have you ever tried using Debian?

I tried using it following the steps on ivonblog, expecting it to work as many other issues mentioned that would work just fine, but I failed... Is there anything that website didn't mention?

Infact I am quite unfamiliar with Linux... I could hardly deal with such problems by simply reading archwiki...

mio-19 commented 11 months ago

Infact I am quite unfamiliar with Linux... I could hardly deal with such problems by simply reading archwiki...

It is a issue specific to a version of android kernel and isn't documented on archwiki.

If you installed an older version of Debian such as Debian 11 it should work fine. The issue was introduced by newer versions of glibc and glib.

mio-19 commented 11 months ago

@szw0407 Just to confirm, was the error message Failed to close file descriptor for child process (Invalid argument) ?

Saikatsaha1996 commented 11 months ago

Infact I am quite unfamiliar with Linux... I could hardly deal with such problems by simply reading archwiki...

It is a issue specific to a version of android kernel and isn't documented on archwiki.

If you installed an older version of Debian such as Debian 11 it should work fine. The issue was introduced by newer versions of glibc and glib.

Can you fell back to Android 12 ? In Android 12 with kernel 5.4 newer Ubuntu & Debian working..

szw0407 commented 11 months ago

@szw0407 Just to confirm, was the error message Failed to close file descriptor for child process (Invalid argument) ?

Yes, along with some other warnings.

I opened a discussion under that blog, with all errors, and the x11 app has only black screen and a cursor:

details

Similar things happen in Debian 12, and I am unable to deal with it.

szw0407 commented 11 months ago

Infact I am quite unfamiliar with Linux... I could hardly deal with such problems by simply reading archwiki...

It is a issue specific to a version of android kernel and isn't documented on archwiki.

If you installed an older version of Debian such as Debian 11 it should work fine. The issue was introduced by newer versions of glibc and glib.

Can you fell back to Android 12 ? In Android 12 with kernel 5.4 newer Ubuntu & Debian working..

Perhaps not.

Samsung devices cannot be downgraded unless being rooted, but that would destroy Knox. Unfortunately I am not yet ready for that.

mio-19 commented 10 months ago

Similar things happen in Debian 12, and I am unable to deal with it.

Yes all recent glibc versions have problems with close range which 5.4 gki android kernel doesn't have.

Glibc incorrectly thinks that the program doesn't have the permission instead of the kernel not having this feature. Glib will use a fallback method on kernels without this feature, but glib received the wrong message from glibc.

szw0407 commented 10 months ago

yeah, and I managed to install xfce4 on Debian 11, everything seemed fine so far...

Thanks for your support. Wish the issue you mentioned be fixed soon in a new release.

BBCByComcast commented 10 months ago

I Fix Glibc in All Latest Proot Distro Using Better Desktop Environment, Go My Issues And You See, It's KDE Plasma (or Kubuntu Desktop If You Are Ubuntu), Everything Fine with All Latest Proot Distro, Do You Accept My Issues?

Saikatsaha1996 commented 10 months ago

I Fix Glibc in All Latest Proot Distro Using Better Desktop Environment, Go My Issues And You See, It's KDE Plasma (or Kubuntu Desktop If You Are Ubuntu), Everything Fine with All Latest Proot Distro, Do You Accept My Issues?

Will check..

BBCByComcast commented 10 months ago

I Fix Glibc in All Latest Proot Distro Using Better Desktop Environment, Go My Issues And You See, It's KDE Plasma (or Kubuntu Desktop If You Are Ubuntu), Everything Fine with All Latest Proot Distro, Do You Accept My Issues?

Will check..

Sure, That KDE Plasma And Kubuntu Desktop is Better....

mio-19 commented 10 months ago

I Fix Glibc in All Latest Proot Distro Using Better Desktop Environment, Go My Issues And You See, It's KDE Plasma (or Kubuntu Desktop If You Are Ubuntu), Everything Fine with All Latest Proot Distro, Do You Accept My Issues?

Did you use a translator or something?

oltenxyz commented 10 months ago

I Fix Glibc in All Latest Proot Distro Using Better Desktop Environment, Go My Issues And You See, It's KDE Plasma (or Kubuntu Desktop If You Are Ubuntu), Everything Fine with All Latest Proot Distro, Do You Accept My Issues?

Did you use a translator or something?

That guy is wreaking havoc all over the repo. Today, I woke up to 27 unintelligible emails, just because I responded to a different issue from him. EDIT: And thanks for that patch btw! :) Any idea on what goes wrong in the 5.4 kernel to cause it?

szw0407 commented 10 months ago

Similar things happen in Debian 12, and I am unable to deal with it.

Yes all recent glibc versions have problems with close range which 5.4 gki android kernel doesn't have.

Glibc incorrectly thinks that the program doesn't have the permission instead of the kernel not having this feature. Glib will use a fallback method on kernels without this feature, but glib received the wrong message from glibc.

I have just found something curious, when I just removed systemd using a package manager, though with lots of components of xfce removed, the startxfce4 command successfully launched the GUI environment. I've tested that on openSUSE in proot.