fix: keep crash-restart off the GUI message-pump thread
Some checks are pending
Continuous integration / test (push) Waiting to run

start() ended with rx.recv().unwrap(), so every caller blocked until
the server reported readiness. process_event runs on the NWG message
pump and is invoked when crash_notice fires; the modal_error_message
returns, start() is called, and the entire UI freezes for up to 60s
while the new stremio-runtime boots.

Return the readiness receiver from start() instead of consuming it.
build_partial keeps the synchronous wait for initial startup so the
WebView isn't attached against a not-yet-bound port. process_event
fires-and-forgets so the GUI keeps pumping; if the new runtime also
fails, the server thread will simply fire crash_notice again.

Closes #49
This commit is contained in:
Timothy Z. 2026-05-10 12:39:32 +00:00
parent 46d152dfc5
commit d61dfb9073

View file

@ -78,13 +78,14 @@ pub struct StremioServer {
}
impl StremioServer {
pub fn start(&self) {
/// Spawn the streaming server; recv on the returned receiver to wait for readiness.
pub fn start(&self) -> Option<flume::Receiver<String>> {
if self.development {
return;
return None;
}
if self.running.swap(true, Ordering::SeqCst) {
eprintln!("StremioServer::start() called while a server is already running; skipping");
return;
return None;
}
let (tx, rx) = flume::unbounded();
let logs = self.logs.clone();
@ -220,8 +221,7 @@ impl StremioServer {
sender.notice();
});
// Wait for the server to start
rx.recv().unwrap();
Some(rx)
}
}
@ -240,7 +240,10 @@ impl PartialUi for StremioServer {
.parent(data.parent)
.build(&mut data.crash_notice)
.ok();
data.start();
// Block until ready so the WebView isn't attached against an unbound port.
if let Some(rx) = data.start() {
rx.recv().ok();
}
println!("Stremio server started");
Ok(())
}
@ -257,6 +260,7 @@ impl PartialUi for StremioServer {
"Stremio server crash log",
self.logs.lock().unwrap().deref(),
);
// Don't block: this runs on the GUI message pump.
self.start();
}
}