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

Bad video performance and screen tearing #334

Closed
zanfix opened this issue May 30, 2023 · 8 comments
Closed

Bad video performance and screen tearing #334

zanfix opened this issue May 30, 2023 · 8 comments

Comments

@zanfix
Copy link

zanfix commented May 30, 2023

Hi @twaik

Here is my findings with the last version (I'm using build https://github.com/termux/termux-x11/actions/runs/5108462890)

I have bad video performance and noticeable screen tearing, that I did not have with previous versions.

So I had a look at the cpu usage for termux-x11 from android terminal with htop and I noticed that, on my device at least, the app_process process seems forced to run on the little cores (cpus from 0 to 3). In particular 1 thread, appears to be the one that uses cpu resources when the screen is refreshed.

So i tried to create a stune cgroup and place the app_process process into it and apply a schedtune.boost of 10 to see if video performance would increase.

The result is that the app_process in no longer bound to the small cores but will run on the big cores (cpus from 4 to 7). This improved performance a lot on my device!

But still, something changed from previous releases because I can still clearly see screen tearing! It's quite noticeable with a 24/30fps video on youtube, and nearly not noticeable with a 50/60fps video, so basically what I am seeing is that screen tearing will occur with anything below 60 fps!?

It's actually strange because if I have a look at the youtube "stat for nerds" i actually see very few dropped frames even at 60 fps (I am actually using an old version of firefox-esr to watch youtube videos since with recent versions of firefox or chromium video playback is actually bad... but this another story...)

Maybe issue #322 is related...

My device is a rooted samsung galaxy tab s6 (Snapdragon 855) with samsung firmware, android 10 with dex 2.5

EDIT: actually with chromium 113 from debian repos i do not have screen tearing with 30fps videos, so I may be an issue with the old firefox-esr version I am using (78.15.0esr). 60fps videos with chromium use too much resources but play fine with firefox-esr... oh well...

@ask9027
Copy link
Contributor

ask9027 commented Jun 13, 2023

try latest now.

@twaik
Copy link
Member

twaik commented Jun 13, 2023

That happened before 4927432 so it is not fixed.

@ask9027
Copy link
Contributor

ask9027 commented Jun 13, 2023

oh.. i have not noticed

@zanfix
Copy link
Author

zanfix commented Jun 16, 2023

Update: I tried installing termux. From there I installed x11-repo termux-x11-nightly and firefox.

No tearing at all in firefox! videos play fine!

This also does not appear to be a problem:
So I had a look at the cpu usage for termux-x11 from android terminal with htop and I noticed that, on my device at least, the app_process process seems forced to run on the little cores (cpus from 0 to 3). In particular 1 thread, appears to be the one that uses cpu resources when the screen is refreshed
Runs just fine on the big cores...

videos i use for testing:

30 fps: https://www.youtube.com/watch?v=MfL_JkcEFbE
60 fps: https://www.youtube.com/watch?v=0RvIbVmCOxg

Well... will have to understand what is going on... Anyone has and idea what it could be?

@zanfix
Copy link
Author

zanfix commented Jun 17, 2023

I fixed the issue with this workaround:

  • compile https://github.com/termux/libandroid-shmem inside che chroot/container (debian in my case)
  • place the resulting libandroid-shmem.so in /usr/local/lib/ (for example) and add the path of the library to /etc/ld.so.preload
  • restart/reload the container

NOTE: the library will not compile out of the box, i had to tweak it a little for missing headers/definitions

@zanfix
Copy link
Author

zanfix commented Jun 17, 2023

The workaround for the app_process process running on small cores still remains, this affects performance. The solution i adopted to place the process in an stune and cpuset cgroups may not be possible on some devices. Maybe taskset can also work, did not try.

NOTE: may not affect al devices...

@twaik
Copy link
Member

twaik commented Jun 17, 2023

Related to #14

Maybe taskset can also work, did not try.

Other users used this to enforce runnning termux-x11 on big cores. I can make termux-x11 force using big cores sched_setaffinity just like it is done by taskset.

@zanfix
Copy link
Author

zanfix commented Jun 19, 2023

Related to #14

Maybe taskset can also work, did not try.

Other users used this to enforce runnning termux-x11 on big cores. I can make termux-x11 force using big cores sched_setaffinity just like it is done by taskset.

Fixed with build 396!

@zanfix zanfix closed this as completed Jun 19, 2023
@termux termux locked and limited conversation to collaborators Jul 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants