ash: Fix a crash when using a cleared window state ptr
I was unable to repro the crash manually, but was able to simulate it in a test. It's not clear how this scenario can happen in production but the resulting crash in the test has the same stack as the reported crash. Fixed: b/331238593 Test: Added a new test that crashes without the fix. Change-Id: I746a27b708a53b4458a3001ff1cba0b4793d8c3d Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5401917 Reviewed-by: Xiyuan Xia <xiyuan@chromium.org> Commit-Queue: Ahmed Fakhry <afakhry@chromium.org> Cr-Commit-Position: refs/heads/main@{#1279348}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
b5ece803f9
commit
cad6fb6ea3
@ -89,7 +89,7 @@ class NonClientFrameViewAshImmersiveHelper : public WindowStateObserver,
|
||||
|
||||
// display::DisplayObserver:
|
||||
void OnDisplayTabletStateChanged(display::TabletState state) override {
|
||||
if (window_state_->IsFullscreen()) {
|
||||
if (!window_state_ || window_state_->IsFullscreen()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -372,6 +372,34 @@ TEST_F(NonClientFrameViewAshTest, OpeningAppsInTabletMode) {
|
||||
delegate->GetNonClientFrameViewTopBorderHeight());
|
||||
}
|
||||
|
||||
// Regression test for https://b/331238593. See bug for more details.
|
||||
TEST_F(NonClientFrameViewAshTest,
|
||||
NoCrashOnTabletChangesWithinWindowDestruction) {
|
||||
class WindowTestObserver : public aura::WindowObserver {
|
||||
public:
|
||||
explicit WindowTestObserver(aura::Window* window) {
|
||||
window_observation_.Observe(window);
|
||||
}
|
||||
~WindowTestObserver() override = default;
|
||||
|
||||
void OnWindowDestroying(aura::Window* window) override {
|
||||
// Simulate a tablet state change from within window destruction. It's not
|
||||
// clear how this may happen in production, but it triggers the same
|
||||
// reported crash stack.
|
||||
TabletModeControllerTestApi().EnterTabletMode();
|
||||
window_observation_.Reset();
|
||||
}
|
||||
|
||||
private:
|
||||
base::ScopedObservation<aura::Window, aura::WindowObserver>
|
||||
window_observation_{this};
|
||||
};
|
||||
|
||||
auto test_window = CreateTestWindow(gfx::Rect(200, 200));
|
||||
WindowTestObserver obs(test_window.get());
|
||||
test_window.reset();
|
||||
}
|
||||
|
||||
// Test if creating a new window in tablet mode uses maximzied state
|
||||
// and immersive mode.
|
||||
TEST_F(NonClientFrameViewAshTest, GetPreferredOnScreenHeightInTabletMaximzied) {
|
||||
|
Reference in New Issue
Block a user