lockscreen: Dynamically load status bar and action drawer as needed for performance

Currently the lockscreen takes 5 seconds to load for me on the OnePlus 6. This MR moves the quicksettings and status bar to only load once the initial lockscreen has loaded (to avoid blocking it). This brings it down the initial load to 1 second for me.
This commit is contained in:
Devin Lin 2024-06-28 11:04:32 -04:00
parent 403b11c2d7
commit acde5b389d
3 changed files with 91 additions and 61 deletions

View file

@ -18,8 +18,6 @@ MobileShell.SwipeArea {
required property ActionDrawer actionDrawer required property ActionDrawer actionDrawer
property int oldMouseY: 0
function startSwipe() { function startSwipe() {
if (actionDrawer.visible) { if (actionDrawer.visible) {
// ensure the action drawer state is consistent // ensure the action drawer state is consistent

View file

@ -21,9 +21,23 @@ Item {
signal passwordRequested() signal passwordRequested()
// top status bar // The status bar and quicksettings take a while to load, don't pause initial lockscreen loading for it
MobileShell.StatusBar { Timer {
id: statusBar id: loadTimer
running: true
repeat: false
onTriggered: {
statusBarLoader.active = true
actionDrawerLoader.active = true
}
}
// Status bar
Loader {
id: statusBarLoader
active: false
asynchronous: true
visible: status == Loader.Ready
anchors.top: parent.top anchors.top: parent.top
anchors.left: parent.left anchors.left: parent.left
@ -31,58 +45,82 @@ Item {
height: root.statusBarHeight height: root.statusBarHeight
Kirigami.Theme.inherit: false sourceComponent: MobileShell.StatusBar {
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary id: statusBar
backgroundColor: "transparent" anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
height: root.statusBarHeight
showSecondRow: false Kirigami.Theme.inherit: false
showDropShadow: true Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
showTime: false
disableSystemTray: true // prevent SIGABRT, since loading the system tray on the lockscreen leads to bad... things backgroundColor: "transparent"
showSecondRow: false
showDropShadow: true
showTime: false
disableSystemTray: true // prevent SIGABRT, since loading the system tray on the lockscreen leads to bad... things
}
} }
// drag down gesture to open action drawer // Drag down gesture to open action drawer
MobileShell.ActionDrawerOpenSurface { MobileShell.ActionDrawerOpenSurface {
id: swipeArea id: swipeArea
actionDrawer: drawer actionDrawer: actionDrawerLoader.item ? actionDrawerLoader.item.actionDrawer : null
anchors.fill: statusBar
anchors.fill: statusBarLoader
} }
// action drawer component // Dynamically load on swipe-down to avoid having to load at start
MobileShell.ActionDrawer { Loader {
id: drawer id: actionDrawerLoader
active: false
asynchronous: true
visible: status == Loader.Ready
anchors.fill: parent anchors.fill: parent
visible: offset !== 0 sourceComponent: Item {
restrictedPermissions: true property var actionDrawer: drawer
notificationSettings: NotificationManager.Settings {} // Action drawer component
notificationModel: root.notificationsModel MobileShell.ActionDrawer {
notificationModelType: MobileShell.NotificationsModelType.WatchedNotificationsModel id: drawer
anchors.fill: parent
property bool requestNotificationAction: false visible: offset !== 0
restrictedPermissions: true
// notification button clicked, requesting auth notificationSettings: NotificationManager.Settings {}
onPermissionsRequested: { notificationModel: root.notificationsModel
requestNotificationAction = true; notificationModelType: MobileShell.NotificationsModelType.WatchedNotificationsModel
drawer.close();
root.passwordRequested();
}
}
// listen to authentication events property bool requestNotificationAction: false
Connections {
target: authenticator // notification button clicked, requesting auth
function onSucceeded() { onPermissionsRequested: {
// run pending action if successfully unlocked requestNotificationAction = true;
if (drawer.requestNotificationAction) { drawer.close();
drawer.runPendingAction(); root.passwordRequested();
drawer.requestNotificationAction = false; }
}
// listen to authentication events
Connections {
target: authenticator
function onSucceeded() {
// run pending action if successfully unlocked
if (drawer.requestNotificationAction) {
drawer.runPendingAction();
drawer.requestNotificationAction = false;
}
}
function onFailed() {
drawer.requestNotificationAction = false;
}
} }
}
function onFailed() {
drawer.requestNotificationAction = false;
} }
} }
} }

View file

@ -69,20 +69,14 @@ Item {
anchors.fill: parent anchors.fill: parent
// Header bar and action drawer // Header bar and action drawer
Loader { HeaderComponent {
id: headerBarLoader id: headerBar
z: 1 // on top of flick area z: 1
readonly property real statusBarHeight: Kirigami.Units.gridUnit * 1.25
anchors.fill: parent anchors.fill: parent
asynchronous: true statusBarHeight: Kirigami.Units.gridUnit * 1.25
openFactor: flickable.openFactor
sourceComponent: HeaderComponent { notificationsModel: root.notifModel
statusBarHeight: headerBarLoader.statusBarHeight onPasswordRequested: root.askPassword()
openFactor: flickable.openFactor
notificationsModel: root.notifModel
onPasswordRequested: root.askPassword()
}
} }
FlickContainer { FlickContainer {
@ -120,7 +114,7 @@ Item {
onNotificationsShownChanged: root.notificationsShown = notificationsShown onNotificationsShownChanged: root.notificationsShown = notificationsShown
onPasswordRequested: flickable.goToOpenPosition() onPasswordRequested: flickable.goToOpenPosition()
anchors.topMargin: headerBarLoader.statusBarHeight anchors.topMargin: headerBar.statusBarHeight
anchors.top: parent.top anchors.top: parent.top
anchors.bottom: parent.bottom anchors.bottom: parent.bottom
anchors.left: parent.left anchors.left: parent.left