tui-realm icon indicating copy to clipboard operation
tui-realm copied to clipboard

[BUG] - Ports are seemingly only polled once per event loop

Open hasezoey opened this issue 3 months ago • 0 comments

Description

From what i can tell, currently Ports (like crossterm) are only polled once per loop in the EventListenerWorker, basically making PollStrategy::UpTo(10) ineffective and having at most 2 events (one port, one tick) when not using extra ports than default input.

Steps to reproduce

Have a tuirealm 1.9 app (or one of the examples) and try to use PollStrategy::UpTo(10), log the amount of messages you get each .tick call and move the mouse a lot over the terminal (#70), observe only having on average 1 event and at most 2 events per call.

Expected behaviour

Should poll a port until it does not return anything anymore, or make it configurable how much a port is polled.

Environment

  • OS: Linux Manjaro 23.1.3
  • Architecture x86_64
  • Rust version 1.76.0
  • tui-realm version 1.9.2

Additional information

My guess is this happens because of the following code:

https://github.com/veeso/tui-realm/blob/b33a430b6dca3489b88f4a68b4e566df39ce4054/src/listener/worker.rs#L121-L138

there the x.poll always only returns one result, and so overall only polling each port once for one event per event loop:

https://github.com/veeso/tui-realm/blob/b33a430b6dca3489b88f4a68b4e566df39ce4054/src/listener/worker.rs#L154-L173

and then sleeping after the loop until the interval_time and only then getting the next event, and so basically making PollStrategy::UpTo(10) not a viable thing, whereas PollStrategy::UpTo(100) might get more events on very slow processors, and so makes it very ineffective and potentially inconsistent.

hasezoey avatar Mar 17 '24 14:03 hasezoey