Ubuntu – Bluetooth mouse lags after upgrading to 18.10 Cosmic

18.10bluetoothcanonical-livepatchmouse

Initially, there was no issue in the first few days after upgrading to 18.10 Cosmic (from 18.04 Bionic), even after suspend/restart/shutdown.

Today, after waking from suspend, the bluetooth mouse started to lag. If I left it stationary for 5 seconds, it would take 2 seconds of constant movement before pointer can move. It seemed to switch to sleep mode after just 5 seconds.

I tried:

  1. scan off in bluetoothctl (the command failed to run anyway).
  2. Re-modprobe the btusb.
  3. sudo sh -c 'echo N > /sys/module/drm_kms_helper/parameters/poll'
  4. tlp and powertop are not installed.

Best Answer

Remove canonical-livepatch which is supported in LTS releases only, i.e. not supported in 18.10.

To remove,

$ sudo snap remove canonical-livepatch

I previously had an issue was also (partially) caused by the package.

Edit: the issue resurface again. Installing powertop without any config somehow resolve it.

$ sudo apt install powertop

Edit: USB autosuspend is probably the cause.

  1. Launch powertop using sudo powertop.
  2. Keep pressing Tab till you reach the "Tunables" section.
  3. Find your mouse in that list "Autosuspend for USB device...". Mine is "Autosuspend for unknown USB device 2-6 (8087-07dc)".
  4. "Good" status means autosuspend is on. Fix this issue by toggling to "Bad", by pressing "Enter". Continue the reset of the steps to re-apply the setting after reboot/suspend.
  5. A command will shows up on Terminal,

    >> echo 'on' > /usr/bus/usb/devices/2-6/power/control';

  6. Note down the command.

  7. Create a shell script in /usr/bin/.

    $ sudo pluma /usr/bin/disable-bt-mouse-autosuspend

  8. Paste the following:

#!/bin/sh

# Disable USB auto-suspend for my mouse on startup
sleep 5;
MOUSE="/sys/bus/usb/devices/2-6/power/control";
if [ -f "$MOUSE" ]; then
    echo 'on' > $MOUSE;
fi
  1. Change 2-6 to what you got from powertop in Step 5.
  2. Make the script executable.

    $ sudo chmod u+x /usr/bin/disable-bt-mouse-autosuspend

  3. Add disable-bt-mouse-autosuspend to systemd.

    $ sudo pluma /etc/systemd/system/disable-bt-mouse-autosuspend.service

  4. Paste the following,

[Unit]
Description=Disable USB auto-suspend for bluetooth mouse

[Service]
ExecStart=/usr/bin/disable-bt-mouse-autosuspend

[Install]
WantedBy=multi-user.target
  1. Save it. Start and enable it.

    $ sudo systemctl start disable-bt-mouse-autosuspend

    $ sudo systemctl enable disable-bt-mouse-autosuspend

  2. The setting will also reset during suspend. To re-apply it:

    $ sudo pluma /lib/systemd/system-sleep/00disable-bt-mouse-autosuspend

  3. Paste the following script and save it,

#!/bin/sh

# restart the service after suspend
if [ $1 = post ] && [ $2 = suspend ]
then systemctl start disable-bt-mouse-autosuspend.service
fi
  1. Set executable permission,

    $ sudo chmod u+x /lib/systemd/system-sleep/00disable-bt-mouse-autosuspend

Related Question