Score:6

Hardware acceleration chrome+youtube?

in flag

I am having an issue watching hd (720 or 1080) videos on Ubuntu 21.04 fresh install. I get really high cpu usage (50% on all cores) which is pretty high for a 720p vid. I tried watching the same video on vlc (hw acceleration) and it works perfectly fine. I even tried a 4k video and it works fine cpu usage < 20%. Why is chrome consuming so much cpu?

flags enabled: enter image description here

Here is what I have tried: sudo apt install intel-media-va-driver

CPU usage on vlc with 4k video h265, vlc is on second line, gnome for some reason takes a HUGE screenshot (6MB, had to compress): enter image description here

CPU usage chrome + youtube: enter image description here Stats for nerds: enter image description here

On my laptop I have an intel cpu:

lscpu
Architecture:                    x86_64
CPU op-mode(s):                  32-bit, 64-bit
Byte Order:                      Little Endian
Address sizes:                   39 bits physical, 48 bits virtual
CPU(s):                          8
On-line CPU(s) list:             0-7
Thread(s) per core:              2
Core(s) per socket:              4
Socket(s):                       1
NUMA node(s):                    1
Vendor ID:                       GenuineIntel
CPU family:                      6
Model:                           142
Model name:                      Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Stepping:                        11
CPU MHz:                         2000.000
CPU max MHz:                     4600.0000
CPU min MHz:                     400.0000
BogoMIPS:                        3999.93
Virtualization:                  VT-x
L1d cache:                       128 KiB
L1i cache:                       128 KiB
L2 cache:                        1 MiB
L3 cache:                        8 MiB
NUMA node0 CPU(s):               0-7
Vulnerability Itlb multihit:     KVM: Mitigation: VMX disabled
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled v
                                 ia prctl and seccomp
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user
                                  pointer sanitization
Vulnerability Spectre v2:        Mitigation; Full generic retpoline, IBPB condit
                                 ional, IBRS_FW, STIBP conditional, RSB filling
Vulnerability Srbds:             Mitigation; Microcode
Vulnerability Tsx async abort:   Not affected
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtr
                                 r pge mca cmov pat pse36 clflush dts acpi mmx f
                                 xsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rd
                                 tscp lm constant_tsc art arch_perfmon pebs bts 
                                 rep_good nopl xtopology nonstop_tsc cpuid aperf
                                 mperf pni pclmulqdq dtes64 monitor ds_cpl vmx e
                                 st tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_
                                 1 sse4_2 x2apic movbe popcnt tsc_deadline_timer
                                  aes xsave avx f16c rdrand lahf_lm abm 3dnowpre
                                 fetch cpuid_fault epb invpcid_single ssbd ibrs 
                                 ibpb stibp tpr_shadow vnmi flexpriority ept vpi
                                 d ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi
                                 2 erms invpcid mpx rdseed adx smap clflushopt i
                                 ntel_pt xsaveopt xsavec xgetbv1 xsaves dtherm i
                                 da arat pln pts hwp hwp_notify hwp_act_window h
                                 wp_epp md_clear flush_l1d arch_capabilities

I have enabled hw acceleration on chrome:

Graphics Feature Status
Canvas: Hardware accelerated
Compositing: Hardware accelerated
Multiple Raster Threads: Enabled
Out-of-process Rasterization: Hardware accelerated
OpenGL: Enabled
Rasterization: Hardware accelerated
Skia Renderer: Enabled
Video Decode: Hardware accelerated
Vulkan: Enabled
WebGL: Hardware accelerated
WebGL2: Hardware accelerated
Driver Bug Workarounds
adjust_src_dst_region_for_blitframebuffer
clear_uniforms_before_first_program_use
count_all_in_varyings_packing
decode_encode_srgb_for_generatemipmap
enable_webgl_timer_query_extensions
exit_on_context_lost
msaa_is_slow
disabled_extension_GL_KHR_blend_equation_advanced
disabled_extension_GL_KHR_blend_equation_advanced_coherent
Problems Detected
Clear uniforms before first program use on all platforms: 124764, 349137
Applied Workarounds: clear_uniforms_before_first_program_use
Mesa drivers in Linux handle varyings without static use incorrectly: 333885
Applied Workarounds: count_all_in_varyings_packing
On Intel GPUs MSAA performance is not acceptable for GPU rasterization: 527565
Applied Workarounds: msaa_is_slow
adjust src/dst region if blitting pixels outside framebuffer on Linux Intel: 664740
Applied Workarounds: adjust_src_dst_region_for_blitframebuffer
Disable KHR_blend_equation_advanced until cc shaders are updated: 661715
Applied Workarounds: disable(GL_KHR_blend_equation_advanced), disable(GL_KHR_blend_equation_advanced_coherent)
Decode and Encode before generateMipmap for srgb format textures on Linux Mesa ANGLE path: 634519
Applied Workarounds: decode_encode_srgb_for_generatemipmap
Expose WebGL's disjoint_timer_query extensions on platforms with site isolation: 808744, 870491
Applied Workarounds: enable_webgl_timer_query_extensions
Some drivers can't recover after OUT_OF_MEM and context lost: 893177
Applied Workarounds: exit_on_context_lost
ANGLE Features
allow_compressed_formats (Frontend workarounds): Enabled: true
Allow compressed formats
disable_anisotropic_filtering (Frontend workarounds): Disabled
Disable support for anisotropic filtering
disable_program_binary (Frontend features) anglebug:5007: Disabled: 
<SNIP!>
...
<SNIP!>
Device Performance Information
Log Messages
[17135:17135:1001/094454.627605:ERROR:sandbox_linux.cc(374)] : InitializeSandbox() called with multiple threads in process gpu-process.
[17135:17135:1001/094454.630728:ERROR:vulkan_device_queue.cc(217)] : Vulkan: Intel(R) UHD Graphics 620 (WHL GT2)

EDIT:

Okay, this may be something more deep than I originally thought. Ubuntu has performance settings powersave, balanced, and performance. Setting it to performance works great and everything seems normal. But checking the governer:

sudo apt-get install cpufrequtils

Check the governer cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor powersave powersave powersave powersave powersave powersave powersave powersave

I set the governer to performance and now it looks to be working much better:

sudo nano /etc/default/cpufrequtils

and setting:

GOVERNOR="performance"

Then restarting the service

sudo systemctl restart cpufrequtils

EDIT 2: Following along with what Michal Przybylowicz said, it looks like the decoder is not a hardware decoder? What is going on here? Why isnt chome or ubuntu using the hardware decoder? enter image description here

EDIT 2.5: Here is the output of vainfo:

vainfo
libva info: VA-API version 1.10.0
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_10
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.10 (libva 2.10.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 21.1.1 ()
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSliceLP
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSliceLP
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD

Edit 3: after trying to run it with --enable-features=VaapiVideoDecoder I got:

google-chrome --enable-features=VaapiVideoDecoder
MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0

[11790:11790:1003/113422.312061:ERROR:sandbox_linux.cc(374)] InitializeSandbox() called with multiple threads in process gpu-process.
[11790:11790:1003/113422.314845:ERROR:vulkan_device_queue.cc(217)] Vulkan: Intel(R) UHD Graphics 620 (WHL GT2)
Fontconfig error: Cannot load default config file: No such file: (null)
Fontconfig error: Cannot load default config file: No such file: (null)
Fontconfig error: Cannot load default config file: No such file: (null)
Fontconfig error: Cannot load default config file: No such file: (null)
Fontconfig error: Cannot load default config file: No such file: (null)

and whats up with this issue:

MESA-INTEL: warning: Performance support disabled, consider sysctl dev.i915.perf_stream_paranoid=0

I also saw this when loading retroarch, I tried launching chrome after setting sysctl dev.i915.perf_stream_paranoid=0 and it made no change, still sw decoder.

It looks like others have been having the same issue: https://www.reddit.com/r/chrome/comments/n6qywt/hardware_acceleration_fail_in_chrome_on_linux/

us flag
Could you check if firefox also consumes that much CPU?
in flag
@ArchismanPanigrahi firefox is exactly the same 40+% cpu
hu flag
Are you sure h265 is used by youtube? Last time I checked, there were VC1, VP9 and AVC. Now your screenshots lack youtube's "stats for nerds", or links, so I can only guess it pays a VC1 video, which needs newer hardware.
in flag
I never said h265 was used by yt, but rather h265 is being used by vlc (the video is encoded in h265). How can I check if it plays a vc1 (or any other codec?)
in flag
@mikewhatever I added a screenshot with stats for nerds
hu flag
Well, it says AVC1, aka h264, which is supported by your hardware.
in flag
@mikewhatever exactly, why could the browser be consuming so much cpu. Any ideas?
hu flag
Not sure. I am not a big fan of Chrome, so let's see what others have to say.
Michal Przybylowicz avatar
eg flag
To verify if Hardware Video Acceleration actually works open Dev Tools -> (three dots) -> More Tools -> Media. Now open Media tab click on video that is currently being played and check "Decoder Name" should be "VDAVideoDecoder" and "Hardware decoder" should be "true".
in flag
@MichalPrzybylowicz I dont see this menu? Where is dev tools? On chome to get to developer tools you need to click on 3 dots first.
Michal Przybylowicz avatar
eg flag
Click F12 or use right mouse click and "inspect". This will open a panel called developer tools.
in flag
@MichalPrzybylowicz I have updated the question. Looks like you had a good hunch, decoder is not hw
Michal Przybylowicz avatar
eg flag
@Kevin Can You also update Your question with the output of `vainfo` command.
Michal Przybylowicz avatar
eg flag
@Kevin Run the browser from command line with this parameter and see if that changes anything `--enable-features=VaapiVideoDecoder`.
in flag
@MichalPrzybylowicz just tried it, gave similar error when I tried retroarch.
Michal Przybylowicz avatar
eg flag
@Kevin Read through this [article](https://www.linuxuprising.com/2021/01/how-to-enable-hardware-accelerated.html) and see if something is missing on Your installation.
in flag
@MichalPrzybylowicz Looks like its still broken? I tried the site and nothing worked. Found this: https://www.reddit.com/r/chrome/comments/n6qywt/hardware_acceleration_fail_in_chrome_on_linux/ others having same issue
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.