Open ZeroX-DG opened 2 months ago
Spawning the async task with tokio is probabl causing this, just move the task out of it
spawn(async move {
while let Ok(event) = terminal_event_rx.recv() {
match event {
TerminalEvent::Redraw {
lines,
cursor,
scroll_top,
} => {
*rendered_lines.write() = lines;
*rendered_cursor.write() = (cursor.x, cursor.y as usize);
*rendered_scroll_top.write() = scroll_top;
}
}
}
});
Moving it outside the tokio task will actually block the main thread & the app freezes. I tried using std::thread::spawn
instead of dioxus spawn but the error still persist.
Can't you just use a non-blocking, async-friendly channel instead of crossbeam ? Like https://docs.rs/tokio/latest/tokio/sync/mpsc/fn.unbounded_channel.html
I've just switched to flume
to have async recv channel:
https://github.com/ZeroX-DG/raven/blob/db0b86052b4fbc101562990d9678c19df2482dd0/src/components/content_area.rs#L63
But now I run into the old bug in https://github.com/marc2332/freya/issues/602. Maybe something is blocking the thread again 😢 I'll investigate more.
Can you try with tokio just in case?
Btw I wonder if for the terminal renderer it would be better to use the canvas directly, that would surely be more performant
Yep. Same thing happen using tokio channel.
thread 'main' panicked at /Users/viethung/.cargo/git/checkouts/freya-aa88117f1f713ee2/7b68806/crates/core/src/dom/mutations_writer.rs:46:60:
called `Option::unwrap()` on a `None` value
Here's my branch for the tokio channel if you want to check it out: https://github.com/ZeroX-DG/raven/tree/tokio-channel
But yeah. Implementing in cavas would indeed be more performant & avoid blocking UI thread problem. I'll try that instead!
Is this still an issue? 👀
I have no idea haha. I switched to using canvas & don't run into this issue any more 😂
I'll test the old code with the latest freya version.
I ran into this issue when I have a
SyncSignal
being updated in a thread. I think it got something to do with it being set too quickly between render? 🤔Here is the error that I got:
Here's a link to that line that the error was complaining about:
https://github.com/ZeroX-DG/raven/blob/112e867d68d61d2b5a78f7cddac9e4f7e02a44a1/src/components/content_area.rs#L71 #