Commit 4cc1df91 authored by Etienne Bergeron's avatar Etienne Bergeron Committed by Commit Bot

Boost thread priority while loading COMBase

This CL is boosting the thread priority to avoid loading the DLL at
 background priority.

The following stackframe is the cause of the priority inversion:

  base::win::RoGetActivationFactory
  device::BluetoothAdapterWinrt::PerformSlowInitTasks()
   [...]
  base::internal::WorkerThread::RunWorker()
  base::internal::WorkerThread::RunBackgroundPooledWorker

see: https://bugs.chromium.org/p/chromium/issues/detail?id=973868#c42
Noticed in crash/bc6506f76abf6a60

R=joenotcharles@chromium.org,robliao@chromium.org

Bug: 973868
Change-Id: Ifbe2b87aed7364ad24a59ad300512ef82c03491a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377891Reviewed-by: default avatarJoe Mason <joenotcharles@chromium.org>
Reviewed-by: default avatarRobert Liao <robliao@chromium.org>
Commit-Queue: Etienne Bergeron <etienneb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802021}
parent aaa5aed2
......@@ -4,11 +4,18 @@
#include "base/win/core_winrt_util.h"
#include "base/threading/scoped_thread_priority.h"
namespace {
FARPROC LoadComBaseFunction(const char* function_name) {
static HMODULE const handle =
::LoadLibraryEx(L"combase.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
static HMODULE const handle = []() {
// Mitigate the issues caused by loading DLLs on a background thread
// (http://crbug/973868).
SCOPED_MAY_LOAD_LIBRARY_AT_BACKGROUND_PRIORITY();
return ::LoadLibraryEx(L"combase.dll", nullptr,
LOAD_LIBRARY_SEARCH_SYSTEM32);
}();
return handle ? ::GetProcAddress(handle, function_name) : nullptr;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment