High cpu usage on youtube

recently I am facing this issue where any youtube video will lag if running at 1080p60 and the cpu usage is at 85% for all cores according to htop. and all this causes the video to buffer the video gets loaded but still buffers.
I have tried this in brave and firefox.
situations are worse in brave .

EDIT: Read the whole disscussion for step by step solution or you can just go to the solution if You are advanced user.

1 Like

Youtube need some resources, you do nothing with it, but cpu usage highly depend on your CPU and GPU. If you have old hardware it’s obvious that usage will be high. Show inxi -Fazy output.

System:
  Kernel: 5.10.59-1-MANJARO x86_64 bits: 64 compiler: gcc v: 11.1.0
  parameters: BOOT_IMAGE=/boot/vmlinuz-5.10-x86_64
  root=UUID=248c4f53-a1ec-45c8-bdbe-4126a41a50da rw quiet apparmor=1
  security=apparmor resume=UUID=1335144a-2dc2-4e7a-96e0-7ef927a3b1fd
  udev.log_priority=3
  Desktop: KDE Plasma 5.22.4 tk: Qt 5.15.2 wm: kwin_x11 vt: 1 dm: SDDM
  Distro: Manjaro Linux base: Arch Linux
Machine:
  Type: Laptop System: LENOVO product: 80UD v: Lenovo ideapad 110-15ISK
  serial: <filter> Chassis: type: 10 v: Lenovo ideapad 110-15ISK
  serial: <filter>
  Mobo: LENOVO model: Lenovo ideapad 1 v: No DPK serial: <filter> UEFI: LENOVO
  v: 1TCN23WW(V2.04) date: 03/06/2017
Battery:
  ID-1: BAT1 charge: 1.1 Wh (7.2%) condition: 15.3/30.1 Wh (50.9%) volts: 14.7
  min: 14.4 model: SANYO PABAS0241231 type: Li-ion serial: <filter>
  status: Charging
CPU:
  Info: Dual Core model: Intel Core i3-6006U bits: 64 type: MT MCP
  arch: Skylake family: 6 model-id: 4E (78) stepping: 3 microcode: EA cache:
  L2: 3 MiB
  flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 vmx
  bogomips: 16006
  Speed: 800 MHz min/max: 400/2000 MHz Core speeds (MHz): 1: 800 2: 800 3: 800
  4: 800
  Vulnerabilities: Type: itlb_multihit status: KVM: VMX disabled
  Type: l1tf
  mitigation: PTE Inversion; VMX: conditional cache flushes, SMT vulnerable
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable
  Type: meltdown mitigation: PTI
  Type: spec_store_bypass
  mitigation: Speculative Store Bypass disabled via prctl and seccomp
  Type: spectre_v1
  mitigation: usercopy/swapgs barriers and __user pointer sanitization
  Type: spectre_v2 mitigation: Full generic retpoline, IBPB: conditional,
  IBRS_FW, STIBP: conditional, RSB filling
  Type: srbds mitigation: Microcode
  Type: tsx_async_abort status: Not affected
Graphics:
  Device-1: Intel Skylake GT2 [HD Graphics 520] vendor: Lenovo driver: i915
  v: kernel bus-ID: 00:02.0 chip-ID: 8086:1916 class-ID: 0300
  Device-2: Acer EasyCamera type: USB driver: uvcvideo bus-ID: 1-5:4
  chip-ID: 5986:06b3 class-ID: 0e02 serial: <filter>
  Display: x11 server: X.Org 1.20.13 compositor: kwin_x11 driver:
  loaded: intel unloaded: modesetting alternate: fbdev,vesa display-ID: :0
  screens: 1
  Screen-1: 0 s-res: 1366x768 s-dpi: 96 s-size: 361x203mm (14.2x8.0")
  s-diag: 414mm (16.3")
  Monitor-1: eDP1 res: 1366x768 hz: 60 dpi: 102 size: 340x190mm (13.4x7.5")
  diag: 389mm (15.3")
  OpenGL: renderer: Mesa Intel HD Graphics 520 (SKL GT2) v: 4.6 Mesa 21.1.6
  direct render: Yes
Audio:
  Device-1: Intel Sunrise Point-LP HD Audio vendor: Lenovo
  driver: snd_hda_intel v: kernel alternate: snd_soc_skl bus-ID: 00:1f.3
  chip-ID: 8086:9d70 class-ID: 0403
  Sound Server-1: ALSA v: k5.10.59-1-MANJARO running: yes
  Sound Server-2: sndio v: N/A running: no
  Sound Server-3: JACK v: 1.9.19 running: no
  Sound Server-4: PulseAudio v: 15.0 running: yes
  Sound Server-5: PipeWire v: 0.3.33 running: yes
Network:
  Device-1: Realtek RTL810xE PCI Express Fast Ethernet vendor: Lenovo
  driver: r8169 v: kernel port: 5000 bus-ID: 01:00.0 chip-ID: 10ec:8136
  class-ID: 0200
  IF: enp1s0 state: up speed: 100 Mbps duplex: full mac: <filter>
  Device-2: Realtek RTL8821AE 802.11ac PCIe Wireless Network Adapter
  vendor: Lenovo driver: rtl8821ae v: kernel port: 4000 bus-ID: 02:00.0
  chip-ID: 10ec:8821 class-ID: 0280
  IF: wlp2s0 state: down mac: <filter>
Bluetooth:
  Device-1: Realtek RTL8821A Bluetooth type: USB driver: btusb v: 0.8
  bus-ID: 1-7:6 chip-ID: 0bda:0821 class-ID: e001 serial: <filter>
  Report: rfkill ID: hci0 rfk-id: 5 state: down bt-service: enabled,running
  rfk-block: hardware: no software: yes address: see --recommends
Drives:
  Local Storage: total: 931.51 GiB used: 47.75 GiB (5.1%)
  SMART Message: Unable to run smartctl. Root privileges required.
  ID-1: /dev/sda maj-min: 8:0 vendor: Western Digital model: WD10JPCX-24UE4T0
  size: 931.51 GiB block-size: physical: 4096 B logical: 512 B speed: 6.0 Gb/s
  type: HDD rpm: 5400 serial: <filter> rev: 1A01 scheme: GPT
Partition:
  ID-1: / raw-size: 421.09 GiB size: 413.41 GiB (98.18%)
  used: 47.72 GiB (11.5%) fs: ext4 dev: /dev/sda6 maj-min: 8:6
  ID-2: /boot/efi raw-size: 100 MiB size: 96 MiB (96.00%)
  used: 25.3 MiB (26.3%) fs: vfat dev: /dev/sda1 maj-min: 8:1
Swap:
  Kernel: swappiness: 60 (default) cache-pressure: 100 (default)
  ID-1: swap-1 type: partition size: 5.86 GiB used: 0 KiB (0.0%) priority: -2
  dev: /dev/sda5 maj-min: 8:5
Sensors:
  System Temperatures: cpu: 37.0 C mobo: N/A
  Fan Speeds (RPM): N/A
Info:
  Processes: 262 Uptime: 2h 59m wakeups: 9 Memory: 11.57 GiB
  used: 4.39 GiB (38.0%) Init: systemd v: 248 tool: systemctl Compilers:
  gcc: 11.1.0 clang: 12.0.1 Packages: 1362 pacman: 1358 lib: 365 flatpak: 4
  Shell: Zsh v: 5.8 running-in: alacritty inxi: 3.3.06

also these are my tlp settings

Cpu energy policy on ac - performance
Cpu energy policy on bat - balance _performance

Browsers don’t support out of the box hardware accelerated video decoding in linux. So, high cpu use is normal with a dual core. If you want somewhat a solution you can download chromium from Pamac. Then in search tab enter chrome://flags >> search Hardware-accelerated-video and enable it. I am also running on integrated graphics and it works most of the time.

2 Likes

Okay so this is a hardware problem , well i noticed some jitterness from the beginning but why only on linux .
Everything is fine on windows side never had such problems :neutral_face:

I know Google stopped Chrome GPU acceleration development.
Didn’t know Mozilla Firefox doesn’t support GPU acceleration too.
Why?
Can it be enabled on Firefox?

Your hardware is much better than mine (and cpu usage on YT is around 30%). Maybe you should enable hardware acceleration in your browser:

Yes, it can be enabled, see tutorial above :wink:

3 Likes

[quote="[HowTo] Enable Hardware Video Acceleration / Video Decode In Google Chrome, Brave, Vivaldi And Opera Browsers, post:1, topic:51895"]
For Brave and Vivaldi:
Since these browsers are not configured to use a user config file like Chrome, you’ll need to enable the flags in chrome://flags:

  • Override software rendering list: chrome://flags/#ignore-gpu-blocklist
  • Use GPU to rasterize web content: chrome://flags/#enable-gpu-rasterization
  • Raster threads write directly to GPU memory associated with tiles: chrome://flags/#enable-zero-copy
    [/quote]

Please help me I am a newbie,
I have done chrome flags settings ,I am using brave. I am unable to understand where to go what to do from the arch wiki :sweat_smile: can You help me to install VA-API driver

Vappi is installed out of the box. @Tina has the best advice for you @shivamChandra65 . Going beyond that is gonna break things.

i dont know how chromium fares, but gChrome has defunct (no more listed) the “hardware-accelerated-video” flag in chrome://flags since ver. 88. now if you need hardware acceleration it need to be explicitly passed as a switch in commandline invoked as in tomek’s post, for it to come into affect. check “media” under “developer tools”.

ex:- chromium --use-gl=desktop --enable-features=VaapiVideoDecoder

therefore it should now be called from shortcut file (.desktop file)

did u get the thing sorted out

No , :frowning_face:
I ran this command :point_down:

brave --use-gl=desktop --enable-features=VaapiVideoDecoder
this is the output

[Thundra  ~]$ brave --use-gl=desktop --enable-features=VaapiVideoDecoder

(brave:31036): Gtk-WARNING **: 18:27:43.237: Theme parsing error: gtk.css:73:46: The style property GtkScrolledWindow:scrollbars-within-bevel is deprecated and shouldn't be used anymore. It will be removed in a future version
Gtk-Message: 18:27:43.313: Failed to load module "appmenu-gtk-module"
Opening in existing browser session.

this does open a new window :point_up:

in Developer tools → media the video decoder name is Vpxdecoder but the cpu usage is still high. and video lags
chrome://gpu shows
Video Decode: Software only. Hardware acceleration disabled

run command;
vainfo

should return something like;

vainfo
vainfo: VA-API version: 1.12 (libva 2.12.0)
vainfo: Driver version: Intel i965 driver for Intel(R) Ivybridge Mobile - 2.4.1
vainfo: Supported profile and entrypoints
VAProfileMPEG2Simple : VAEntrypointVLD
VAProfileMPEG2Simple : VAEntrypointEncSlice
…

if vainfo command is non-existent install libva-utils with command;
sudo pacman -S libva-utils
and run vainfo again

if vainfo returns errors, it means vaapi drivers are not installed,
install intel-media-driver with;
sudo pacman -S intel-media-driver

and run vainfo too see whehter you get the above like results.

EDIT: then run;
brave --use-gl=desktop --enable-features=VaapiVideoDecoder

thank You man It did work when I launched new browser with this command :point_up: ,
But how do I make it permanent as soon as I closed that instance of brave chrome://gpu again shows
Video Decode: Software only. Hardware acceleration disabled

Also these were the errors I got when ran the command

[Thundra  ~]$ brave --use-gl=desktop --enable-features=VaapiVideoDecoder

(brave:40965): Gtk-WARNING **: 07:26:41.837: Theme parsing error: gtk.css:73:46: The style property GtkScrolledWindow:scrollbars-within-bevel is deprecated and shouldn't be used anymore. It will be removed in a future version
Gtk-Message: 07:26:41.915: Failed to load module "appmenu-gtk-module"
[40999:40999:0824/072642.275903:ERROR:gpu_init.cc(441)] Passthrough is not supported, GL is desktop
[40999:40999:0824/072642.348228:ERROR:sandbox_linux.cc(374)] InitializeSandbox() called with multiple threads in process gpu-process.
[40965:40965:0824/072713.616446:ERROR:CONSOLE(1)] "[Shields]: Can't request shields panel data. Error: No tab url specified", source: chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/out/brave_extension_background.bundle.js (1)
[40965:40965:0824/072713.629622:ERROR:CONSOLE(1)] "[Shields]: Can't request shields panel data. Error: No tab url specified", source: chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/out/brave_extension_background.bundle.js (1)
[40965:40965:0824/072836.733172:ERROR:CONSOLE(1)] "[Shields]: Can't request shields panel data. Error: No tab url specified", source: chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/out/brave_extension_background.bundle.js (1)
[40965:40965:0824/072836.734349:ERROR:CONSOLE(1)] "[Shields]: Can't request shields panel data. Error: No tab url specified", source: chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/out/brave_extension_background.bundle.js (1)
[40965:40965:0824/073002.605856:ERROR:CONSOLE(1)] "[Shields]: Can't request shields panel data. Error: No tab url specified", source: chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/out/brave_extension_background.bundle.js (1)
[40965:40965:0824/073002.606946:ERROR:CONSOLE(1)] "[Shields]: Can't request shields panel data. Error: No tab url specified", source: chrome-extension://mnojpmjdmbbfmejpflffifhffcmidifd/out/brave_extension_background.bundle.js (1)

no worries, disregard the errors. none of those are even close to critical.

  1. run command;

ls ~/.local/share/applications/*brave*.desktop

if this returns a file, skip to (3) note: treat it as name and path of file from hereon

  1. if the above command returns no files, run commands;

cp /usr/share/applications/*brave*.desktop ~/.local/share/applications/
and
chown $USER:$USER ~/.local/share/applications/*brave*.desktop
and
ls ~/.local/share/applications/*brave*.desktop

  1. the last command gets you the name and path of the file desktop (shortcut) file. so open it in a file editor.

kate <path-and-name-of-file>

find lines starting with “Exec=”, and append " --enable-features=VaapiVideoDecoder" at the end on all occurrences. also add " --use-gl=desktop" if it is not already there, and save the file

should be working with the menu shortcut now, if not logout-login, worse restart.

Thank You worked without a restart :smiley:
The community support in Manjaro is awesome.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.