Make RenderingWindowManager access happen only on UI thread.
Remove the ability to access RenderingWindowManager on any thread and
remove locks. Make RegisterChild() PostTask back to the UI thread if
necessary so it can still be called anywhere. There is already a
PostTask before ::SetParent() gets called, so this shouldn't add much
extra latency before things show up on screen.
Also move the checks that parent HWND was registered and child HWND was
created by expected process id to happen immediately before calling
::SetParent(). This ensures that child HWND belongs to the right
process. We don't need to check the parent HWND process because we
check it registered by the browser process.
This also fixes a race with OOP-D where RegisterChild() can get called
more than once due to races between different message pipes.
Bug: 791660
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel
Change-Id: If8e98bd974dbc77e1be21252d3aa1682f3e6e016
Reviewed-on: https://chromium-review.googlesource.com/1194580
Commit-Queue: kylechar <[email protected]>
Reviewed-by: Antoine Labour <[email protected]>
Reviewed-by: Sadrul Chowdhury <[email protected]>
Reviewed-by: Sunny Sachanandani <[email protected]>
Cr-Commit-Position: refs/heads/master@{#589919}
diff --git a/components/viz/host/gpu_host_impl.cc b/components/viz/host/gpu_host_impl.cc
index b1993c3..0c41b1a 100644
--- a/components/viz/host/gpu_host_impl.cc
+++ b/components/viz/host/gpu_host_impl.cc
@@ -529,28 +529,9 @@
#if defined(OS_WIN)
void GpuHostImpl::SetChildSurface(gpu::SurfaceHandle parent,
gpu::SurfaceHandle child) {
- constexpr char kBadMessageError[] = "Bad parenting request from gpu process.";
- if (!params_.in_process) {
- DWORD parent_process_id = 0;
- DWORD parent_thread_id =
- ::GetWindowThreadProcessId(parent, &parent_process_id);
- if (!parent_thread_id || parent_process_id != ::GetCurrentProcessId()) {
- LOG(ERROR) << kBadMessageError;
- return;
- }
-
- DWORD child_process_id = 0;
- DWORD child_thread_id =
- ::GetWindowThreadProcessId(child, &child_process_id);
- if (!child_thread_id || child_process_id != pid_) {
- LOG(ERROR) << kBadMessageError;
- return;
- }
- }
-
- if (!gfx::RenderingWindowManager::GetInstance()->RegisterChild(parent,
- child)) {
- LOG(ERROR) << kBadMessageError;
+ if (pid_ != base::kNullProcessId) {
+ gfx::RenderingWindowManager::GetInstance()->RegisterChild(
+ parent, child, /*expected_child_process_id=*/pid_);
}
}
#endif // defined(OS_WIN)