Fix a bug where the Screen lock placeholder could be slow. (#2155)

* Only use the Task for the delayed window changes.
The timing was off with the Task when locking the device with the app open.

* Check the application state before unlocking the app.
On top of a), the app will reveal itself if you background during the success animation, b) the flow is run farrrr too many times, so the app is revealing itself way before the Face ID scan UI is complete - definitely need a state machine here.
This commit is contained in:
Doug 2023-11-22 18:58:14 +00:00 committed by GitHub
parent a21bc2cdd3
commit 4d011b9116
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 11 deletions

View File

@ -63,10 +63,10 @@ class WindowManager {
/// Shows the main and overlay window combo, hiding the alternate window.
func switchToMain() {
switchTask = Task {
mainWindow.isHidden = false
overlayWindow.isHidden = false
switchTask = Task {
// Delay hiding to make sure the main windows are visible.
try await Task.sleep(for: windowHideDelay)
@ -76,7 +76,6 @@ class WindowManager {
/// Shows the alternate window, hiding the main and overlay combo.
func switchToAlternate() {
switchTask = Task {
alternateWindow.isHidden = false
// We don't know what route the app will use when returning back
@ -84,6 +83,10 @@ class WindowManager {
// e.g. the keyboard being displayed on top of a call sheet.
mainWindow.endEditing(true)
// alternateWindow.isHidden = false cannot got inside the Task otherwise the timing
// is poor when you lock the phone - you briefly see the main window for a few
// frames after you've unlocked the phone and then the placeholder animates in.
switchTask = Task {
// Delay hiding to make sure the alternate window is visible.
try await Task.sleep(for: windowHideDelay)

View File

@ -108,7 +108,7 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
if appLockService.biometricUnlockEnabled, appLockService.biometricUnlockTrusted {
showPlaceholder() // For the unlock background.
if await appLockService.unlockWithBiometrics() {
if await appLockService.unlockWithBiometrics(), UIApplication.shared.applicationState == .active {
actionsSubject.send(.unlockApp)
return
}
@ -132,6 +132,7 @@ class AppLockFlowCoordinator: CoordinatorProtocol {
guard let self else { return }
switch action {
case .appUnlocked:
guard UIApplication.shared.applicationState == .active else { return }
actionsSubject.send(.unlockApp)
case .forceLogout:
actionsSubject.send(.forceLogout)