0

ash: Fix potential crash when displays are removed during rotation

Potential crash with the same root case as the bug b/293667233.
Apply the same fix to this situation of StartSlowAnimation().

Bug: 348688192
Change-Id: I710eaf8fe0c637e1924be6e7d976f293c4c5b226
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5718711
Commit-Queue: Tao Wu <wutao@chromium.org>
Reviewed-by: Ahmed Fakhry <afakhry@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1329559}
This commit is contained in:
Tao Wu
2024-07-18 15:23:50 +00:00
committed by Chromium LUCI CQ
parent cf018c76fe
commit d09c900056

@ -196,8 +196,21 @@ void ScreenRotationAnimator::StartRotationAnimation(
void ScreenRotationAnimator::StartSlowAnimation(
std::unique_ptr<ScreenRotationRequest> rotation_request) {
CreateOldLayerTreeForSlowAnimation();
auto weak_ptr = weak_factory_.GetWeakPtr();
SetRotation(rotation_request->display_id, rotation_request->old_rotation,
rotation_request->new_rotation, rotation_request->source);
if (!weak_ptr) {
// The above call to `SetRotation()` will end up calling
// `DisplayManager::UpdateDisplaysWith()`, which may lead to display
// removals while we're in the middle of rotation. In this case, `this` will
// be destroyed in `RootWindowController::Shutdown()`, and we should early
// exit here. See http://b/293667233.
return;
}
AnimateRotation(std::move(rotation_request));
}