input stops working when rendering too often
- Dominant language
- Go
- Stars
- 13.6k
- Forks
- 819
- PR merge metrics
- No merged PRs in 30d
Description
Looks like a bug or a race, but I can't pinpoint the exact reason. Consider the following snippet:
```
package main
import (
"flag"
"fmt"
"log"
ui "github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"
)
type state struct {
pressed uint
draw uint
}
func prompt(st *state) {
st.draw++
ui.Clear()
p := widgets.NewParagraph()
p.Text = fmt.Sprintf("[%v] pressed %v times", st.draw, st.pressed)
p.SetRect(0, 0, 25, 5)
ui.Render(p)
}
func main() {
flag.Parse()
if err := ui.Init(); err != nil {
log.Fatalf("failed to initialize termui: %v", err)
}
defer ui.Close()
st := &state{}
prompt(st)
events := ui.PollEvents()
for {
e := <-events
st.pressed++
if e.Type == ui.KeyboardEvent && e.ID == "" {
break
}
prompt(st)
}
}
```
I'm running this on Linux, At a point where I reach ~80 key presses, the input stops working. I've written a small snippet that uses only `termbox-go` to read input and print the state, and the input does not block. Using `ui.PollEvents()` and rendering test through `termbox-go` works well too. However, combining `ui.Render()` and `ui.PollEvents()`, blocks after registering some number of input events.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the provided Go reproducer and inspect the interaction between ui.Render() and ui.PollEvents(). Compare it with the termbox-go-only input test and the version that polls events without rendering; done means repeated rendering continues accepting keyboard input beyond roughly 80 presses.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100