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
property int oldMouseY: 0
function startSwipe() {
if (actionDrawer.visible) {
// ensure the action drawer state is consistent

View file

@ -21,9 +21,23 @@ Item {
signal passwordRequested()
// top status bar
MobileShell.StatusBar {
id: statusBar
// The status bar and quicksettings take a while to load, don't pause initial lockscreen loading for it
Timer {
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.left: parent.left
@ -31,6 +45,14 @@ Item {
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.colorSet: Kirigami.Theme.Complementary
@ -41,15 +63,29 @@ Item {
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
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 {
id: drawer
anchors.fill: parent
@ -85,4 +121,6 @@ Item {
drawer.requestNotificationAction = false;
}
}
}
}
}

View file

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