Commit a6e569e2 authored by Nick Diego Yamane's avatar Nick Diego Yamane Committed by Commit Bot

x11: CHECK for unexpected XWindow destruction during resize closure

This should help us to determine what exactly caused XWindow
destruction during DelayedResize closure execution so that we can
propose a proper fix to it.

R=gab@chromium.org

Bug: 1021490
Change-Id: Ie8e18d47b4c08d3c8aaf89d4f6dbf230f5c41b7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2087664
Commit-Queue: Nick Yamane <nickdiego@igalia.com>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Reviewed-by: default avatarThomas Anderson <thomasanderson@chromium.org>
Auto-Submit: Nick Yamane <nickdiego@igalia.com>
Cr-Commit-Position: refs/heads/master@{#746924}
parent f80dfbc0
......@@ -8,6 +8,7 @@
#include <vector>
#include "base/location.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "base/threading/thread_task_runner_handle.h"
......@@ -144,6 +145,7 @@ XWindow::XWindow()
}
XWindow::~XWindow() {
CHECK(!resize_weak_factory_.HasWeakPtrs());
DCHECK_EQ(xwindow_, x11::None) << "XWindow destructed without calling "
"Close() to release allocated resources.";
}
......@@ -1392,6 +1394,8 @@ void XWindow::DispatchResize() {
}
void XWindow::DelayedResize(const gfx::Rect& bounds_in_pixels) {
base::WeakPtr<XWindow> alive(resize_weak_factory_.GetWeakPtr());
if (configure_counter_value_is_extended_ &&
(current_counter_value_ % 2) == 0) {
// Increase the |extended_update_counter_|, so the compositor will know we
......@@ -1402,6 +1406,13 @@ void XWindow::DelayedResize(const gfx::Rect& bounds_in_pixels) {
++current_counter_value_);
}
NotifyBoundsChanged(bounds_in_pixels);
// TODO(crbug.com/1021490): Crashes during window re-attaching while dragging
// a tab points out to the XWindow instance being destroyed in the middle of
// DelayedResize closure execution. This + CHECK'ing weak references in dtor
// helps better identify such unexpected scenario.
if (!alive)
return;
CancelResize();
}
......
......@@ -13,6 +13,7 @@
#include "base/component_export.h"
#include "base/containers/flat_set.h"
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "base/strings/string16.h"
#include "ui/gfx/geometry/insets.h"
......@@ -376,6 +377,8 @@ class COMPONENT_EXPORT(UI_BASE_X) XWindow {
bool has_pointer_barriers_ = false;
std::array<XID, 4> pointer_barriers_;
base::WeakPtrFactory<XWindow> resize_weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(XWindow);
};
......
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