Giter VIP home page Giter VIP logo

Comments (8)

marc2332 avatar marc2332 commented on July 18, 2024

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;
              }
          }
      }
  });

from freya.

ZeroX-DG avatar ZeroX-DG commented on July 18, 2024

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.

from freya.

marc2332 avatar marc2332 commented on July 18, 2024

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

from freya.

ZeroX-DG avatar ZeroX-DG commented on July 18, 2024

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 #602. Maybe something is blocking the thread again 😢 I'll investigate more.

from freya.

marc2332 avatar marc2332 commented on July 18, 2024

Can you try with tokio just in case?

from freya.

marc2332 avatar marc2332 commented on July 18, 2024

Btw I wonder if for the terminal renderer it would be better to use the canvas directly, that would surely be more performant

from freya.

ZeroX-DG avatar ZeroX-DG commented on July 18, 2024

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

from freya.

ZeroX-DG avatar ZeroX-DG commented on July 18, 2024

But yeah. Implementing in cavas would indeed be more performant & avoid blocking UI thread problem. I'll try that instead!

from freya.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.