Commit 87bdfd19 authored by Scott Violet's avatar Scott Violet Committed by Commit Bot

chromeos: fix bug in ArcScreenCaptureSession with mash

In SingleProcessMash there are two aura::Envs. See design doc for details.
This code was calling aura::Env::GetInstance() and expecting to get Ash's
Env. In SingleProcessMash aura::Env::GetInstance() returns Chrome's aura::Env.
The fix is to get the env from the window.

I'm also renaming 'desktop_window_' to display_root_window_ to make it clearer
that the window corresponds only to a display root.

BUG=b:124258894
TEST=none

Change-Id: I3b85610d72ada8adb674441e6e47d5ddd9d1b37f
Reviewed-on: https://chromium-review.googlesource.com/c/1483351Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Scott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634737}
parent 60d3a92e
...@@ -96,7 +96,6 @@ ArcScreenCaptureSession::ArcScreenCaptureSession( ...@@ -96,7 +96,6 @@ ArcScreenCaptureSession::ArcScreenCaptureSession(
: binding_(this), : binding_(this),
notifier_(std::move(notifier)), notifier_(std::move(notifier)),
size_(size), size_(size),
desktop_window_(nullptr),
client_native_pixmap_factory_( client_native_pixmap_factory_(
gfx::CreateClientNativePixmapFactoryDmabuf()), gfx::CreateClientNativePixmapFactoryDmabuf()),
weak_ptr_factory_(this) {} weak_ptr_factory_(this) {}
...@@ -106,18 +105,19 @@ mojom::ScreenCaptureSessionPtr ArcScreenCaptureSession::Initialize( ...@@ -106,18 +105,19 @@ mojom::ScreenCaptureSessionPtr ArcScreenCaptureSession::Initialize(
const std::string& display_name, const std::string& display_name,
bool enable_notification) { bool enable_notification) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
desktop_window_ = content::DesktopMediaID::GetNativeWindowById(desktop_id); display_root_window_ =
if (!desktop_window_) { content::DesktopMediaID::GetNativeWindowById(desktop_id);
if (!display_root_window_) {
LOG(ERROR) << "Unable to find Aura desktop window"; LOG(ERROR) << "Unable to find Aura desktop window";
return nullptr; return nullptr;
} }
ui::Layer* layer = desktop_window_->layer(); ui::Layer* layer = display_root_window_->layer();
if (!layer) { if (!layer) {
LOG(ERROR) << "Unable to find layer for the desktop window"; LOG(ERROR) << "Unable to find layer for the desktop window";
return nullptr; return nullptr;
} }
auto context_provider = aura::Env::GetInstance() auto context_provider = display_root_window_->env()
->context_factory() ->context_factory()
->SharedMainThreadContextProvider(); ->SharedMainThreadContextProvider();
gl_helper_ = std::make_unique<viz::GLHelper>( gl_helper_ = std::make_unique<viz::GLHelper>(
...@@ -129,7 +129,7 @@ mojom::ScreenCaptureSessionPtr ArcScreenCaptureSession::Initialize( ...@@ -129,7 +129,7 @@ mojom::ScreenCaptureSessionPtr ArcScreenCaptureSession::Initialize(
gfx::Vector2d(desktop_size.width(), desktop_size.height()), gfx::Vector2d(desktop_size.width(), desktop_size.height()),
gfx::Vector2d(size_.width(), size_.height()), false, true, false); gfx::Vector2d(size_.width(), size_.height()), false, true, false);
desktop_window_->GetHost()->compositor()->AddAnimationObserver(this); display_root_window_->GetHost()->compositor()->AddAnimationObserver(this);
if (enable_notification) { if (enable_notification) {
// Show the tray notification icon now. // Show the tray notification icon now.
...@@ -159,7 +159,10 @@ void ArcScreenCaptureSession::Close() { ...@@ -159,7 +159,10 @@ void ArcScreenCaptureSession::Close() {
} }
ArcScreenCaptureSession::~ArcScreenCaptureSession() { ArcScreenCaptureSession::~ArcScreenCaptureSession() {
desktop_window_->GetHost()->compositor()->RemoveAnimationObserver(this); if (!display_root_window_)
return;
display_root_window_->GetHost()->compositor()->RemoveAnimationObserver(this);
ash::Shell::Get()->display_manager()->dec_screen_capture_active_counter(); ash::Shell::Get()->display_manager()->dec_screen_capture_active_counter();
ash::Shell::Get()->UpdateCursorCompositingEnabled(); ash::Shell::Get()->UpdateCursorCompositingEnabled();
} }
...@@ -352,7 +355,7 @@ void ArcScreenCaptureSession::OnAnimationStep(base::TimeTicks timestamp) { ...@@ -352,7 +355,7 @@ void ArcScreenCaptureSession::OnAnimationStep(base::TimeTicks timestamp) {
return; return;
} }
ui::Layer* layer = desktop_window_->layer(); ui::Layer* layer = display_root_window_->layer();
if (!layer) { if (!layer) {
LOG(ERROR) << "Unable to find layer for the desktop window"; LOG(ERROR) << "Unable to find layer for the desktop window";
return; return;
...@@ -363,7 +366,7 @@ void ArcScreenCaptureSession::OnAnimationStep(base::TimeTicks timestamp) { ...@@ -363,7 +366,7 @@ void ArcScreenCaptureSession::OnAnimationStep(base::TimeTicks timestamp) {
base::BindOnce(&ArcScreenCaptureSession::OnDesktopCaptured, base::BindOnce(&ArcScreenCaptureSession::OnDesktopCaptured,
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
// Clip the requested area to the desktop area. See b/118675936. // Clip the requested area to the desktop area. See b/118675936.
request->set_area(gfx::Rect(desktop_window_->bounds().size())); request->set_area(gfx::Rect(display_root_window_->bounds().size()));
layer->RequestCopyOfOutput(std::move(request)); layer->RequestCopyOfOutput(std::move(request));
} }
......
...@@ -93,7 +93,9 @@ class ArcScreenCaptureSession : public mojom::ScreenCaptureSession, ...@@ -93,7 +93,9 @@ class ArcScreenCaptureSession : public mojom::ScreenCaptureSession,
mojo::Binding<mojom::ScreenCaptureSession> binding_; mojo::Binding<mojom::ScreenCaptureSession> binding_;
mojom::ScreenCaptureSessionNotifierPtr notifier_; mojom::ScreenCaptureSessionNotifierPtr notifier_;
gfx::Size size_; gfx::Size size_;
aura::Window* desktop_window_; // aura::Window of the display being captured. This corresponds to one of
// Ash's root windows.
aura::Window* display_root_window_ = nullptr;
// We have 2 separate queues for handling incoming GPU buffers from Android // We have 2 separate queues for handling incoming GPU buffers from Android
// and also textures for the desktop we have captured already. Due to the // and also textures for the desktop we have captured already. Due to the
......
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