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
2 changed files with 15 additions and 11 deletions
@@ -63,10 +63,10 @@ class WindowManager {
/// Shows the main and overlay window combo, hiding the alternate window.
func switchToMain() {
mainWindow.isHidden = false
overlayWindow.isHidden = false
switchTask = Task {
mainWindow.isHidden = false
overlayWindow.isHidden = false
// Delay hiding to make sure the main windows are visible.
try await Task.sleep(for: windowHideDelay)
@@ -76,14 +76,17 @@ class WindowManager {
/// Shows the alternate window, hiding the main and overlay combo.
func switchToAlternate() {
alternateWindow.isHidden = false
// We don't know what route the app will use when returning back
// to the main window, so end any editing operation now to avoid
// 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 {
alternateWindow.isHidden = false
// We don't know what route the app will use when returning back
// to the main window, so end any editing operation now to avoid
// e.g. the keyboard being displayed on top of a call sheet.
mainWindow.endEditing(true)
// Delay hiding to make sure the alternate window is visible.
try await Task.sleep(for: windowHideDelay)