Skip to content

Hangs on repeated calls to SetSelected in table. #3684

Closed
@dhowlett99

Description

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

Using the latest version fyne.io/fyne/v2 v2.3.1 on Mac Catalina 10.15.7, go version go1.20 darwin/amd64

I'm building a table which has multiple widget types (wrapped in a container) in each field of the table.
Hide and Show are called to build a table with multiple widget types see screenshot.

I use SetSelected to set the correct option from an array of options in the select widgets of the table.

If you replace the SetSelected calls with just Selected the problem goes away, but the UI shows 'Set Selected' instead of the correct option.

How to reproduce

On a MAC Build the example code and simply scroll up and down and within a few minutes the program will hang and never return.

Screenshots

image

Example code

package main

import (
	"fmt"

	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/widget"
)

const id int = 0
const tpe int = 1
const group int = 2
const number int = 3
const name int = 4
const label int = 5
const desc int = 6
const addr int = 7
const del int = 8
const add int = 9
const channel int = 10

func main() {
	myApp := app.New()
	myWindow := myApp.NewWindow("Table Widget")

	groupOptions := []string{"1", "2", "3", "4"}
	numberOptions := []string{"1", "2", "3", "4", "5", "6", "7", "8"}
	typeOptions := []string{"rgb", "scanner", "switch", "projector"}

	var data = [][]string{}

	// scan the fixtures structure for the selected fixture.
	for fixture := 0; fixture < 32; fixture++ {
		newFixture := []string{}
		newFixture = append(newFixture, fmt.Sprintf("%d", fixture))
		newFixture = append(newFixture, "rgb")
		newFixture = append(newFixture, fmt.Sprintf("%d", 1))
		newFixture = append(newFixture, fmt.Sprintf("%d", 1))
		newFixture = append(newFixture, fmt.Sprintf("name#%d", fixture))
		newFixture = append(newFixture, fmt.Sprintf("label#%d", fixture))
		newFixture = append(newFixture, fmt.Sprintf("desc#%d", fixture))
		newFixture = append(newFixture, fmt.Sprintf("%d", fixture+100))
		newFixture = append(newFixture, "-")
		newFixture = append(newFixture, "+")
		newFixture = append(newFixture, "channel")
		data = append(data, newFixture)
	}

	list := widget.NewTable(

		// Find lenghths.
		func() (int, int) {
			return len(data), len(data[0])
		},

		// Create Table
		func() (o fyne.CanvasObject) {
			return container.NewMax(
				widget.NewLabel(""), //id 0
				widget.NewSelect(typeOptions, func(value string) {}),   // Type 1
				widget.NewSelect(groupOptions, func(value string) {}),  // group 2
				widget.NewSelect(numberOptions, func(value string) {}), //  number 3
				widget.NewEntry(),               // name 4
				widget.NewEntry(),               // label 5
				widget.NewEntry(),               // Desc 6
				widget.NewEntry(),               // address 7
				widget.NewButton("", func() {}), // Delete 8
				widget.NewButton("", func() {}), // Add 9
				widget.NewButton("", func() {}), // Channels 10
			)
		},

		// // Update Tabel
		func(i widget.TableCellID, o fyne.CanvasObject) {
			hideAllFields(o)

			if i.Col == id {
				o.(*fyne.Container).Objects[id].(*widget.Label).Hidden = false
				o.(*fyne.Container).Objects[id].(*widget.Label).SetText(data[i.Row][i.Col])
			}

			if i.Col == tpe {
				o.(*fyne.Container).Objects[tpe].(*widget.Select).Hidden = false
				o.(*fyne.Container).Objects[tpe].(*widget.Select).SetSelected(data[i.Row][i.Col])
			}

			if i.Col == group {
				o.(*fyne.Container).Objects[group].(*widget.Select).Hidden = false
				o.(*fyne.Container).Objects[group].(*widget.Select).SetSelected(data[i.Row][i.Col])
			}
			if i.Col == number {
				o.(*fyne.Container).Objects[number].(*widget.Select).Hidden = false
				o.(*fyne.Container).Objects[number].(*widget.Select).SetSelected(data[i.Row][i.Col])
			}

			if i.Col == name {
				o.(*fyne.Container).Objects[name].(*widget.Entry).Hidden = false
				o.(*fyne.Container).Objects[name].(*widget.Entry).SetText(data[i.Row][i.Col])
			}

			if i.Col == label {
				o.(*fyne.Container).Objects[label].(*widget.Entry).Hidden = false
				o.(*fyne.Container).Objects[label].(*widget.Entry).SetText(data[i.Row][i.Col])
			}

			if i.Col == desc {
				o.(*fyne.Container).Objects[desc].(*widget.Entry).Hidden = false
				o.(*fyne.Container).Objects[desc].(*widget.Entry).SetText(data[i.Row][i.Col])
			}

			if i.Col == addr {
				o.(*fyne.Container).Objects[desc].(*widget.Entry).Hidden = false
				o.(*fyne.Container).Objects[desc].(*widget.Entry).SetText(data[i.Row][i.Col])
			}

			if i.Col == del {
				o.(*fyne.Container).Objects[del].(*widget.Button).Hidden = false
				o.(*fyne.Container).Objects[del].(*widget.Button).SetText(data[i.Row][i.Col])
			}

			if i.Col == add {
				o.(*fyne.Container).Objects[add].(*widget.Button).Hidden = false
				o.(*fyne.Container).Objects[add].(*widget.Button).SetText(data[i.Row][i.Col])
			}

			if i.Col == channel {
				o.(*fyne.Container).Objects[channel].(*widget.Button).Hidden = false
				o.(*fyne.Container).Objects[channel].(*widget.Button).SetText(data[i.Row][i.Col])
			}
		})

	list.SetColumnWidth(id, 40)
	list.SetColumnWidth(tpe, 120)
	list.SetColumnWidth(group, 60)
	list.SetColumnWidth(number, 60)
	list.SetColumnWidth(name, 120)
	list.SetColumnWidth(label, 120)
	list.SetColumnWidth(desc, 300)
	list.SetColumnWidth(addr, 50)
	list.SetColumnWidth(del, 40)
	list.SetColumnWidth(add, 40)
	list.SetColumnWidth(channel, 80)

	myWindow.SetContent(list)

	myWindow.Resize(fyne.NewSize(1100, 400))
	myWindow.ShowAndRun()

}

func hideAllFields(o fyne.CanvasObject) {
	// Hide everything.
	o.(*fyne.Container).Objects[id].(*widget.Label).Hidden = true
	o.(*fyne.Container).Objects[tpe].(*widget.Select).Hidden = true
	o.(*fyne.Container).Objects[group].(*widget.Select).Hidden = true
	o.(*fyne.Container).Objects[number].(*widget.Select).Hidden = true
	o.(*fyne.Container).Objects[name].(*widget.Entry).Hidden = true
	o.(*fyne.Container).Objects[label].(*widget.Entry).Hidden = true
	o.(*fyne.Container).Objects[desc].(*widget.Entry).Hidden = true
	o.(*fyne.Container).Objects[addr].(*widget.Entry).Hidden = true
	o.(*fyne.Container).Objects[del].(*widget.Button).Hidden = true
	o.(*fyne.Container).Objects[add].(*widget.Button).Hidden = true
	o.(*fyne.Container).Objects[channel].(*widget.Button).Hidden = true
}

Fyne version

v2.3.1

Go compiler version

go1.20

Operating system and version

macOS Catalina

Additional Information

Date/Time: 2023-02-26 19:45:27 +0000
End time: 2023-02-26 19:45:47 +0000
OS Version: Mac OS X 10.15.7 (Build 19H2026)
Architecture: x86_64h
Report Version: 29

Data Source: Stackshots
Shared Cache: 0x3471000 B17C1CBE-BC73-34BB-A9C4-DE7487BA1631

Command: table
Path: /Users/USER/*/table
Version: ??? (???)
Parent: bash [6482] [unique pid 106254]
Responsible: Terminal [90652]
PID: 9275

Event: hang
Duration: 19.70s
Duration Sampled: 4.90s (process was unresponsive for 15 seconds before sampling)
Steps: 49 (100ms sampling interval)

Hardware model: MacBookAir7,2
Active cpus: 4

Time Awake Since Boot: 790000s
Time Since Wake: 33000s

Fan speed: 1192 rpm


Timeline format: stacks are sorted chronologically
Use -i and -heavy to re-report with count sorting

Heaviest stack for the main thread of the target process:
49 runtime.mcall + 67 (table + 421731) [0x100066f63]
49 runtime.park_m + 301 (table + 263053) [0x10004038d]
49 runtime.schedule + 61 (table + 261629) [0x10003fdfd]
49 runtime.stoplockedm + 101 (table + 254021) [0x10003e045]
49 runtime.mPark + 37 (table + 246629) [0x10003c365]
49 runtime.notesleep + 133 (table + 59749) [0x10000e965]
49 runtime.semasleep + 173 (table + 211565) [0x100033a6d]
49 runtime.pthread_cond_wait.abi0 + 52 (table + 353268) [0x1000563f4]
49 runtime.asmcgocall.abi0 + 161 (table + 429793) [0x100068ee1]
49 runtime.pthread_cond_wait_trampoline.abi0 + 16 (table + 438416) [0x10006b090]
49 __psynch_cvwait + 10 (libsystem_kernel.dylib + 14450) [0x7fff6a383872]
*49 psynch_cvcontinue + 0 (pthread + 18722) [0xffffff7f82d15922]

Process: table [9275] [unique pid 109046]
UUID: A1A20DF9-B4D3-3378-B665-1053C178D0E2
Path: /Users/USER/*/table
Architecture: x86_64
Parent: bash [6482] [unique pid 106254]
Responsible: Terminal [90652]
UID: 501
Footprint: 73.28 MB
Start time: 2023-02-26 19:45:42 +0000
End time: 2023-02-26 19:45:47 +0000
Num samples: 49 (1-49)
CPU Time: 0.055s (54.3M cycles, 12.7M instructions, 4.26c/i)
Note: Unresponsive for 15 seconds before sampling
Note: 1 idle work queue thread omitted

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions