Skip to content

Commit

Permalink
[Merge to M100] wm: Another speculative fix for the crash during wind…
Browse files Browse the repository at this point in the history
…ow dragging

This is another specutlative fix for the crash that happens during
dragging. It's possible that when dragging a maximized window, restoring
the maximized window may cause the window being destroyed. Early return
in this case.

(cherry picked from commit 2eb6c28)

Bug: 1200599
Change-Id: Ib8c49ee418e6fd1d3549de6e7b8ec71f6a35e412
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3543511
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Xiaoqian Dai <xdai@chromium.org>
Cr-Original-Commit-Position: refs/heads/main@{#984102}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3553687
Cr-Commit-Position: refs/branch-heads/4896@{#872}
Cr-Branched-From: 1f63ff4-refs/heads/main@{#972766}
  • Loading branch information
Xiaoqian Dai authored and Chromium LUCI CQ committed Mar 25, 2022
1 parent 8e8d915 commit 15c7894
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ash/wm/workspace/workspace_window_resizer.cc
Expand Up @@ -713,9 +713,21 @@ void WorkspaceWindowResizer::Drag(const gfx::PointF& location_in_parent,
// Update the maximized window so that it looks like it has been
// restored (i.e. update the caption buttons and height of the
// browser frame).

// TODO(http://crbug.com/1200599): Speculative, remove if not fixed.
// Change window property kFrameRestoreLookKey or window bounds may
// cause the window being destroyed during the drag and return early
// if that's the case.
base::WeakPtr<WorkspaceWindowResizer> resizer(
weak_ptr_factory_.GetWeakPtr());
window_state()->window()->SetProperty(kFrameRestoreLookKey, true);
if (!resizer)
return;
CrossFadeAnimation(window_state()->window(), bounds,
/*maximize=*/false);
if (!resizer)
return;

base::RecordAction(
base::UserMetricsAction("WindowDrag_Unmaximize"));
} else if (window_state()->IsSnapped()) {
Expand Down

0 comments on commit 15c7894

Please sign in to comment.