e8root
Posts: 3
Joined: Thu Jul 11, 2019 8:02 am

[RPi4/RPi3] Input lag with video driver enabled

Wed Jul 24, 2019 8:52 pm

I have noticeable input lag on my Pi4 4GB when using vc4-fkms-v3d driver which is completely gone when I use frame buffer. It feel like at least one frame of additional lag.

At first I thought it is usbhit.mousepoll issue with my wireless mouse I use for Pi but this was not it. The lag is there no matter of this or any other setting, mouse and monitor used and is completely gone when I comment driver. I did rpi-update twice, including today before posting this.

For my use this is actually non-issue as I do not care about 3D or playing games. Chromium works great, even better than with hardware acceleration because it made system unresponsive when playing videos. Videos plays great without this driver in VLC, even 110Mbps H264 sample so that is great. But I guess that this kills the idea of ever using this computer to play any games which require hardware acceleration to be present and generally an issue for most users who mind not come up with the idea to disable video driver or actually test if it works better that way.

This is my first Pi and I do not use Linux other than on Pi so I do not know if this is expected behavior or not.
Is there a way to configure video driver without input lag? Not having this driver (yes, it is completely unusable as it is!) reduces advertised functionality of this device...
Last edited by e8root on Mon Feb 10, 2020 10:07 pm, edited 1 time in total.

crnewton
Posts: 7
Joined: Wed Dec 18, 2019 11:00 am

Re: [RPi4] Input lag with video driver enabled

Wed Dec 18, 2019 11:10 am

I have the same issue, did you find a solution?

I experience no lagg or latency when I just boot the RPI4 (with latest raspbian buster img)
when I run my python script, which hosts a webservice and serves images from usb webcam,
my keyboard and mouse lagg both. It looks like the usb is being occupied by the usb camera.

I don't have this problem on RPI3, with exactly the same setup.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 25429
Joined: Sat Jul 30, 2011 7:41 pm

Re: [RPi4] Input lag with video driver enabled

Wed Dec 18, 2019 11:56 am

crnewton wrote:
Wed Dec 18, 2019 11:10 am
I have the same issue, did you find a solution?

I experience no lagg or latency when I just boot the RPI4 (with latest raspbian buster img)
when I run my python script, which hosts a webservice and serves images from usb webcam,
my keyboard and mouse lagg both. It looks like the usb is being occupied by the usb camera.

I don't have this problem on RPI3, with exactly the same setup.
What does htop say about CPU utilisation? Sounds like your script is hogging all the CPU's.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“I own the world’s worst thesaurus. Not only is it awful, it’s awful."

crnewton
Posts: 7
Joined: Wed Dec 18, 2019 11:00 am

Re: [RPi4] Input lag with video driver enabled

Wed Dec 18, 2019 2:41 pm

RPI4 htop: https://i.imgur.com/gDFSpJw.png
RPI3 htop: https://i.imgur.com/TdjQyk5.png
looks like my CPU is doing fine, even tho on the rpi4 shows more threads of my .py script

its the same sd card, and on rpi4 my mouse and keyboard lagg, and sometimes key stick. on rpi3 I have no issues.
I use the original powerbrick (with cable) on both the rpi3 and rpi4
adding "dwc_otg.speed=1" to cmdline.txt doesn't make any difference

crnewton
Posts: 7
Joined: Wed Dec 18, 2019 11:00 am

Re: [RPi4] Input lag with video driver enabled

Mon Jan 06, 2020 10:44 am

I found a solution that solves this particulair issue.
the downside is that in my situation it looks like its slowing down my system (rpi).

sudo apt-get install pciutils
sudo setpci -s 01:00.0 0xD4.B=0x41

This will resolve the issue of lagg and key sticking on usb devices (when using a usb webcam).


explaination (from https://linux.die.net/man/8/setpci):
-s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]]

with the tool setpci we write a byte (B) with the value '0x41' to register '0xD4'.
we write to:
domain: 01, bus: 00, slot: 0

I dont know why this value and register, I hope someone can answer that for me.


In my case it resolved the usb lagg & key sticking 100%.

e8root
Posts: 3
Joined: Thu Jul 11, 2019 8:02 am

Re: [RPi4] Input lag with video driver enabled

Mon Feb 10, 2020 10:06 pm

This issue is unrelated to "my" issue but thanks for solution. Just in case I experienced this kind of lag I saved this command in "useful scripts" folder.

The lag I am talking about is constant one frame lag on video when vc4-fkms-v3d is used.
I tested this on 64bit Gentoo and the issue was identical.
Then I borrowed RPi3 from a friend and the behaviour was also identical. Interresingly enough vc4-kms-v3d worked without any lag just like no overlay loaded in framebuffer mode. Fake KMS did have identical lag even on Raspberry Pi 3.

I cannot enable Full KMS driver on my Pi4, there is no setting in raspi-config and enabling it via config.txt results in blank screen soon after module is loaded. Should I install something to make it work?

Or maybe there is some setting I could enable/disable to make Fake KMS not use composition or something which would prevent putting it through additional buffering that causes this lag?

Return to “Troubleshooting”