summaryrefslogtreecommitdiffstats
path: root/content
diff options
context:
space:
mode:
authorapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-12 03:00:19 +0000
committerapatrick@chromium.org <apatrick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-03-12 03:00:19 +0000
commit2abf912f655b1d2f462fdcc8bcaffdb3c2895999 (patch)
treeef194338325498fd490ee8145250c6109e4a7ddc /content
parent44f8b82b79e0f41e0f26a88f497441e60f3ac480 (diff)
downloadchromium_src-2abf912f655b1d2f462fdcc8bcaffdb3c2895999.zip
chromium_src-2abf912f655b1d2f462fdcc8bcaffdb3c2895999.tar.gz
chromium_src-2abf912f655b1d2f462fdcc8bcaffdb3c2895999.tar.bz2
Revert 170568 - Do DXVA pre-sandbox initialization off the main thread.
Drivers for DisplayLink and Thinkpad USB Port Replicator crash when Direct3D is initialized on a sandboxed worker thread. BUG=181665,177611 Review URL: https://chromiumcodereview.appspot.com/12408016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187470 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content')
-rw-r--r--content/common/gpu/media/dxva_video_decode_accelerator.cc62
-rw-r--r--content/common/gpu/media/dxva_video_decode_accelerator.h8
-rw-r--r--content/common/gpu/media/video_decode_accelerator_unittest.cc6
-rw-r--r--content/gpu/gpu_main.cc33
4 files changed, 42 insertions, 67 deletions
diff --git a/content/common/gpu/media/dxva_video_decode_accelerator.cc b/content/common/gpu/media/dxva_video_decode_accelerator.cc
index 47a30ff..ad79c51 100644
--- a/content/common/gpu/media/dxva_video_decode_accelerator.cc
+++ b/content/common/gpu/media/dxva_video_decode_accelerator.cc
@@ -24,7 +24,6 @@
#include "base/message_loop.h"
#include "base/process_util.h"
#include "base/shared_memory.h"
-#include "base/threading/worker_pool.h"
#include "media/video/video_decode_accelerator.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_surface.h"
@@ -366,14 +365,10 @@ DXVAVideoDecodeAccelerator::PendingSampleInfo::PendingSampleInfo(
DXVAVideoDecodeAccelerator::PendingSampleInfo::~PendingSampleInfo() {}
// static
-// Initializes DXVA on a separate thread.
-void DXVAVideoDecodeAccelerator::PreSandboxInitialization(
- const base::Closure& completion_task) {
+void DXVAVideoDecodeAccelerator::PreSandboxInitialization() {
// Should be called only once during program startup.
DCHECK(!pre_sandbox_init_done_);
- base::ScopedClosureRunner scoped_completion_runner(completion_task);
-
static wchar_t* decoding_dlls[] = {
L"d3d9.dll",
L"dxva2.dll",
@@ -390,24 +385,15 @@ void DXVAVideoDecodeAccelerator::PreSandboxInitialization(
}
}
- HRESULT hr = Direct3DCreate9Ex(D3D_SDK_VERSION, &d3d9_);
- RETURN_ON_HR_FAILURE(hr,
- "Failed to initialize D3D9.",);
-
- // Initialize H/W video decoding stuff which fails in the sandbox. This is
- // done on a worker thread because it takes 10s of ms.
- scoped_completion_runner.Release();
- base::WorkerPool::PostTask(
- FROM_HERE,
- base::Bind(&DXVAVideoDecodeAccelerator::CreateD3DDevManager,
- completion_task),
- true);
+ RETURN_ON_FAILURE(CreateD3DDevManager(),
+ "Failed to initialize D3D device and manager",);
+ pre_sandbox_init_done_ = true;
}
// static
-void DXVAVideoDecodeAccelerator::CreateD3DDevManager(
- const base::Closure& completion_task) {
- base::ScopedClosureRunner scoped_completion_runner(completion_task);
+bool DXVAVideoDecodeAccelerator::CreateD3DDevManager() {
+ HRESULT hr = Direct3DCreate9Ex(D3D_SDK_VERSION, &d3d9_);
+ RETURN_ON_HR_FAILURE(hr, "Direct3DCreate9Ex failed", false);
D3DPRESENT_PARAMETERS present_params = {0};
present_params.BackBufferWidth = 1;
@@ -421,34 +407,32 @@ void DXVAVideoDecodeAccelerator::CreateD3DDevManager(
present_params.FullScreen_RefreshRateInHz = 0;
present_params.PresentationInterval = 0;
- HRESULT hr = d3d9_->CreateDeviceEx(D3DADAPTER_DEFAULT,
- D3DDEVTYPE_HAL,
- ::GetShellWindow(),
- D3DCREATE_FPU_PRESERVE |
- D3DCREATE_SOFTWARE_VERTEXPROCESSING |
- D3DCREATE_DISABLE_PSGP_THREADING |
- D3DCREATE_MULTITHREADED,
- &present_params,
- NULL,
- &device_);
- RETURN_ON_HR_FAILURE(hr, "Failed to create D3D device",);
+ hr = d3d9_->CreateDeviceEx(D3DADAPTER_DEFAULT,
+ D3DDEVTYPE_HAL,
+ ::GetShellWindow(),
+ D3DCREATE_FPU_PRESERVE |
+ D3DCREATE_SOFTWARE_VERTEXPROCESSING |
+ D3DCREATE_DISABLE_PSGP_THREADING |
+ D3DCREATE_MULTITHREADED,
+ &present_params,
+ NULL,
+ &device_);
+ RETURN_ON_HR_FAILURE(hr, "Failed to create D3D device", false);
hr = DXVA2CreateDirect3DDeviceManager9(&dev_manager_reset_token_,
&device_manager_);
- RETURN_ON_HR_FAILURE(hr, "DXVA2CreateDirect3DDeviceManager9 failed",);
+ RETURN_ON_HR_FAILURE(hr, "DXVA2CreateDirect3DDeviceManager9 failed", false);
hr = device_manager_->ResetDevice(device_, dev_manager_reset_token_);
- RETURN_ON_HR_FAILURE(hr, "Failed to reset device",);
+ RETURN_ON_HR_FAILURE(hr, "Failed to reset device", false);
hr = device_->CreateQuery(D3DQUERYTYPE_EVENT, &query_);
- RETURN_ON_HR_FAILURE(hr, "Failed to create D3D device query",);
-
+ RETURN_ON_HR_FAILURE(hr, "Failed to create D3D device query", false);
// Ensure query_ API works (to avoid an infinite loop later in
// CopyOutputSampleDataToPictureBuffer).
hr = query_->Issue(D3DISSUE_END);
- RETURN_ON_HR_FAILURE(hr, "Failed to issue END test query",);
-
- pre_sandbox_init_done_ = true;
+ RETURN_ON_HR_FAILURE(hr, "Failed to issue END test query", false);
+ return true;
}
DXVAVideoDecodeAccelerator::DXVAVideoDecodeAccelerator(
diff --git a/content/common/gpu/media/dxva_video_decode_accelerator.h b/content/common/gpu/media/dxva_video_decode_accelerator.h
index c6738bc..b137946 100644
--- a/content/common/gpu/media/dxva_video_decode_accelerator.h
+++ b/content/common/gpu/media/dxva_video_decode_accelerator.h
@@ -61,9 +61,7 @@ class CONTENT_EXPORT DXVAVideoDecodeAccelerator
// 1. Loads the dlls like mf/mfplat/d3d9, etc required for decoding.
// 2. Setting up the device manager instance which is shared between all
// decoder instances.
- // Invokes the completion task, potentially on another thread, when complete.
- static void PreSandboxInitialization(
- const base::Closure& completion_task);
+ static void PreSandboxInitialization();
private:
typedef void* EGLConfig;
@@ -71,9 +69,7 @@ class CONTENT_EXPORT DXVAVideoDecodeAccelerator
// Creates and initializes an instance of the D3D device and the
// corresponding device manager. The device manager instance is eventually
// passed to the IMFTransform interface implemented by the h.264 decoder.
- // Invokes the completion task, potentially on another thread, when complete.
- static void CreateD3DDevManager(
- const base::Closure& completion_task);
+ static bool CreateD3DDevManager();
// Creates, initializes and sets the media types for the h.264 decoder.
bool InitDecoder();
diff --git a/content/common/gpu/media/video_decode_accelerator_unittest.cc b/content/common/gpu/media/video_decode_accelerator_unittest.cc
index dd6c137..6b01a9a 100644
--- a/content/common/gpu/media/video_decode_accelerator_unittest.cc
+++ b/content/common/gpu/media/video_decode_accelerator_unittest.cc
@@ -985,11 +985,7 @@ int main(int argc, char **argv) {
content::RenderingHelper::InitializePlatform();
#if defined(OS_WIN)
- base::WaitableEvent event(true, false);
- content::DXVAVideoDecodeAccelerator::PreSandboxInitialization(
- base::Bind(&base::WaitableEvent::Signal,
- base::Unretained(&event)));
- event.Wait();
+ content::DXVAVideoDecodeAccelerator::PreSandboxInitialization();
#elif defined(OS_CHROMEOS)
#if defined(ARCH_CPU_ARMEL)
if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseExynosVda))
diff --git a/content/gpu/gpu_main.cc b/content/gpu/gpu_main.cc
index e01ed63..44d00dd 100644
--- a/content/gpu/gpu_main.cc
+++ b/content/gpu/gpu_main.cc
@@ -169,15 +169,6 @@ int GpuMain(const MainFunctionParams& parameters) {
command_line.GetSwitchValueASCII(switches::kGpuDriverVersion);
GetContentClient()->SetGpuInfo(gpu_info);
-#if defined(OS_WIN)
- // Asynchronously initialize DXVA while GL is being initialized because
- // they both take tens of ms.
- base::WaitableEvent dxva_initialized(true, false);
- DXVAVideoDecodeAccelerator::PreSandboxInitialization(
- base::Bind(&base::WaitableEvent::Signal,
- base::Unretained(&dxva_initialized)));
-#endif
-
// We need to track that information for the WarmUpSandbox function.
bool initialized_gl_context = false;
// Load and initialize the GL implementation and locate the GL entry points.
@@ -251,12 +242,6 @@ int GpuMain(const MainFunctionParams& parameters) {
#if defined(OS_WIN)
{
- // DXVA initialization must have completed before the token is lowered.
- TRACE_EVENT0("gpu", "Wait for DXVA initialization");
- dxva_initialized.Wait();
- }
-
- {
TRACE_EVENT0("gpu", "Lower token");
// For windows, if the target_services interface is not zero, the process
// is sandboxed and we must call LowerToken() before rendering untrusted
@@ -359,8 +344,22 @@ void WarmUpSandbox(const GPUInfo& gpu_info,
#endif
#if defined(OS_WIN)
- // Preload these DLL because the sandbox prevents them from loading.
- LoadLibrary(L"setupapi.dll");
+ {
+ TRACE_EVENT0("gpu", "Initialize COM");
+ base::win::ScopedCOMInitializer com_initializer;
+ }
+
+ {
+ TRACE_EVENT0("gpu", "Preload setupapi.dll");
+ // Preload this DLL because the sandbox prevents it from loading.
+ LoadLibrary(L"setupapi.dll");
+ }
+
+ {
+ TRACE_EVENT0("gpu", "Initialize DXVA");
+ // Initialize H/W video decoding stuff which fails in the sandbox.
+ DXVAVideoDecodeAccelerator::PreSandboxInitialization();
+ }
#endif
}