mirror of
https://github.com/rivo/tview.git
synced 2026-04-27 05:45:49 +03:00
[GH-ISSUE #569] Deadlock when calling Application.Draw from within the event loop #416
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/tview#416
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 @forejtv on GitHub (Mar 3, 2021).
Original GitHub issue: https://github.com/rivo/tview/issues/569
The following code hangs after pressing Enter:
The important part is the
app.Draw()call within an event handler for list item. In my understanding of tview's internals, the issue is that the event handler runs from within the event loop and it waits forapp.Draw()call to finish, but it will not be finished until the current event loop iteration (the even handler itself) finishes. Hence the execution hangs.I am not sure if this is expected. If yes, then the the wiki statement at https://github.com/rivo/tview/wiki/concurrency which says
could probably be strengthened to
@rivo commented on GitHub (Mar 11, 2021):
That's a good catch. I actually didn't realize calling
Draw()from an event handler would lead to a deadlock. I was tempted to moveDraw()into its own goroutine (which would resolve the deadlock, I believe) but at the moment, I don't know if that would result in any undesired side effects. For sure, it may lead to users calling the function in an event handler (as in your example), resulting in multiple (unnecessary) calls toDraw(). So it's probably better to just clarify it like you suggested.I've modified the Wiki (and the function comments) accordingly. Thanks.