termux / termux-x11

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

[Bug]: X server not running on Galaxy S24+ #544

Closed hansm629 closed 4 months ago

hansm629 commented 6 months ago

Problem description

The X server is showing a black screen on Galaxy S24+ (Exynos2400 ver).

The X-shaped mouse pointer does not appear either.

~ $ termux-x11 :1 &
[1] 31330
~ $ "The XKEYBOARD keymap compiler (xkbcomp) reports:"
"> "Warning:          Could not resolve keysym XF86CameraAccessEnable
"> "Warning:          Could not resolve keysym XF86CameraAccessDisable
"> "Warning:          Could not resolve keysym XF86CameraAccessToggle
"> "Warning:          Could not resolve keysym XF86NextElement
"> "Warning:          Could not resolve keysym XF86PreviousElement
"> "Warning:          Could not resolve keysym XF86AutopilotEngageToggle
"> "Warning:          Could not resolve keysym XF86MarkWaypoint
"> "Warning:          Could not resolve keysym XF86Sos
"> "Warning:          Could not resolve keysym XF86NavChart
"> "Warning:          Could not resolve keysym XF86FishingChart
"> "Warning:          Could not resolve keysym XF86SingleRangeRadar
"> "Warning:          Could not resolve keysym XF86DualRangeRadar
"> "Warning:          Could not resolve keysym XF86RadarOverlay
"> "Warning:          Could not resolve keysym XF86TraditionalSonar
"> "Warning:          Could not resolve keysym XF86ClearvuSonar
"> "Warning:          Could not resolve keysym XF86SidevuSonar
"> "Warning:          Could not resolve keysym XF86NavInfo
"Errors from xkbcomp are not fatal to the X server"

20240128.txt

What steps will reproduce the bug?

XFCE4 not running in Termux

PRoot-Distro Linux also doesn't run.

What is the expected behavior?

There is nothing in particular.

twaik commented 6 months ago

Did you try -legacy-drawing mode?

twaik commented 6 months ago

According to the log there was no connection. Did you open application during recording this log?

hansm629 commented 6 months ago

According to the log there was no connection. Didyou open application during recording this log?

-legacy-drawing

Even if you run it in that mode, the same black screen appears.

No separate applications were run while executing the debug command. T_T

twaik commented 6 months ago

It does not matter what runs in session. What matters is what happens during connection attempt which did not happen (according to the log)...

twaik commented 6 months ago

I think I can try to fix it with Remote Test Lab by Samsung. But it will happen a bit later, I am kind of busy with other projects.

hansm629 commented 6 months ago

@twaik

After reinstalling Termux-X11, the X server ran in -legacy-drawing mode! :)

First of all, I think #544 that I posted can be closed.

but

https://github.com/termux/termux-x11/issues/495

Like the issue, the X server color was displayed strangely.

Issue #495 appears to be a compatibility issue caused by the Exynos GPU's ANGLE driver. Are there any plans to fix it?

yueziji commented 6 months ago

Have the same problem, but it still hasn’t been solved after using -legacy-drawing...

chris-mcdonald-dev commented 5 months ago

Device: S24 (Exynos CPU) Also just sharing that I initially could only get it to work with the -legacy-drawing flag. Not sure why though, but a week later with some config changes, it works without it. I'll play around to find out why it's working without it now.

twaik commented 5 months ago

I found something that may cause a problem. Try https://github.com/termux/termux-x11/actions/runs/7973490833 artifact with -force-bgra and -legacy-drawing in different combinations.

twaik commented 5 months ago

20240128.txt

@hansm629 you did not switch to main applcation during capturing this log so it is useless. Can you make one more log but with switching to main application please?

twaik commented 4 months ago

Unfortunately I failed to setup Remote Test Lab of Samsung. RDB does not want to connect. I could check this if someone wants to lend me device (remotely). But now I can not fix it.

twaik commented 4 months ago

Can someone please check if build 592 can run without -legacy-drawing flag?

twaik commented 4 months ago

@hansm629 ?

twaik commented 4 months ago

Ok, it seems like that works in Remote Test Lab (yeah, I tested this without adb).

screenshot ![image](https://github.com/termux/termux-x11/assets/9674930/ecfa03c4-750d-4cb6-8d38-6adc58dee99a)
twaik commented 4 months ago

@yueziji @chris-mcdonald-dev ?

hansm629 commented 4 months ago

@twaik Sorry for the late reply. I'm working right now, so I'll test it after work. (I have the S24+ at home.)

twaik commented 4 months ago

@hansm629 are you home?

hansm629 commented 4 months ago

@twaik I am currently leaving work. I'm a little late because I worked overtime. We will provide feedback within 2 hours.

hansm629 commented 4 months ago

@twaik I will provide feedback on the test results. X11 is displayed well on Galaxy S24+ (Exynos2400 Ver) even without the -legacy-drawing option.

However, it seems to show somewhat worse performance compared to -legacy-drawing.

As shown in the attached video and screenshot, there is a symptom that the Windows window breaks when moved quickly.

Screenshot_20240326_230755_Gallery Screenshot_20240326_230801_Gallery

https://github.com/termux/termux-x11/assets/101167173/cfdef5de-877b-4876-ab58-b9d1c7420aac

twaik commented 4 months ago

Yeah, seems like a tearing. Can you please make a screen recording using screen capturing tool and not record a screen with another device? Pixels and focus distance changes confuse me.

hansm629 commented 4 months ago

@twaik I'm thinking it may be a PRoot problem, so I'm uninstalling Debian 12 and reinstalling it.

If there are any symptoms after installation, I will capture a video and upload it.

I think it will take some time~

twaik commented 4 months ago

Try to use regular termux's xfce for test. And please tell me if it is reproducible.

hansm629 commented 4 months ago

@twaik The same symptom occurs on both PRoot Debian and Termux XFCE.

But strangely, the above symptoms disappear when I use a screen capture application.

Let's find a way to capture video of the symptoms.

When running xfce with Termux native on a Snapdragon device, it is very smooth, but in the case of Exynos 2400 If you don't use the "-legacy-drawing" option, you'll see frame drops and screen tearing if you move the window quickly... Hmm...

twaik commented 4 months ago

Let's try to do glFinish() before calling eglSwapBuffers. app-universal-debug.zip

twaik commented 4 months ago

Or, even better, before drawing cursor. app-universal-debug.zip Check if it fixes tearing.

hansm629 commented 4 months ago

@twaik Sorry for the late reply. The two apks you provided still occasionally cause GUI frame drops and tearing on the X11 server.

But interestingly, the GUI operates smoothly when glmark2 (or glmark2-es2) is running or a video is being played using VLC.

Could this be related to the Exynos2400's Xclipse 940 GPU driver? Xclipse 940 uses Angle EGL, not the regular EGL driver.

In an X11 server environment Case1: virglrenderer-android Case2: angle-android + virglrenderer-android Case3: vulkan-loader-android + mesa-zink + virglrenderer-mesa-zink

When running glmark2 (or glmark2-es2), the total score was only 60 to 70 fps.

It's just a guess, but I assume there is a problem with libEGL_angle.so, the default driver for Exynos2400 Xclipse 940 GPU. Is there a possibility that this could cause problems with compatibility and performance with Termux-X11?

hansm629 commented 4 months ago

@twaik oh! oh my god! I changed the value of vblank_mode from auto -> off in xfwm4.xml. Performance has improved!!!

Now on Exynos 2400 Works smoothly in both Termux native XFCE environment and PRoot Linux XFCE environment!

What does this option have to do with it? There were no problems with Exynos using the Snapdragon series and the existing Mali GPU. This problem occurred with the Exynos 2400, which was changed to an AMD RDNA3 base GPU. Is this also a compatibility issue with the Exynos 2400 Android libEGL_angle.so driver?

twaik commented 4 months ago

Is tearing problem fixed with disabling vblank mode too?

hansm629 commented 4 months ago

Is tearing problem fixed with disabling vblank mode too?

Yes! :)

twaik commented 4 months ago

I have a few ideas how to make that work. But I need to research something.

hansm629 commented 4 months ago

@twaik If you need testing, please let me know anytime. :)

twaik commented 4 months ago

app-universal-debug.zip Try this.

Diff is for me. diff.txt

twaik commented 4 months ago

Do not forget to enable vblank.

twaik commented 4 months ago

@hansm629 ?

hansm629 commented 4 months ago

@twaik I'm going out for a while right now. I'll tell you the test results when I get back home! :)

hansm629 commented 4 months ago

@twaik

Intermittent performance degradation (GUI tearing) still occurs when the vblank_mode option is set to auto.

This happens more clearly when zink or virgl is applied to X11.

ah! I discovered an interesting symptom.

This time, after applying WSI Layer to Xclipse940, I am conducting several tests in combination with zink.

Case 1. In the case of Vulkan + mesa-zink 22.0.5 (tur-repo), if the value of vblank_mode in xfce4's xml settings is auto, the display refresh rate is recognized as 30Hz(?!) on the xfce4 desktop. (When turned off, normal performance occurs at 60Hz)

Case 2. In the case of Vulkan + mesa 24.0.5 (main-repo), if the value of vblank_mode in xfce4's xml settings is auto, the xfce4 desktop screen is displayed in black and only the mouse pointer is visible.

In virglrenderer-android, when the value of vblank_mode is set to auto, the performance of glmark2, glmark2-es2, etc. is reduced by half compared to before turning off, resulting in lower performance and intermittent GUI tearing.

twaik commented 4 months ago

Wait. Vulkan and Zink rendering are different issue. Try to use it with llvmpipe. NO hardware acceleration, only software.

twaik commented 4 months ago

And maybe you should try original apk (from action or release) with llvmpipe, not the one I sent. Only for check.

hansm629 commented 4 months ago

Wait. Vulkan and Zink rendering are different issue. Try to use it with llvmpipe. NO hardware acceleration, only software.

Oh, come to think of it In the case of the newly delivered version There is no such symptom in llvmpipe. (In previous versions, the same symptom existed in lvmpipe)

Both Termux native XFCE and PRoot Linux XFCE

When using X11 by applying zink or virgl (virpipe)

If the vblank_mode value is auto, slowdown or GUI tearing will occur!

twaik commented 4 months ago

So probably it is a problem of zink or virgl since I did not change any behaviour that can affect them. Probably I can try to change fake PRESENT extension behaviour to make it spawn vblank events when Android Choreographer sends event. But I am not sure if it can fix this.

hansm629 commented 4 months ago

@twaik First of all, it seems to be okay if I set the vlbank_mode value to off and use it, but will there be any problems if the value is off?

twaik commented 4 months ago

I have no idea.

hansm629 commented 4 months ago

@twaik First, let's set the value to off and use it.

I tested it further

With X11 in llvmpipe state At least there doesn't seem to be any GUI tearing symptoms when running a program using the zink or virpipe environment variable in the terminal.

For Exynos 2400 It seems clear that this only happens when zink or virpipe is applied to X11.

twaik commented 4 months ago

So that is definitely a problem of zink and virgl. I'll research something to generate vblank events with Android's Choreographer, but I am not sure it will fix this.

twaik commented 4 months ago

Probably buffer turnip/zink/wsi-layer uses is being released too early so it's content is veing rewritten. @xMem can you please investigate this?

twaik commented 4 months ago

Because Android's graphics architecture does not allow mixing different GraphicBuffers in the same frame HardwareComposer posts. I mean it posts only the latest frame, and it can not be accessed in while it is being drawn.

xMeM commented 4 months ago

Probably buffer turnip/zink/wsi-layer uses is being released too early so it's content is veing rewritten. @xMeM can you please investigate this?

This is due to missing implicit synchronization, so the X server reads incomplete frames.

twaik commented 4 months ago

Can we somehow fix this? Probably I should implement something on X server side?

xMeM commented 4 months ago

Can we somehow fix this? Probably I should implement something on X server side?

I need to wait for a fence before calling xcb_present_pixmap, because turnip kgsl cannot export the fence as sync file fd, so these need to be implemented in WSI.

twaik commented 4 months ago

@hansm629 You can wait for a while and do pkg up or install artifact from here. Also I still waiting for your response in two issues (including this one).