# Solved: Mouse lag problem



## Jakeotr (Apr 2, 2014)

I'm a new FreeBSD (10) user, but a long time Linux user. I am trying out FreeBSD in earnest (systemd is pushing the wrong buttons with me, and I hope more Linux users come aboard). I have a problem though with mouse issues. Reasonably sure it is hardware but not sure how to test. Hardware is:


Asus Sabretooth 990 FX motherboard
AMD FX-8350
Samsung 840 pro SSD
Nvidia ge660
The mouse lags/hangs in Firefox (w & w/o with and without safe-mode) or Opera, though occasionally in other software. I am using a Logitech wireless mouse/keyboard combo, but I have tried various other USB mice (can't get a PS/2 to work) and keyboards. I have loaded FreeBSD on an older computer (Gigabyte board, AMD Phenom CPU) and it does not have this problem. I have also installed FreeBSD 9.2 and 10 in VirtualBox on a Linux install on this same machine and noticed the same behavior (only not to the same degree). I have tried hald, and moused settings, checked the logs, watched `top`, but I can*'*t see anything unusual. Any terminal window I can watch while this behavior is going on? Any ideas on what direction to look would be appreciated as this is not workable. Thanks


----------



## wblock@ (Apr 2, 2014)

Please show your xorg.conf.  My first guess is AllowEmptyInput: AllowEmptyInput, FreeBSD, and Xorg Input.


----------



## Jakeotr (Apr 2, 2014)

I can post xorg.conf later this evening, and any other log info, but I have already tried it both on and off. Thanks to your guide (which is awesome BTW, thank you).


----------



## Jakeotr (Apr 2, 2014)

Just for more info: I have set the AHCI driver to load at boot (on and off) after having a constant error for a bad DVD drive, I have unplugged all USB peripherals except for keyboard/mouse, and turned off USB 3.0 in the BIOS. I have tried letting HAL configure keyboard/mouse and shutting it off in Xorg with 
	
	



```
Option "AutoAddDevices" "Off"
```
 Thanks


----------



## Jakeotr (Apr 3, 2014)

Here is my xorg.conf

```
Section "ServerLayout"
	Identifier     "X.org Configured"
	Screen      0  "Screen0" 0 0
#	InputDevice    "Mouse0" "CorePointer"
#	InputDevice    "Keyboard0" "CoreKeyboard"
#       Option "AllowEmptyInput" "Off"        
#        Option "AutoAddDevices" "Off"
EndSection

Section "Files"
	ModulePath   "/usr/local/lib/xorg/modules"
	FontPath     "/usr/local/lib/X11/fonts/misc/"
	FontPath     "/usr/local/lib/X11/fonts/TTF/"
	FontPath     "/usr/local/lib/X11/fonts/OTF"
	FontPath     "/usr/local/lib/X11/fonts/Type1/"
	FontPath     "/usr/local/lib/X11/fonts/100dpi/"
	FontPath     "/usr/local/lib/X11/fonts/75dpi/"
        FontPath     "/usr/local/lib/X11/fonts/dejavu"
EndSection

Section "Module"
	Load  "dbe"
	Load  "dri"
	Load  "dri2"
	Load  "extmod"
	Load  "record"
	Load  "glx"
        Load  "freetype"
EndSection

#Section "InputDevice"
#	Identifier  "Keyboard0"
#	Driver      "kbd"
#EndSection

#Section "InputDevice"
#	Identifier  "Mouse0"
#	Driver      "mouse"
#	Option	    "Protocol" "SysMouse"
#	Option	    "Device" "/dev/sysmouse"
#	Option	    "ZAxisMapping" "4 5 6 7"
#EndSection

Section "Monitor"
	Identifier   "Monitor0"
	VendorName   "Monitor Vendor"
	ModelName    "Monitor Model"
EndSection

Section "Device"
        ### Available Driver options are:-
        ### Values: <i>: integer, <f>: float, <bool>: "True"/"False",
        ### <string>: "String", <freq>: "<f> Hz/kHz/MHz"
        ### [arg]: arg optional
        #Option     "SWcursor"           	# [<bool>]
        #Option     "HWcursor"           	# [<bool>]
        #Option     "NoAccel"            	# [<bool>]
        #Option     "ShadowFB"           	# [<bool>]
        #Option     "UseFBDev"           	# [<bool>]
        #Option     "Rotate"             	# [<str>]
        #Option     "VideoKey"           	# <i>
        #Option     "FlatPanel"          	# [<bool>]
        #Option     "FPDither"           	# [<bool>]
        #Option     "CrtcNumber"         	# <i>
        #Option     "FPScale"            	# [<bool>]
        #Option     "FPTweak"            	# <i>
        #Option     "DualHead"           	# [<bool>]
	Identifier  "Card0"
	Driver      "nvidia"
	VendorName  "NVIDIA Corporation"
	BoardName   "GK106 [GeForce GTX 660]"
	BusID       "PCI:1:0:0"
EndSection

Section "Screen"
	Identifier "Screen0"
	Device     "Card0"
	Monitor    "Monitor0"
#	SubSection "Display"
#		Viewport   0 0
#		Depth     1
#	EndSubSection
#	SubSection "Display"
#		Viewport   0 0
#		Depth     4
#	EndSubSection
#	SubSection "Display"
#		Viewport   0 0
#		Depth     8
#	EndSubSection
#	SubSection "Display"
#		Viewport   0 0
#		Depth     15
#	EndSubSection
#	SubSection "Display"
#		Viewport   0 0
#		Depth     16
#	EndSubSection
	SubSection "Display"
		Viewport   0 0
		Depth     24
	EndSubSection
EndSection
```


----------



## wblock@ (Apr 3, 2014)

AHCI only affects disks.  That DVD error is probably not an error, just showing there is no disk in the drive.  Does a corded mouse have the same problems as the wireless one?  For a USB mouse, it is not necessary to enable moused.


----------



## Jakeotr (Apr 3, 2014)

Warren, thanks for the reply. Corded mouse does not make a difference. It seems moused was enabled from installation, and when I kill it the mouse stops working. Interestingly I just installed PC-BSD on another drive and under KDE in Konqueror it seems like the problem is lessened. Firefox under KDE or Mate is still very stuttery. Could being a GTK application have something to do with it? (time passes)  Although it seems other KDE applications are affected as well. Where I see it most is in menu bar drop downs. I saw another similar post to menus being slow but it seemed the problem was KDE pulling in a GTK .rc file. Nearly all my hardware is new, could I just the perfect combination to create a problem?


----------



## wblock@ (Apr 3, 2014)

The hardware should be fine, although I can't speak for the Nvidia card.  Still, the video card should not affect mouse movement.

With a default install of X, twm(1) should be included.  Try that instead of KDE to see if the mouse problems are present in both.


----------



## Jakeotr (Apr 4, 2014)

Looks like the same behavior under twm, not as bad, but maybe that*'*s owing to its smaller footprint?  I don*'*t think it*'*s a resource issue as I have fast CPU and 8 GB RAM. I just wonder if something is interrupting the USB system, because it will happen for a few seconds and then be fine for 10-15 secondss. Is there anything more fine grained than top to watch system functions/processes? BTW I dual boot this with Linux Mint and no problem there. I also see no stuttering on the root window or terminals.


----------



## wblock@ (Apr 4, 2014)

That's a very fast system which should have no problems at all.  It's worth turning off legacy USB emulation in the BIOS.  If that does not help, please post your /etc/rc.conf and /boot/loader.conf.


----------



## Jakeotr (Apr 5, 2014)

I can't shut off the USB system completely as I need it for mouse/keyboard, but I've shut off all ports not needed. I'm going to try to get PS/2 port working today, although it doesn't work in Linux either...so it may be bad. 
/boot/loader.conf 

```
nvidia_load="YES"
ahci_load="YES"
```

/etc/rc.conf

```
hostname="godzilla"
ifconfig_re0="DHCP"
sshd_enable="YES"
ntpd_enable="YES"
# Set dumpdev to "AUTO" to enable crash dumps, "NO" to disable
dumpdev="AUTO"
hald_enable="YES"
dbus_enable="YES"
linux_enable="YES"
moused_enable="YES"
```


----------



## wblock@ (Apr 5, 2014)

Legacy USB emulation is a BIOS setting that allows using a PS/2 keyboard in the BIOS.  It sometimes interferes with normal use after booting.


----------



## Jakeotr (Apr 5, 2014)

Shutting off legacy USB doesn*'*t work either, probably a good thing as I dual boot, and GRUB can*'*t cope with my USB keyboard when legacy is off.


----------



## Jakeotr (Apr 8, 2014)

Enabling IOMMU in the BIOS has helped the mouse lag problem quite a bit. It still happens once in a while, but it*'*s much better. I don*'*t understand completely what IOMMU is supposed to do; apparently it remaps memory for devices that can*'*t go above a certain limit, but I'm not sure how it has helped me. Maybe someone with more knowledge of this can suggest the reason why it*'*s happening or maybe some way to tune it even farther.


----------



## Jakeotr (Dec 1, 2014)

Answering my own issue in case anyone*'*s in the same place: never did figure out the problem (the above did not work BTW), but after upgrading to 10.1 no problems. So, for what it*'*s worth.


----------

