Skip to content
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

[Bug]: ANGLE EGL device has again experienced poor X11 Server performance #780

Closed
hansm629 opened this issue Jan 4, 2025 · 40 comments
Closed

Comments

@hansm629
Copy link

hansm629 commented Jan 4, 2025

Problem description

https://github.com/termux/termux-x11/actions/runs/12559148802

Since the above build, the ANGLE EGL device (Exynos 2400: Xclipse 940 GPU) has again experienced poor X11 Server performance symptoms.

Before the ANGLE EGL improvements were reflected,

when moving the window, the screen would be vertically split or the periphery would be broken,

but since the above build, frame drops are also noticeable.

I am currently using the version below, which does not cause the symptoms.

https://github.com/termux/termux-x11/actions/runs/12556174093

What steps will reproduce the bug?

https://github.com/termux/termux-x11/actions/runs/12559148802

If you install the above version, the following symptoms will occur in X11.

  • Vertical splitting symptom when moving the Windows window with the mouse
  • Window periphery breakage symptom when moving the Windows window with the mouse
  • Frame drop when moving the Windows window with the mouse

What is the expected behavior?

No response

@twaik
Copy link
Member

twaik commented Jan 5, 2025

ANGLE EGL improvements were reflected

What EGL improvements?

@twaik
Copy link
Member

twaik commented Jan 5, 2025

And how exactly do you use ANGLE EGL? Termux does not have options to use EGL directly.

@hansm629
Copy link
Author

hansm629 commented Jan 5, 2025

@twaik
Screenshot_20250105_222743_Device Info HW+

As you may remember,
Exynos 1480, 2200, 2400 series

does not support Android EGL and only supports Vulkan driver.

That is why
OpenGL ES3.2 is implemented as ANGLE EGL, a combination of ANGLE + Vulkan driver.

The X11 server performance of Termux-X11 running on ANGLE EGL environment was very poor.

  • The screen is split vertically when moving the window
  • The window periphery is broken when moving the window

There was a symptom like the above,

97bee98

The symptom was completely fixed starting from the above commit.

However,
https://github.com/termux/termux-x11/actions/runs/12559148802

The above build re-occurs with the same symptoms and also causes frame drops.

The same for llvmpipe, virpipe, and zink.

@twaik
Copy link
Member

twaik commented Jan 5, 2025

Does it happen in legacy drawing mode and/or with forcing bgra on the latest build? I mean different combinations of -legacy-drawing and -force-bgra.

@hansm629
Copy link
Author

hansm629 commented Jan 5, 2025

@twaik
I will give you feedback after testing tomorrow.

@hansm629
Copy link
Author

hansm629 commented Jan 6, 2025

@twaik
Sorry for the late feedback.

https://github.com/termux/termux-x11/actions/runs/12629982140

Based on the latest build above,
Even if you run the X11 server by adding the -legacy-drawing or -force-bgra environment variables,

XDG_RUNTIME_DIR=${TMPDIR} termux-x11 :1.0 -legacy-drawing & 
XDG_RUNTIME_DIR=${TMPDIR} termux-x11 :1.0 -force-bgra & 

the following symptoms still occur.

  • Vertical splitting symptom when moving the Windows window with the mouse
  • Window periphery breakage symptom when moving the Windows window with the mouse
  • Frame drop when moving the Windows window with the mouse

llvmpipe, virpipe, zink all occur the same,

and separately from the frame drop,

glmark2, glmark2-es2, vkmark all measured

https://github.com/termux/termux-x11/actions/runs/12556174093

Only about half the performance of the build is shown.

As I mentioned earlier, this symptom occurs only in the Xclipse GPU series where OpenGL ES3.2 is implemented with ANGLE EGL (ANGLE + Vulkan driver).

@twaik
Copy link
Member

twaik commented Jan 6, 2025

  • Vertical splitting symptom when moving the Windows window with the mouse

Do you mean screen tearing?

Window periphery breakage symptom when moving the Windows window with the mouse

You mean visual artifacts?

Frame drop when moving the Windows window with the mouse

You mean stuttering?

Most of these problems may be caused by ANGLE not working with both AHardwareBuffers and regular textures properly, probably the cause of it is not performing drawing in time. I can try to write some kind of alternative renderer which will use vulkan directly in the case if it is available, but it will happen after moving renderer code to activity in order to fix displaying on Huawei and some other devices.

@twaik
Copy link
Member

twaik commented Jan 7, 2025

Should be fixed by f5e0f05 . Check the latest build.

@hansm629
Copy link
Author

hansm629 commented Jan 7, 2025

@twaik
I'll check after work!

@hansm629
Copy link
Author

hansm629 commented Jan 7, 2025

@twaik
https://github.com/termux/termux-x11/actions/runs/12650161419
Tested with the above build.

The test results show that the issue of X11 Server being slow and causing frame drops has been fixed!
The glmark2, glmark2-es2, and vkmark scores that were cut in half are now Good results.

However, there are still tearing symptoms and artifacts appearing in the periphery when moving the window quickly.

llvmpipe, virpipe, and zink are all the same.

Screenshot_20250107_210035_Video Player
Screenshot_20250107_205833_Video Player
Screenshot_20250107_205919_Video Player
Screenshot_20250107_210021_Video Player

@twaik
Copy link
Member

twaik commented Jan 7, 2025

Does it happen with llvmpipe?

@twaik
Copy link
Member

twaik commented Jan 7, 2025

I mean can you please check if it happens with regular llvmpipe/lavapipe without any GPU acceleration?
And can you please check the -legacy-drawing again?
Because it is weird. I added explicit glFinish() call which must ensure all drawing operations are finished before the method returns control back to program to make sure there will be no tearing. And I checked it on my device: I changed scale to 30 to see super big display and tearing was gone.

@hansm629
Copy link
Author

hansm629 commented Jan 7, 2025

@twaik
Yes, it happens the same way. Rather, llvmpipe showed slower performance compared tozink and virpipe.

I'll give you feedback again after adding the -legacy-drawing option.

@hansm629
Copy link
Author

hansm629 commented Jan 7, 2025

@twaik
Oh! I just tested it

With the -legacy-drawing option added, llvmpipe doesn't have the same symptoms.
(Without the -legacy-drawing option, llvmpipe, zink, and virpipe all have the same symptoms)

https://github.com/termux/termux-x11/actions/runs/12556174093

In the above build, both zink and virpipe worked fine without the -legacy-drawing option. Can this be fixed?

@twaik
Copy link
Member

twaik commented Jan 7, 2025

it was before I moved rendering to its own thread. I have no plans to move it back to X11 thread.

@twaik
Copy link
Member

twaik commented Jan 7, 2025

app-arm64-v8a-debug.zip
Check this one.

@hansm629
Copy link
Author

hansm629 commented Jan 7, 2025

@twaik
Oh! In the new build, without the -legacy-drawing option, the symptom still occurs,
but with the -legacy-drawing option, the symptom does not occur in zink.

@hansm629
Copy link
Author

hansm629 commented Jan 7, 2025

@twaik
Hmm, that's a bit weird. After a while, the tearing still occurs intermittently, almost like vsync is going out.

@twaik
Copy link
Member

twaik commented Jan 7, 2025

app-arm64-v8a-debug.zip
I believe this artifact will fix that.

@twaik
Copy link
Member

twaik commented Jan 7, 2025

app-arm64-v8a-debug.zip
Updated artifact.

@twaik
Copy link
Member

twaik commented Jan 7, 2025

This fix worked for few other testers and they reported there are no regressions in stability or performance so I decided to merge it. It should be available in the latest build. https://github.com/termux/termux-x11/actions/runs/12658293115

@twaik
Copy link
Member

twaik commented Jan 7, 2025

The code I wrote should be effectively same as in the commit you referenced. Renderer does not let X server continue execution until the screen is being drawn. So I believe it will fix this annoying bug.

@hansm629
Copy link
Author

hansm629 commented Jan 8, 2025

@twaik
I'll test it out after work today.

@hansm629
Copy link
Author

hansm629 commented Jan 8, 2025

@twaik
Great!

As of the latest build
It works smoothly in most scenarios!!

But there are some strange symptoms.
Tearing and artifacts still occur only in vkucbe & glxgears demos.

glmark2 & glmark2-es2, vkmark do not have such symptoms at all even when moving the window quickly.

And strangely, the frame rate of the vkcube demo feels low. (It runs unsmoothly.)

Screenshot_20250108_213817_Video Player
Screenshot_20250108_213614_Video Player

2025_01_08.21_42.mp4
2025_01_08.21_42.1.mp4

@twaik
Copy link
Member

twaik commented Jan 8, 2025

app-arm64-v8a-debug.zip
Let's try this approach.

@hansm629
Copy link
Author

hansm629 commented Jan 8, 2025

@twaik
Thanks for the new build.

Test results still show tearing and artifacts only in vkcube & glxgears.
(especially vkcube demo is not running smoothly.)

glmark2, glmark2-es2, vkmark, blender, firefox(WebGL), etc.
do not show the symptoms.

@hansm629
Copy link
Author

hansm629 commented Jan 8, 2025

@twaik
Here are the additional test results.

When running glxgears with virpipe, tearing and artifacts do not occur through the following environmental activities.

~$ LIBGL_KOPPER_DISABLE=1 GALLIUM_DRIVER=virpipe glxgears

Firefox(WebGL) also does not have tearing and artifacts with virpipe, but zink occurs.

~$ LIBGL_KOPPER_DISABLE=1 GALLIUM_DRIVER=virpipe firefox

@twaik
Copy link
Member

twaik commented Jan 8, 2025

I start to think your gl driver is simply kidding me.
Did X server print anything? It should print some debug messages for the case it can ot use fences.

@hansm629
Copy link
Author

hansm629 commented Jan 8, 2025

@twaik
ANGLE EGL seems really troublesome to use X11.

How can I help you?
Should I organize the logcat or TERMUX_X11_DEBUG=1 log and deliver it to you?

@twaik
Copy link
Member

twaik commented Jan 8, 2025

Probably there is simpler reason why it keeps tearing. I did not protect root window in all possible places and missed some of them. I'll check it.

@twaik
Copy link
Member

twaik commented Jan 8, 2025

Because I'm starting to think I am not sane enough. It is not possible that such a big company (google) releases drivers with visual artifacts like this.

@hansm629
Copy link
Author

hansm629 commented Jan 8, 2025

@twaik
https://github.com/termux/termux-x11/actions/runs/12559148802

However, many parts have been fixed compared to the above build.
In that build, XFCE4 GUI tearing is torn and frame drops occur,

But from the latest built version, tearing and artifacts occur only in certain situations. (vkcube, zink_glxgears, zink_webgl)
I believe you will fix it enough! 😀

@twaik
Copy link
Member

twaik commented Jan 9, 2025

app-arm64-v8a-debug.zip
Try this one.

@hansm629
Copy link
Author

hansm629 commented Jan 9, 2025

@twaik
Vulkan and zink not working in new build

~$ vkcube
Selected WSI platform: xcb
vulkan: No DRI3 support detected - required for presentation
Note: you can probably enable DRI3 in your Xorg config
Segmentation fault

~$  vkmark
vulkan: No DRI3 support detected - required for presentation
Note: you can probably enable DRI3 in your Xorg config
vulkan: No DRI3 support detected - required for presentation
Note: you can probably enable DRI3 in your Xorg config
Error: No suitable Vulkan physical devices found

~$  glxgears
vulkan: No DRI3 support detected - required for presentation
Note: you can probably enable DRI3 in your Xorg config
MESA: error: zink: could not create swapchain
Running synchronized to the vertical refresh.  The framerate should be
approximately the same as the monitor refresh rate.
X Error of failed request:  GLXBadCurrentWindow
  Major opcode of failed request:  149 (GLX)
  Minor opcode of failed request:  11 (X_GLXSwapBuffers)
  Serial number of failed request:  52
  Current serial number in output stream:  52

~$  glmark2
vulkan: No DRI3 support detected - required for presentation
Note: you can probably enable DRI3 in your Xorg config
MESA: error: zink: could not create swapchain
=======================================================
    glmark2 2023.01
=======================================================
    OpenGL Information
    GL_VENDOR:      Mesa
    GL_RENDERER:    zink Vulkan 1.3(Samsung Xclipse 940 (SAMSUNG_PROPRIETARY))
    GL_VERSION:     4.6 (Compatibility Profile) Mesa 24.3.3
    Surface Config: buf=32 r=8 g=8 b=8 a=8 depth=24 stencil=0 samples=0
    Surface Size:   800x600 windowed
=======================================================
vulkan: No DRI3 support detected - required for presentation
Note: you can probably enable DRI3 in your Xorg config
MESA: error: zink: could not create swapchain
[build] use-vbo=false:X Error of failed request:  GLXBadCurrentWindow
  Major opcode of failed request:  149 (GLX)
  Minor opcode of failed request:  11 (X_GLXSwapBuffers)
  Serial number of failed request:  68
  Current serial number in output stream:  68

@twaik
Copy link
Member

twaik commented Jan 9, 2025

Yeah, I kinda removed the code which did the dri3 trick because it was a part of the problem. I am going to reimplement it back in a few hours.

@twaik
Copy link
Member

twaik commented Jan 9, 2025

app-arm64-v8a-debug.zip
I believe this should work fine.

@hansm629
Copy link
Author

@twaik
Thank you. I'll test it out after work today!

@twaik
Copy link
Member

twaik commented Jan 10, 2025

app-arm64-v8a-debug.zip
Newer artifact to test.

@hansm629
Copy link
Author

@twaik
Thank you Sir!

It's perfect!!!

All symptoms are fixed and it works great.
I tested it in various scenarios and no more tearing, artifacts and frame drops on zink!

In fact, in the future Google roadmap, it is said that Android EGL will be kicked out and
OpenGL ES support will be supported with ANGLE EGL via ANGLE + Vulkan Driver, so Termux-X11 is almost ready for the future!

Thank you so much for fixing it!!

GaQ5ZxGWMAAHo3u

@twaik
Copy link
Member

twaik commented Jan 12, 2025

Fixed by cb8c4b0 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants