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,6 +45,14 @@ Item {
height: root.statusBarHeight height: root.statusBarHeight
sourceComponent: MobileShell.StatusBar {
id: statusBar
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
height: root.statusBarHeight
Kirigami.Theme.inherit: false Kirigami.Theme.inherit: false
Kirigami.Theme.colorSet: Kirigami.Theme.Complementary Kirigami.Theme.colorSet: Kirigami.Theme.Complementary
@ -41,15 +63,29 @@ Item {
showTime: false showTime: false
disableSystemTray: true // prevent SIGABRT, since loading the system tray on the lockscreen leads to bad... things disableSystemTray: true // prevent SIGABRT, since loading the system tray on the lockscreen leads to bad... things
} }
// drag down gesture to open action drawer
MobileShell.ActionDrawerOpenSurface {
id: swipeArea
actionDrawer: drawer
anchors.fill: statusBar
} }
// action drawer component // Drag down gesture to open action drawer
MobileShell.ActionDrawerOpenSurface {
id: swipeArea
actionDrawer: actionDrawerLoader.item ? actionDrawerLoader.item.actionDrawer : null
anchors.fill: statusBarLoader
}
// Dynamically load on swipe-down to avoid having to load at start
Loader {
id: actionDrawerLoader
active: false
asynchronous: true
visible: status == Loader.Ready
anchors.fill: parent
sourceComponent: Item {
property var actionDrawer: drawer
// Action drawer component
MobileShell.ActionDrawer { MobileShell.ActionDrawer {
id: drawer id: drawer
anchors.fill: parent anchors.fill: parent
@ -85,4 +121,6 @@ Item {
drawer.requestNotificationAction = false; drawer.requestNotificationAction = false;
} }
} }
}
}
} }

View file

@ -69,21 +69,15 @@ 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
sourceComponent: HeaderComponent {
statusBarHeight: headerBarLoader.statusBarHeight
openFactor: flickable.openFactor openFactor: flickable.openFactor
notificationsModel: root.notifModel notificationsModel: root.notifModel
onPasswordRequested: root.askPassword() onPasswordRequested: root.askPassword()
} }
}
FlickContainer { FlickContainer {
id: flickable id: flickable
@ -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