[GH-ISSUE #797] Window freeze if selecting textview #588

Closed
opened 2026-03-04 01:06:15 +03:00 by kerem · 5 comments
Owner

Originally created by @dingxiong on GitHub (Jan 22, 2023).
Original GitHub issue: https://github.com/rivo/tview/issues/797

Hey guys, I encounter a problem with textview in a form. The window freezes after I try to select a text view.

The tview version I am using is v0.0.0-20230104153304-892d1a2eb0da. The code is

package main

import (
        "github.com/rivo/tview"
)

func main() {
        app := tview.NewApplication()
        form := tview.NewForm().
                AddDropDown("Env", []string{"production"}, 0, func(option string, index int){

                }).
                AddInputField("env", "", 20, nil, nil).
                AddInputField("Last name", "", 20, nil, nil).
                AddTextArea("Address", "", 40, 0, 0, nil).
                AddTextView("Notes", "This is just a demo.\nYou can enter whatever you wish.", 40, 2, true, false).
                AddCheckbox("Age 18+", false, nil).
                AddPasswordField("Password", "", 10, '*', nil).
                AddButton("Save", nil).
                AddButton("Quit", func() {
                        app.Stop()
                })
        form.SetBorder(true).SetTitle("Enter some data").SetTitleAlign(tview.AlignLeft)
        if err := app.SetRoot(form, true).EnableMouse(true).Run(); err != nil {
                panic(err)
        }
}
Screenshot 2023-01-21 at 7 46 41 PM

I tried to select the the notes fields This is just a demo. multiple times, then the UI freezes. By selection, I mean I put the mouse cursor on the message, and press the muse left button, and scroll to the right.

Below is the debug info.

$ dlv attach 44630
Type 'help' for list of commands.
(dlv) grs
  Goroutine 1 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/sema.go:77 sync.runtime_SemacquireMutex (0x100d31984) [semacquire]
  Goroutine 2 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:364 runtime.gopark (0x100d08f74) [force gc (idle)]
  Goroutine 3 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:364 runtime.gopark (0x100d08f74) [GC sweep wait]
  Goroutine 4 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:364 runtime.gopark (0x100d08f74) [GC scavenge wait]
  Goroutine 5 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/sigqueue.go:149 os/signal.signal_recv (0x100d31b5c) (thread 5332337)
  Goroutine 6 - User: /Users/xiongding/go/pkg/mod/github.com/gdamore/tcell/v2@v2.5.3/tscreen.go:1700 github.com/gdamore/tcell/v2.(*tScreen).inputLoop (0x100dd05c0) [chan send]
  Goroutine 7 - User: /Users/xiongding/go/pkg/mod/github.com/gdamore/tcell/v2@v2.5.3/tscreen.go:1183 github.com/gdamore/tcell/v2.(*tScreen).mainLoop (0x100dd02d8) [chan send]
  Goroutine 8 - User: /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:765 github.com/rivo/tview.(*Application).Run.func2 (0x100dd3db0) [chan send]
  Goroutine 17 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:364 runtime.gopark (0x100d08f74) [finalizer wait]
  Goroutine 18 - User: /Users/xiongding/go/pkg/mod/github.com/gdamore/tcell/v2@v2.5.3/tty_unix.go:92 github.com/gdamore/tcell/v2.(*devTty).Start.func1 (0x100dd1794) [select]
  Goroutine 19 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:364 runtime.gopark (0x100d08f74) [select]
[11 goroutines]

seems goroutine get stuck at acquiring a mutex. below is the stack trace of goroutine 1.

0  0x0000000100d08f74 in runtime.gopark
    at /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:364
 1  0x0000000100d19cac in runtime.goparkunlock
    at /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:369
 2  0x0000000100d19cac in runtime.semacquire1
    at /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/sema.go:150
 3  0x0000000100d31984 in sync.runtime_SemacquireMutex
    at /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/sema.go:77
 4  0x0000000100d3a248 in sync.(*Mutex).lockSlow
    at /opt/homebrew/Cellar/go/1.19.2/libexec/src/sync/mutex.go:171
 5  0x0000000100de94bc in sync.(*Mutex).Lock
    at /opt/homebrew/Cellar/go/1.19.2/libexec/src/sync/mutex.go:90
 6  0x0000000100de94bc in github.com/rivo/tview.(*TextView).Focus
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/textview.go:761
 7  0x0000000100dd4c3c in github.com/rivo/tview.(*Application).SetFocus
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:717
 8  0x0000000100dd4ca4 in github.com/rivo/tview.(*Application).SetFocus.func1
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:718
 9  0x0000000100ddad24 in github.com/rivo/tview.(*Form).Focus.func2.1
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/form.go:710
10  0x0000000100ddaca8 in github.com/rivo/tview.(*Form).Focus.func2
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/form.go:711
11  0x0000000100ddaa38 in github.com/rivo/tview.(*Form).Focus
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/form.go:711
12  0x0000000100ddadc0 in github.com/rivo/tview.(*Form).Focus.func1
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/form.go:683
13  0x0000000100ddae48 in github.com/rivo/tview.(*Form).Focus.func1
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/form.go:700
14  0x0000000100de9520 in github.com/rivo/tview.(*TextView).Focus
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/textview.go:768
15  0x0000000100dd4c3c in github.com/rivo/tview.(*Application).SetFocus
15  0x0000000100dd4c3c in github.com/rivo/tview.(*Application).SetFocus
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:717
16  0x0000000100dd4664 in github.com/rivo/tview.(*Application).fireMouseActions.func1.1
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:431
17  0x0000000100ded5b8 in github.com/rivo/tview.(*TextView).MouseHandler.func1
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/textview.go:1469
18  0x0000000100dd4fd4 in github.com/rivo/tview.(*Box).WrapMouseHandler.func1
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/box.go:209
19  0x0000000100ddb240 in github.com/rivo/tview.(*Form).MouseHandler.func1
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/form.go:764
20  0x0000000100dd4fd4 in github.com/rivo/tview.(*Box).WrapMouseHandler.func1
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/box.go:209
21  0x0000000100dd45ac in github.com/rivo/tview.(*Application).fireMouseActions.func1
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:430
22  0x0000000100dd41c4 in github.com/rivo/tview.(*Application).fireMouseActions
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:462
23  0x0000000100dd3924 in github.com/rivo/tview.(*Application).Run
    at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:366
24  0x0000000100df39e4 in main.main
    at /Users/xiongding/code/career/tutorials/tview-example/main.go:24
25  0x0000000100d08bac in runtime.main
    at /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:250
26  0x0000000100d35704 in runtime.goexit
    at /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172

Any idea of what is happening here?

Originally created by @dingxiong on GitHub (Jan 22, 2023). Original GitHub issue: https://github.com/rivo/tview/issues/797 Hey guys, I encounter a problem with textview in a form. The window freezes after I try to select a text view. The tview version I am using is `v0.0.0-20230104153304-892d1a2eb0da`. The code is ``` package main import ( "github.com/rivo/tview" ) func main() { app := tview.NewApplication() form := tview.NewForm(). AddDropDown("Env", []string{"production"}, 0, func(option string, index int){ }). AddInputField("env", "", 20, nil, nil). AddInputField("Last name", "", 20, nil, nil). AddTextArea("Address", "", 40, 0, 0, nil). AddTextView("Notes", "This is just a demo.\nYou can enter whatever you wish.", 40, 2, true, false). AddCheckbox("Age 18+", false, nil). AddPasswordField("Password", "", 10, '*', nil). AddButton("Save", nil). AddButton("Quit", func() { app.Stop() }) form.SetBorder(true).SetTitle("Enter some data").SetTitleAlign(tview.AlignLeft) if err := app.SetRoot(form, true).EnableMouse(true).Run(); err != nil { panic(err) } } ``` <img width="407" alt="Screenshot 2023-01-21 at 7 46 41 PM" src="https://user-images.githubusercontent.com/5496402/213897039-a8ccc07d-32ff-41db-bed2-353c6a1241ae.png"> I tried to select the the notes fields `This is just a demo.` multiple times, then the UI freezes. By selection, I mean I put the mouse cursor on the message, and press the muse left button, and scroll to the right. Below is the debug info. ``` $ dlv attach 44630 Type 'help' for list of commands. (dlv) grs Goroutine 1 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/sema.go:77 sync.runtime_SemacquireMutex (0x100d31984) [semacquire] Goroutine 2 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:364 runtime.gopark (0x100d08f74) [force gc (idle)] Goroutine 3 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:364 runtime.gopark (0x100d08f74) [GC sweep wait] Goroutine 4 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:364 runtime.gopark (0x100d08f74) [GC scavenge wait] Goroutine 5 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/sigqueue.go:149 os/signal.signal_recv (0x100d31b5c) (thread 5332337) Goroutine 6 - User: /Users/xiongding/go/pkg/mod/github.com/gdamore/tcell/v2@v2.5.3/tscreen.go:1700 github.com/gdamore/tcell/v2.(*tScreen).inputLoop (0x100dd05c0) [chan send] Goroutine 7 - User: /Users/xiongding/go/pkg/mod/github.com/gdamore/tcell/v2@v2.5.3/tscreen.go:1183 github.com/gdamore/tcell/v2.(*tScreen).mainLoop (0x100dd02d8) [chan send] Goroutine 8 - User: /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:765 github.com/rivo/tview.(*Application).Run.func2 (0x100dd3db0) [chan send] Goroutine 17 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:364 runtime.gopark (0x100d08f74) [finalizer wait] Goroutine 18 - User: /Users/xiongding/go/pkg/mod/github.com/gdamore/tcell/v2@v2.5.3/tty_unix.go:92 github.com/gdamore/tcell/v2.(*devTty).Start.func1 (0x100dd1794) [select] Goroutine 19 - User: /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:364 runtime.gopark (0x100d08f74) [select] [11 goroutines] ``` seems goroutine get stuck at acquiring a mutex. below is the stack trace of goroutine 1. ``` 0 0x0000000100d08f74 in runtime.gopark at /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:364 1 0x0000000100d19cac in runtime.goparkunlock at /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:369 2 0x0000000100d19cac in runtime.semacquire1 at /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/sema.go:150 3 0x0000000100d31984 in sync.runtime_SemacquireMutex at /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/sema.go:77 4 0x0000000100d3a248 in sync.(*Mutex).lockSlow at /opt/homebrew/Cellar/go/1.19.2/libexec/src/sync/mutex.go:171 5 0x0000000100de94bc in sync.(*Mutex).Lock at /opt/homebrew/Cellar/go/1.19.2/libexec/src/sync/mutex.go:90 6 0x0000000100de94bc in github.com/rivo/tview.(*TextView).Focus at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/textview.go:761 7 0x0000000100dd4c3c in github.com/rivo/tview.(*Application).SetFocus at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:717 8 0x0000000100dd4ca4 in github.com/rivo/tview.(*Application).SetFocus.func1 at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:718 9 0x0000000100ddad24 in github.com/rivo/tview.(*Form).Focus.func2.1 at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/form.go:710 10 0x0000000100ddaca8 in github.com/rivo/tview.(*Form).Focus.func2 at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/form.go:711 11 0x0000000100ddaa38 in github.com/rivo/tview.(*Form).Focus at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/form.go:711 12 0x0000000100ddadc0 in github.com/rivo/tview.(*Form).Focus.func1 at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/form.go:683 13 0x0000000100ddae48 in github.com/rivo/tview.(*Form).Focus.func1 at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/form.go:700 14 0x0000000100de9520 in github.com/rivo/tview.(*TextView).Focus at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/textview.go:768 15 0x0000000100dd4c3c in github.com/rivo/tview.(*Application).SetFocus 15 0x0000000100dd4c3c in github.com/rivo/tview.(*Application).SetFocus at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:717 16 0x0000000100dd4664 in github.com/rivo/tview.(*Application).fireMouseActions.func1.1 at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:431 17 0x0000000100ded5b8 in github.com/rivo/tview.(*TextView).MouseHandler.func1 at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/textview.go:1469 18 0x0000000100dd4fd4 in github.com/rivo/tview.(*Box).WrapMouseHandler.func1 at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/box.go:209 19 0x0000000100ddb240 in github.com/rivo/tview.(*Form).MouseHandler.func1 at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/form.go:764 20 0x0000000100dd4fd4 in github.com/rivo/tview.(*Box).WrapMouseHandler.func1 at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/box.go:209 21 0x0000000100dd45ac in github.com/rivo/tview.(*Application).fireMouseActions.func1 at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:430 22 0x0000000100dd41c4 in github.com/rivo/tview.(*Application).fireMouseActions at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:462 23 0x0000000100dd3924 in github.com/rivo/tview.(*Application).Run at /Users/xiongding/go/pkg/mod/github.com/rivo/tview@v0.0.0-20230104153304-892d1a2eb0da/application.go:366 24 0x0000000100df39e4 in main.main at /Users/xiongding/code/career/tutorials/tview-example/main.go:24 25 0x0000000100d08bac in runtime.main at /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/proc.go:250 26 0x0000000100d35704 in runtime.goexit at /opt/homebrew/Cellar/go/1.19.2/libexec/src/runtime/asm_arm64.s:1172 ``` Any idea of what is happening here?
kerem closed this issue 2026-03-04 01:06:16 +03:00
Author
Owner

@dingxiong commented on GitHub (Jan 26, 2023):

@digitallyserviced Thanks. I can try. What is the focused above?
The code I have is copied from https://github.com/rivo/tview/blob/master/demos/form/main.go
Does it mean that the demo example also need to be updated?

<!-- gh-comment-id:1404576605 --> @dingxiong commented on GitHub (Jan 26, 2023): @digitallyserviced Thanks. I can try. What is the `focused` above? The code I have is copied from https://github.com/rivo/tview/blob/master/demos/form/main.go Does it mean that the demo example also need to be updated?
Author
Owner

@dingxiong commented on GitHub (Jan 27, 2023):

Hi @digitallyserviced thanks for a quick reply. Yeah. I am using OSX Iterm2, but not in tmux or ssh.

I made a recording below. Each time I selected the textview, the focus moved to the next row until it hit textview itself, it then get stuck and become unresponsive.

https://user-images.githubusercontent.com/5496402/215018170-d5b9c8c6-bb76-4005-bc9f-8ea9910acd66.mov

<!-- gh-comment-id:1406050115 --> @dingxiong commented on GitHub (Jan 27, 2023): Hi @digitallyserviced thanks for a quick reply. Yeah. I am using OSX Iterm2, but not in tmux or ssh. I made a recording below. Each time I selected the textview, the focus moved to the next row until it hit textview itself, it then get stuck and become unresponsive. https://user-images.githubusercontent.com/5496402/215018170-d5b9c8c6-bb76-4005-bc9f-8ea9910acd66.mov
Author
Owner

@dingxiong commented on GitHub (Jan 27, 2023):

Thanks for a quick fix. Sorry how to include your change? I tried to follow https://stackoverflow.com/questions/42761820/how-to-get-another-branch-instead-of-default-branch-with-go-get but seems not working.

<!-- gh-comment-id:1407192017 --> @dingxiong commented on GitHub (Jan 27, 2023): Thanks for a quick fix. Sorry how to include your change? I tried to follow https://stackoverflow.com/questions/42761820/how-to-get-another-branch-instead-of-default-branch-with-go-get but seems not working.
Author
Owner

@dingxiong commented on GitHub (Feb 8, 2023):

@digitallyserviced Thanks. go mod edit -replace works for me. The patch works great!
Any estimation when the patch will be merged?

<!-- gh-comment-id:1421725081 --> @dingxiong commented on GitHub (Feb 8, 2023): @digitallyserviced Thanks. `go mod edit -replace` works for me. The patch works great! Any estimation when the patch will be merged?
Author
Owner

@rivo commented on GitHub (Feb 8, 2023):

Text views in forms are read-only elements and thus should not be selectable. The keyboard input handler already handled this but this affected the mouse handler in the wrong way. Should be fixed now.

<!-- gh-comment-id:1423248349 --> @rivo commented on GitHub (Feb 8, 2023): Text views in forms are read-only elements and thus should not be selectable. The keyboard input handler already handled this but this affected the mouse handler in the wrong way. Should be fixed now.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/tview#588
No description provided.