mirror of
https://github.com/rivo/tview.git
synced 2026-04-26 13:25:51 +03:00
[GH-ISSUE #244] Tview stuck in infinite loop after shelling out.... #187
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#187
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @derailed on GitHub (Mar 1, 2019).
Original GitHub issue: https://github.com/rivo/tview/issues/244
Hi,
First off thank you for this great project! I am having an issue in the latest code base while shelling out using Suspend. I issue a command and forward stdin, stdout, stderr. When the command completes tview is completely non responsive and the screen is partially drawn + cpu pegged. Ctrl-C has no effect. It seems I am stuck in a screen rendering loop somewhere. Any advise or things I could try out? Thanks! BTW this used to work fine a few month ago....
@rivo commented on GitHub (Mar 9, 2019):
I just tried this myself but couldn't reproduce your problem. Could you send a short code snippet that illustrates this?
@k8sland commented on GitHub (Mar 12, 2019):
@rivo thanks for looking into it and for tview!!
I think there is a race in this code (link below) where we init the new screen after it's been set in the application when the app is suspended. I've moved the lock block after the init and this seem to be working now. This is hard to repro as I think the draw routine timing is a play here...
Here is a ref:
github.com/rivo/tview@3938f60085/application.go (L189)Thanks!
@rivo commented on GitHub (May 13, 2019):
@k8sland Do you mean you set
a.screenbetween the call toInit()anda.draw()and that solved it?@rivo commented on GitHub (Jun 26, 2019):
Will reopen when there is more information.
@derricw commented on GitHub (May 7, 2020):
I'm experiencing this same issue. I am using
app.Suspendto run Vim and compose a document. About 1/3 of the time, tview seems to get into some kind of infinite loop where it becomes unresponsive and pegs CPU. The other 2/3 of the time it works correctly.Code snippet looks like this:
And
FancyComposelooks like this:@raziman18 commented on GitHub (Jul 24, 2020):
I have this issue before but I solved it by making sure there are no tview widgets methods being called when calling
app.Suspendalso this workaround doesn't work
@lenormf commented on GitHub (Feb 1, 2021):
I'm hitting this issue, and it's making my program useless because it locks up constantly.
Here's a standalone reproducer:
When I
stracethe process, I see that it's stuck on a call tofutex(0x675688, FUTEX_WAIT_PRIVATE, 0, NULLand it takes 100% of the CPU.Any ideas?
@lenormf commented on GitHub (Feb 8, 2021):
@rivo Could we please re-open this, we have a reproducer and several reports of the issue occurring, it'd be nice to have a workaround — or even better, a hot fix.
@rivo commented on GitHub (Apr 26, 2021):
I tried this with your code and there was no deadlock. We're on
tcellv2 now and work has been done on suspending applications. Maybe that has fixed it?Can you please let me know if this is still an issue?
@lenormf commented on GitHub (Apr 27, 2021):
It looks like the issue went away with
tcell/v2. One side effect (potentially unrelated) seems to be that inputs are buffered, and hitting e won't do anything until another key is hit.@rivo commented on GitHub (Apr 27, 2021):
I didn't experience this. I tried it on macOS with iTerm2 and hitting e immediately sent me to my editor. What OS and terminal are you on?
@lenormf commented on GitHub (Apr 27, 2021):
I'm using ArchLinux, the same issue is reproducible with Kitty (
v0.20.1) and Xterm (v367) for me.@rivo commented on GitHub (Apr 27, 2021):
I'm sorry but I don't have any way to test and debug it on these systems. Key events are produced by
tcelland consumed bytviewhere:github.com/rivo/tview@09cec83b17/application.go (L267)Then they are queued and picked up again here:
github.com/rivo/tview@09cec83b17/application.go (L303)You may want to check if this code gets executed when you press e. If the
screen.PollEvent()function doesn't even return when it's pressed, then it's an issue oftcelland you might want to open an issue there. If it returns with the correct*tcell.EventKeyevent, we can take it from there over here.@derailed commented on GitHub (Apr 27, 2021):
@lenormf - which version of tcell are you running? I think tcell v2.2.1 or later contains a fix for the first char being swallowed during suspend/resume operations...
@lenormf commented on GitHub (Apr 27, 2021):
I'm using
v2.2.1.The first e is not swallowed up, I just have to hit another key for it to be executed.
The other weird thing is if I double tap e, the editor spawns (first e). When I quit the editor, the program resumes. If I hit another key, the editor spawns again (second e, for the double tap). So it looks like keys are buffered, until the buffer hits a size of 2.
The issue also occurs with different values of
$EDITOR.@rivo commented on GitHub (Apr 27, 2021):
Well, for sure
tviewdoesn't buffer any key events.@jeewangue commented on GitHub (May 2, 2021):
@lenormf
I had exactly the same issue with Arch Linux & termite.
I had to press any other keys whenever
app.stop()is executed by a keystroke.versions:
09cec83(latest by now)v2.2.1IMO the issue is related to https://github.com/gdamore/tcell/issues/452, saying that
for the quick fix, I just downgraded tview to
7df0389and tcell tov2.2.0(not really far from the latest, 6 days ago from now)
@gdamore commented on GitHub (May 19, 2021):
tcell's issue 452 is fixed now... please retest.
@rivo commented on GitHub (May 20, 2021):
Echoing @gdamore here, please let us know if the problem still persists with the latest version.
@dundee commented on GitHub (Sep 1, 2021):
I am getting
panic: read /dev/tty: i/o timeouton ArchLinux.Code the same as in https://github.com/rivo/tview/issues/244#issuecomment-770851919 except using
tcell/v2.Tried multiple shells and terminals.
@rivo commented on GitHub (Sep 2, 2021):
@dundee Could you please run the program listed here: https://github.com/gdamore/tcell/issues/480 and let me know if this results in the same error?
@dundee commented on GitHub (Sep 3, 2021):
Yes, same error. I will paste details there.
@gdamore commented on GitHub (Sep 3, 2021):
So, does this only happen on ArchLinux? I wonder if there is a bug in the terminal code there.
The panic indicates a timeout reading from /dev/tty, but I don't think we actually attempt to read from that -- we issue a ioctls in the code path that has the panic, but not reads.
Which version of ArchLinux are you using? I unfortunately don't have any experience with Arch, but I don't want to burn cycles trying to fix a problem only to find I can't reproduce it because I don't have the right version of Arch.
@dundee commented on GitHub (Sep 5, 2021):
I can confirm that the fix from https://github.com/gdamore/tcell/issues/480 fixes this issue as well.
@dundee commented on GitHub (Sep 8, 2021):
Looks like some problem still persists on Windows.
The test script in https://github.com/gdamore/tcell/issues/480 works but tview application is not able to resume after being paused. It falls into deadlock:
Not sure if it's worth the debugging though :)
@dundee commented on GitHub (Sep 8, 2021):
Minimal example:
This example doesn't crash on the first suspend but on the second one:
@gdamore commented on GitHub (Sep 8, 2021):
Interesting -- I tested this on Linux, but not Windows. I guess maybe there is a completely separate bug on Windows. One thing I did try is the mouse.go demo -- which goes through this several times.
@bcspragu commented on GitHub (Oct 15, 2023):
EDIT: Adding an
app.Sync()after theapp.Suspendcall fixed my issue.Found this issue after hitting the same thing with a more/less identical chunk of code. Relevant snippet:
The editor opens fine, but the program hangs after closing. I'm on Arch Linux, using alacritty + tmux, and using the latest versions of both tview (
6c844bdc5f7a) and tcell (v2.6.0). The whole TUI app is available here: https://git.sr.ht/~bsprague/logseq-ui/tree/main/item/tui/tui.go@bcspragu commented on GitHub (Oct 20, 2023):
I'm not the original poster, just someone who ran into the same behavior, but I was indeed able to fix the problem by adding an
app.Sync(), so it may or may not be related to the underlying issue other folks have mentioned here.