Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'm running a fresh install of Xubuntu 12.04 and I'd like to know how can I activate my nVidia card's GPU acceleration inside the latest stable Chromium. I wanted to play an MP4 file without the CPU firing to 100%.

I've installed mplayer and vdpau (and they work fine), but so far I haven't been able to use them inside Chromium. A couple of years ago, I used gecko-mediaplayer but the plugin's been blacklisted...

Any ideas?

Here's the output of glxinfo | grep render:

direct rendering: Yes
OpenGL renderer string: GeForce GT 520M/PCIe/SSE2
    GL_NV_blend_square, GL_NV_compute_program5, GL_NV_conditional_render, 
    GL_NV_parameter_buffer_object2, GL_NV_path_rendering, 
    GL_NVX_conditional_render, GL_NVX_gpu_memory_info, 

and here's the output of lspci | grep -i vga:

02:00.0 VGA compatible controller: NVIDIA Corporation GF119 [GeForce GT 520M] (rev a1)

Chromium is churning out a lot of warnings whenever I open the page, as you can see here and I've just found out a promising lead, lost in a sea of performance warnings:

NVIDIA: could not open the device file /dev/nvidia0 (Operation not permitted).

After adding the user to the video group, Chromium is now unable to play MP4's at all (yup, not even using the CPU). I got the same error messages as before, but a new one popped up as well:

[4296:4296:0827/100001:ERROR:gpu_video_decode_accelerator.cc(208)] Not implemented reached in void content::GpuVideoDecodeAccelerator::Initialize(media::VideoCodecProfile, IPC::Message*)**HW video decode acceleration not available**.
share|improve this question
    
Why does your CPU usage rise to 100%? Even without any HWA (no GPU), I can play mp4 videos through Google Chrome and the CPU usage is < 20%. –  user25656 Aug 23 '13 at 16:52
3  
1080p videos on a 4 year old, 300$ computer. –  Hal Aug 26 '13 at 8:32

2 Answers 2

up vote 5 down vote accepted
+100

TL;DR: Unless you have tried everything below and now you get a black screen hitting this particular fixed bug, your problem should be solved by now. If you now get:

ERROR:gpu_video_decode_accelerator.cc(208)] Not implemented reached in void content::GpuVideoDecodeAccelerator::Initialize(media::VideoCodecProfile, IPC::Message\*) HW video decode acceleration not available.

after trying everything below, then you should try starting Chrome/ium with --disable-gpu-sandbox or --blacklist-accelerated-compositing. If problems persists, revert all changes and report a bug detailing what is your problem, what have you tried, and all the data possible: about:gpu, about:version, the drivers you are using, kernel version, etc. For the ones that still want to test their luck, use the switch mentioned earlier, does that are having issues with AMD cards, the "Forcing Chrome/ium to use HWA" section works for you. Those using Nvidia privatives drivers or the xorg-ppa-edge, should test with Firefox and see if the issue happens there too.

Nvidia permissions problems

NVIDIA: could not open the device file /dev/nvidia0 (Operation not permitted).

This means that you are not part of the video group. This is solved as easy as you could be:

sudo adduser Hal video

Then restart your session and you are there.

Source: http://forums.gentoo.org/viewtopic-p-7232328.html?sid=900a2d59cdb52e1a5f530598dfa1be24#7232328

Forcing Chrome/ium to use HWA

You should check your about:gpu section in Chrome/ium. In older PC's HW Acceleration is disabled by default and you only can enable it by overriding the settings in the about:flags.

  • Open the about:flags in your address bar
  • Look for Override software redendering list
  • Click "Enable"
  • Restart Chrome/ium

You can also start chrome using chrome --ignore-gpu-blacklist but having to do so each time is not ideal.

This is my GPU page

THis is my flags

share|improve this answer
1  
Well, I enabled the "override software rendering list" in chrome://gpu, reopened chromium and opened a local page containing an HTML5 embed video tag (the source is an MP4) but the CPU is still doing well over 100%. Then, I installed gecko-mediaplayer, rebooted and reopened chromium with the ignore blacklist parameter but no such luck as well. Any other ideas? My graphic features status is identical to yours. –  Hal Aug 23 '13 at 16:09
    
I'm not sure if video decoding is actually working. I'm running Chrome 29 on Ubuntu 12.04 and I see "Accelerated video decode is unavailable on Mac and Linux.: 137247, 133828", so I'm surprised to see you got it to "Hardware Accelerated". –  gertvdijk Aug 26 '13 at 10:43
    
Now, if only we could make Chromium put his money where his mouth is... –  Hal Aug 26 '13 at 11:23
1  
@Braiam Sorry if I wasn't really clear - it shows it for me as well, but it seems it isn't working as shown in the "problems detected" output (when disabled forcing options). See also the bug report (code.google.com/p/chromium/issues/detail?id=137247) –  gertvdijk Aug 26 '13 at 13:06
1  
@gertvdijk Yeah, I've seen that report before. Actually is a pretty darn dumb policy: We don't like bug reports, so we (really) slowly activate the cards we believe don't have problems (which are the minority) and leave the users that have cards that might work just fine run with just 0.1% of their real performance. –  Braiam Aug 26 '13 at 19:29

Solution for Video Decoding on linux/chromium :

GpuVideoDecodeAccelerator function has been disabled in the chromium linux code for few months (except for ChromiumOS obviously) so you'll have to patch chromium like this :

https://bazaar.launchpad.net/~saiarcot895/chromium-browser/chromium-browser.utopic.beta/view/head:/debian/patches/enable_vaapi_on_linux.diff

or use this great PPA :

https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-beta

Tested with libva on Intel SandyBridge for H264, works great. Don't know about VP8.

As requested here is the Full Patch :

Index: beta.vivid/content/common/gpu/media/gpu_video_decode_accelerator.cc
===================================================================
--- beta.vivid.orig/content/common/gpu/media/gpu_video_decode_accelerator.cc    2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/common/gpu/media/gpu_video_decode_accelerator.cc 2014-12-04 09:32:45.341607169 -0500
@@ -31,7 +31,7 @@
 #elif defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) && defined(USE_X11)
 #include "content/common/gpu/media/v4l2_video_decode_accelerator.h"
 #include "content/common/gpu/media/v4l2_video_device.h"
-#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11)
+#elif (defined(OS_CHROMEOS) || defined(OS_LINUX)) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11)
 #include "content/common/gpu/media/vaapi_video_decode_accelerator.h"
 #include "ui/gl/gl_context_glx.h"
 #include "ui/gl/gl_implementation.h"
@@ -272,7 +272,7 @@
       make_context_current_,
       device.Pass(),
       io_message_loop_));
-#elif defined(OS_CHROMEOS) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11)
+#elif (defined(OS_CHROMEOS) || defined(OS_LINUX)) && defined(ARCH_CPU_X86_FAMILY) && defined(USE_X11)
   if (gfx::GetGLImplementation() != gfx::kGLImplementationDesktopGL) {
     VLOG(1) << "HW video decode acceleration not available without "
                "DesktopGL (GLX).";
Index: beta.vivid/content/content_common.gypi
===================================================================
--- beta.vivid.orig/content/content_common.gypi 2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/content_common.gypi  2014-12-04 09:32:45.341607169 -0500
@@ -769,7 +769,7 @@
         '<(DEPTH)/third_party/khronos',
       ],
     }],
-    ['target_arch != "arm" and chromeos == 1 and use_x11 == 1', {
+    ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1) and use_x11 == 1', {
       'dependencies': [
         '../media/media.gyp:media',
         '../third_party/libyuv/libyuv.gyp:libyuv',
Index: beta.vivid/content/content_gpu.gypi
===================================================================
--- beta.vivid.orig/content/content_gpu.gypi    2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/content_gpu.gypi 2014-12-04 09:32:45.341607169 -0500
@@ -40,7 +40,7 @@
         ],
       },
     }],
-    ['target_arch!="arm" and chromeos == 1', {
+    ['target_arch!="arm" and (chromeos == 1 or desktop_linux == 1)', {
       'include_dirs': [
         '<(DEPTH)/third_party/libva',
       ],
Index: beta.vivid/content/content_tests.gypi
===================================================================
--- beta.vivid.orig/content/content_tests.gypi  2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/content_tests.gypi   2014-12-04 09:32:45.342607150 -0500
@@ -1556,7 +1556,7 @@
           },
         ]
     }],
-    ['chromeos==1 and use_x11 == 1 and target_arch != "arm"', {
+    ['(chromeos==1 or desktop_linux==1) and use_x11 == 1 and target_arch != "arm"', {
       'targets': [
           {
             'target_name': 'vaapi_h264_decoder_unittest',
Index: beta.vivid/content/public/common/content_switches.cc
===================================================================
--- beta.vivid.orig/content/public/common/content_switches.cc   2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/public/common/content_switches.cc    2014-12-04 09:32:45.342607150 -0500
@@ -930,7 +930,7 @@
 // Disable web audio API.
 const char kDisableWebAudio[]               = "disable-webaudio";

-#if defined(OS_CHROMEOS)
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
 // Disables panel fitting (used for mirror mode).
 const char kDisablePanelFitting[]           = "disable-panel-fitting";

Index: beta.vivid/content/public/common/content_switches.h
===================================================================
--- beta.vivid.orig/content/public/common/content_switches.h    2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/public/common/content_switches.h 2014-12-04 09:32:45.342607150 -0500
@@ -268,7 +268,7 @@

 CONTENT_EXPORT extern const char kDisableWebAudio[];

-#if defined(OS_CHROMEOS)
+#if defined(OS_CHROMEOS) || defined(OS_LINUX)
 CONTENT_EXPORT extern const char kDisablePanelFitting[];
 CONTENT_EXPORT extern const char kDisableVaapiAcceleratedVideoEncode[];
 #endif
Index: beta.vivid/media/media.gyp
===================================================================
--- beta.vivid.orig/media/media.gyp 2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/media/media.gyp  2014-12-04 09:32:45.342607150 -0500
@@ -672,7 +672,7 @@
           ],
         }],
         # For VaapiVideoEncodeAccelerator.
-        ['target_arch != "arm" and chromeos == 1 and use_x11 == 1', {
+        ['target_arch != "arm" and (chromeos == 1 or desktop_linux == 1) and use_x11 == 1', {
           'sources': [
             'filters/h264_bitstream_buffer.cc',
             'filters/h264_bitstream_buffer.h',
Index: beta.vivid/gpu/config/software_rendering_list_json.cc
===================================================================
--- beta.vivid.orig/gpu/config/software_rendering_list_json.cc  2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/gpu/config/software_rendering_list_json.cc   2014-12-04 09:32:45.343607131 -0500
@@ -508,8 +508,8 @@
     },
     {
       "id": 48,
-      "description": "Accelerated video decode is unavailable on Mac and Linux",
-      "cr_bugs": [137247, 133828],
+      "description": "Accelerated video decode is unavailable on Mac",
+      "cr_bugs": [133828],
       "exceptions": [
         {
           "os": {
@@ -525,6 +525,11 @@
           "os": {
             "type": "android"
           }
+        },
+        {
+          "os": {
+            "type": "linux"
+          }
         }
       ],
       "features": [
Index: beta.vivid/content/common/sandbox_linux/bpf_gpu_policy_linux.cc
===================================================================
--- beta.vivid.orig/content/common/sandbox_linux/bpf_gpu_policy_linux.cc    2014-12-04 09:32:45.344607112 -0500
+++ beta.vivid/content/common/sandbox_linux/bpf_gpu_policy_linux.cc 2014-12-04 09:32:45.343607131 -0500
@@ -21,6 +21,8 @@
 #include "base/logging.h"
 #include "base/memory/scoped_ptr.h"
 #include "build/build_config.h"
+// Auto-generated for dlopen libva libraries
+#include "content/common/gpu/media/va_stubs.h"
 #include "content/common/sandbox_linux/sandbox_bpf_base_policy_linux.h"
 #include "content/common/sandbox_linux/sandbox_seccomp_bpf_linux.h"
 #include "content/common/set_process_title.h"
@@ -30,6 +32,8 @@
 #include "sandbox/linux/seccomp-bpf-helpers/syscall_sets.h"
 #include "sandbox/linux/services/linux_syscalls.h"
 #include "sandbox/linux/syscall_broker/broker_process.h"
+#include "third_party/libva/va/va.h"
+#include "third_party/libva/va/va_x11.h"

 using sandbox::BrokerProcess;
 using sandbox::SyscallSets;
@@ -38,6 +42,14 @@
 using sandbox::bpf_dsl::ResultExpr;
 using sandbox::bpf_dsl::Trap;

+using content_common_gpu_media::kModuleVa;
+using content_common_gpu_media::InitializeStubs;
+using content_common_gpu_media::StubPathMap;
+
+// libva-x11 depends on libva, so dlopen libva-x11 is enough
+static const base::FilePath::CharType kVaLib[] =
+    FILE_PATH_LITERAL("libva-x11.so.1");
+
 namespace content {

 namespace {
@@ -238,19 +250,38 @@
     // Accelerated video dlopen()'s some shared objects
     // inside the sandbox, so preload them now.
     if (IsAcceleratedVideoEnabled()) {
-      const char* I965DrvVideoPath = NULL;
+      StubPathMap paths;
+      paths[kModuleVa].push_back(kVaLib);
+      if (!InitializeStubs(paths)) {
+        return false;
+      }

-      if (IsArchitectureX86_64()) {
-        I965DrvVideoPath = "/usr/lib64/va/drivers/i965_drv_video.so";
-      } else if (IsArchitectureI386()) {
-        I965DrvVideoPath = "/usr/lib/va/drivers/i965_drv_video.so";
+      // libva drivers won't get loaded even above two libraries get dlopened.
+      // Thus, libva calls will fail after post sandbox stage.
+      //
+      // To get the va driver loadded before sandboxing, upstream simply dlopen
+      // the hard-coded va driver path because ChromeOS is the only platform
+      // that Google want to support libva.
+      //
+      // While generic linux distros ship va driver as anywhere they want.
+      // Fortunately, the va driver will be loadded when vaInitialize() get
+      // called.
+      // So the following code is to call vaInitialize() before sandboxing.
+      Display* x_display = XOpenDisplay(NULL);
+      VADisplay va_display = vaGetDisplay(x_display);
+      if (!vaDisplayIsValid(va_display)) {
+        DVLOG(1) << "Failed to call vaGetDisplay()";
+        return false;
       }

-      dlopen(I965DrvVideoPath, RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
-      dlopen("libva.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
-      dlopen("libva-x11.so.1", RTLD_NOW|RTLD_GLOBAL|RTLD_NODELETE);
-    }
-  }
+      int major_version, minor_version;
+      if (vaInitialize(va_display, &major_version, &minor_version)
+          != VA_STATUS_SUCCESS) {
+        DVLOG(1) << "Failed to call vaInitialize()";
+        return false;
+      }
+    }  // end of IsAcceleratedVideoDecodeEnabled()
+  }  // end of IsArchitectureX86_64() || IsArchitectureI386()

   return true;
 }
share|improve this answer
1  
Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. –  MadMike Mar 3 at 10:06
    
What I meant was to include the steps on how to get the source, apply the patch and compile it. Or on how to apt-add the PPA and install the browser. –  MadMike Mar 3 at 10:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.