Commit 7a27c0fc authored by Wenzhao Zang's avatar Wenzhao Zang Committed by Commit Bot

cros: Remove unnecessary timer in LockScreen

The timer was added for the fear that the wallpaper animation
completion is never received. In fact, it's guaranteed to be received.

In case there's a decoder issue (more info in the bug) that wallpaper
decoding takes more than 5 sec:

1) If keeping the timer, the user pods will be shown on top of the
   white boot splash screen, which looks buggy.
2) If removing the timer, the user pods will show together with the
   wallpaper. The boot experience feels slow but still smooth.

So IMO the best solution is to remove the timer as well as trying to
fix the decoder issue.

Bug: 890935
Change-Id: I685a0065acae99ebccd2734dcebd9dce2f563dbb
Reviewed-on: https://chromium-review.googlesource.com/1255903Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Commit-Queue: Wenzhao (Colin) Zang <wzang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596284}
parent aa11ee70
......@@ -16,7 +16,6 @@
#include "ash/tray_action/tray_action.h"
#include "ash/wallpaper/wallpaper_controller.h"
#include "base/command_line.h"
#include "base/timer/timer.h"
#include "chromeos/chromeos_switches.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
......@@ -25,9 +24,6 @@
namespace ash {
namespace {
constexpr base::TimeDelta kShowLoginScreenTimeout =
base::TimeDelta::FromSeconds(5);
// Global lock screen instance. There can only ever be on lock screen at a
// time.
LockScreen* instance_ = nullptr;
......@@ -86,28 +82,18 @@ void LockScreen::Show(ScreenType type) {
}
instance_->window_->set_data_dispatcher(std::move(data_dispatcher));
const base::RepeatingClosure show_screen = base::BindRepeating([]() {
// |instance_| may already be destroyed in tests.
if (!instance_ || instance_->is_shown_)
return;
instance_->is_shown_ = true;
instance_->window_->Show();
});
if (type == ScreenType::kLogin) {
// Postpone showing the login screen after the animation of the first
// wallpaper completes, to make the transition smooth.
Shell::Get()->wallpaper_controller()->AddFirstWallpaperAnimationEndCallback(
show_screen, instance_->window_->GetNativeView());
// In case the wallpaper animation takes forever to complete, set a timer to
// make sure the login screen is shown eventually. This should never happen,
// so use an extra long time-out value to raise awareness.
instance_->show_login_screen_fallback_timer_ =
std::make_unique<base::OneShotTimer>();
instance_->show_login_screen_fallback_timer_->Start(
FROM_HERE, kShowLoginScreenTimeout, show_screen);
} else {
show_screen.Run();
}
// Postpone showing the screen after the animation of the first wallpaper
// completes, to make the transition smooth. The callback will be dispatched
// immediately if the animation is already complete (e.g. kLock).
Shell::Get()->wallpaper_controller()->AddFirstWallpaperAnimationEndCallback(
base::BindOnce([]() {
// |instance_| may already be destroyed in tests.
if (!instance_ || instance_->is_shown_)
return;
instance_->is_shown_ = true;
instance_->window_->Show();
}),
instance_->window_->GetNativeView());
}
// static
......
......@@ -5,18 +5,12 @@
#ifndef ASH_LOGIN_UI_LOCK_SCREEN_H_
#define ASH_LOGIN_UI_LOCK_SCREEN_H_
#include <memory>
#include "ash/ash_export.h"
#include "ash/session/session_observer.h"
#include "ash/tray_action/tray_action_observer.h"
#include "base/macros.h"
#include "base/scoped_observer.h"
namespace base {
class OneShotTimer;
}
namespace ash {
class LockContentsView;
......@@ -89,10 +83,6 @@ class ASH_EXPORT LockScreen : public TrayActionObserver,
// Unowned pointer to the LockContentsView hosted in lock window.
LockContentsView* contents_view_ = nullptr;
// The fallback timer that ensures the login screen is shown in case the first
// wallpaper animation takes an extra long time to complete.
std::unique_ptr<base::OneShotTimer> show_login_screen_fallback_timer_;
bool is_shown_ = false;
ScopedObserver<TrayAction, TrayActionObserver> tray_action_observer_{this};
......
......@@ -73,6 +73,8 @@ gfx::Rect LoginKeyboardTestBase::GetKeyboardBoundsInScreen() const {
void LoginKeyboardTestBase::ShowLockScreen() {
GetSessionControllerClient()->SetSessionState(
session_manager::SessionState::LOCKED);
// The lock screen can't be shown without a wallpaper.
Shell::Get()->wallpaper_controller()->ShowDefaultWallpaperForTesting();
base::Optional<bool> result;
login_controller_->ShowLockScreen(base::BindOnce(
......
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