fix: repaint the whole screen while the root switches
PID 1 writes to the console and resets it while it re-executes, and bootvine only drew the cells it believed had changed, so the switch left a garbled screen for up to seconds. Repaint on every check from the moment the switch is queued until the new manager answers.
This commit is contained in:
2 files changed
+32
-4
No files matched your search
@@ -113,6 +113,14 @@ fn queued_units(signals: &[Signal]) -> impl Iterator<Item = &str> {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn connected_inputs(changes: Vec<BootChange>, switching_root: bool) -> Vec<ScreenInput> {
|
||||||
|
(!changes.is_empty())
|
||||||
|
.then_some(ScreenInput::Boot(changes))
|
||||||
|
.into_iter()
|
||||||
|
.chain(switching_root.then_some(ScreenInput::FullRepaint))
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|
||||||
struct BootTracker {
|
struct BootTracker {
|
||||||
scope: Scope,
|
scope: Scope,
|
||||||
target: RootRequest,
|
target: RootRequest,
|
||||||
@@ -160,9 +168,9 @@ impl BusFeed {
|
|||||||
}
|
}
|
||||||
Link::Connected(connection) => {
|
Link::Connected(connection) => {
|
||||||
let received = self.tracker.receive(connection).await;
|
let received = self.tracker.receive(connection).await;
|
||||||
|
let switching_root = matches!(self.tracker.root_switch, RootSwitch::Queued(_));
|
||||||
Some(match received {
|
Some(match received {
|
||||||
Ok(changes) if changes.is_empty() => Vec::new(),
|
Ok(changes) => connected_inputs(changes, switching_root),
|
||||||
Ok(changes) => vec![ScreenInput::Boot(changes)],
|
|
||||||
Err(_) => self.lose_connection(),
|
Err(_) => self.lose_connection(),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -184,7 +192,7 @@ impl BusFeed {
|
|||||||
Ok(changes) => vec![ScreenInput::Boot(changes), ScreenInput::FullRepaint],
|
Ok(changes) => vec![ScreenInput::Boot(changes), ScreenInput::FullRepaint],
|
||||||
Err(_) if Instant::now() < deadline => {
|
Err(_) if Instant::now() < deadline => {
|
||||||
sleep(BACKGROUND_CHECK_INTERVAL).await;
|
sleep(BACKGROUND_CHECK_INTERVAL).await;
|
||||||
Vec::new()
|
vec![ScreenInput::FullRepaint]
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
self.link = Link::Finished;
|
self.link = Link::Finished;
|
||||||
@@ -546,6 +554,23 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn the_screen_is_repainted_only_while_the_root_switches() {
|
||||||
|
assert!(connected_inputs(Vec::new(), false).is_empty());
|
||||||
|
assert!(matches!(
|
||||||
|
connected_inputs(Vec::new(), true).as_slice(),
|
||||||
|
[ScreenInput::FullRepaint]
|
||||||
|
));
|
||||||
|
assert!(matches!(
|
||||||
|
connected_inputs(vec![BootChange::ForgetJobs], true).as_slice(),
|
||||||
|
[ScreenInput::Boot(_), ScreenInput::FullRepaint]
|
||||||
|
));
|
||||||
|
assert!(matches!(
|
||||||
|
connected_inputs(vec![BootChange::ForgetJobs], false).as_slice(),
|
||||||
|
[ScreenInput::Boot(_)]
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
fn in_state(state: ActiveState) -> Activity {
|
fn in_state(state: ActiveState) -> Activity {
|
||||||
Activity {
|
Activity {
|
||||||
state: Some(state),
|
state: Some(state),
|
||||||
|
|||||||
@@ -270,7 +270,10 @@ While it runs, bootvine:
|
|||||||
`/proc/sys/kernel/printk` to 1, so only emergency messages reach the
|
`/proc/sys/kernel/printk` to 1, so only emergency messages reach the
|
||||||
screen, and sets it again if something raises it;
|
screen, and sets it again if something raises it;
|
||||||
- **silences systemd's status output** with the manager's `SetShowStatus`
|
- **silences systemd's status output** with the manager's `SetShowStatus`
|
||||||
call.
|
call;
|
||||||
|
- **repaints every cell every 100 ms during a root switch**, because PID 1
|
||||||
|
writes to the console and resets it while it re-executes, and drawing only
|
||||||
|
the cells that changed would leave that on screen.
|
||||||
|
|
||||||
It restores the log level and the status output when it hands the console
|
It restores the log level and the status output when it hands the console
|
||||||
back. Kernel messages from before it starts are already on screen; see
|
back. Kernel messages from before it starts are already on screen; see
|
||||||
|
|||||||
Reference in new issue
Block a user