Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clicking table headers causes high CPU consumption #4264

Closed
2 tasks done
3a9LL opened this issue Sep 19, 2023 · 6 comments
Closed
2 tasks done

Clicking table headers causes high CPU consumption #4264

3a9LL opened this issue Sep 19, 2023 · 6 comments
Labels
blocker Items that would block a forthcoming release bug Something isn't working

Comments

@3a9LL
Copy link

3a9LL commented Sep 19, 2023

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

When I click on table headers a few times I get the app hagned. CPU usage above 12%

How to reproduce

  1. Run Fyne Demo
  2. Go to Collections -> Table
  3. Click once on table headers
  4. In a moment the app doesn't respond

or run the sample app below and do the steps since the 3rd

Screenshots

image
image

Example code

package main

import (
	"fyne.io/fyne/v2"
	"fyne.io/fyne/v2/app"
	"fyne.io/fyne/v2/container"
	"fyne.io/fyne/v2/data/binding"
	"fyne.io/fyne/v2/widget"
	"os"
)

func main() {
	os.Setenv("FYNE_THEME", "light")

	myApp := app.New()
	w := myApp.NewWindow("Table with headers")

	tab := makeTableTab()

	tabs := container.NewAppTabs(
		container.NewTabItem("Table", tab),
	)
	tabs.SetTabLocation(container.TabLocationLeading)
	content := container.NewBorder(nil, nil, nil, nil, tabs)
	w.SetContent(content)
	w.Resize(fyne.NewSize(500, 300))

	w.ShowAndRun()

}

type TestStruct struct {
	Name        string
	Path        string
	Description string
}

func makeTableTab() fyne.CanvasObject {
	list := binding.NewUntypedList()
	table := widget.NewTableWithHeaders(
		func() (int, int) {
			return list.Length(), 3
		},
		func() fyne.CanvasObject {
			return widget.NewLabel("template")
		},
		func(id widget.TableCellID, o fyne.CanvasObject) {
			label := o.(*widget.Label)
			ti, _ := list.GetValue(id.Row)
			t := ti.(TestStruct)
			switch id.Col {
			case 0:
				label.SetText(t.Name)
			case 1:
				label.SetText(t.Path)
			case 2:
				label.SetText(t.Description)
			}
		})
	table.CreateHeader = func() fyne.CanvasObject {
		return widget.NewLabel("template")
	}
	colNames := []string{"Name", "Path", "Description"}
	table.UpdateHeader = func(i widget.TableCellID, t fyne.CanvasObject) {
		l := t.(*widget.Label)
		if i.Row == -1 {
			l.SetText(colNames[i.Col])
		}
	}
	table.SetColumnWidth(0, 100)
	table.SetColumnWidth(1, 100)
	table.SetColumnWidth(2, 300)
	table.ShowHeaderColumn = false

	return table
}

Fyne version

2.4.0

Go compiler version

1.21.0

Operating system and version

Microsoft Windows [Version 10.0.19044.3086]

Additional Information

image

@3a9LL 3a9LL added the unverified A bug that has been reported but not verified label Sep 19, 2023
@3a9LL 3a9LL changed the title Fyne Demo: click on table headers hang the app Table headers: click on table headers caui Sep 19, 2023
@3a9LL 3a9LL changed the title Table headers: click on table headers caui Table headers: a few click on table headers cause 12+% CPU consumption (Fyne Demo table as well) Sep 19, 2023
@3a9LL 3a9LL changed the title Table headers: a few click on table headers cause 12+% CPU consumption (Fyne Demo table as well) A few clicks on table headers cause 12+% CPU consumption. Fyne Demo table as well Sep 19, 2023
@andydotxyz
Copy link
Member

andydotxyz commented Sep 19, 2023

When I click on table headers a few times I get the app hagned.

Sounds like a duplicate of #4210

@3a9LL
Copy link
Author

3a9LL commented Sep 19, 2023

I clicked 3-5 times and the app didn't respond. If I click on table cells I don't have the issue

It occurs only with headers

@andydotxyz
Copy link
Member

This is very strange, as table headers are not Tappable!

@3a9LL
Copy link
Author

3a9LL commented Sep 19, 2023

Actually I clicked once on headers and the app hanged. Can anyone reproduce it?

@3a9LL 3a9LL changed the title A few clicks on table headers cause 12+% CPU consumption. Fyne Demo table as well A click on table headers cause 12+% CPU consumption. Fyne Demo table as well Sep 19, 2023
@3a9LL 3a9LL changed the title A click on table headers cause 12+% CPU consumption. Fyne Demo table as well Clicking table headers causes high CPU consumption Sep 19, 2023
@GaetanBaert
Copy link

I got the same trouble here. The app froze when I click on the Header.

@andydotxyz andydotxyz added bug Something isn't working blocker Items that would block a forthcoming release and removed unverified A bug that has been reported but not verified labels Sep 20, 2023
@andydotxyz andydotxyz added this to the D fixes (v2.4.x) milestone Sep 20, 2023
andydotxyz added a commit to andydotxyz/fyne that referenced this issue Sep 20, 2023
@andydotxyz
Copy link
Member

This is now resolved on develop and will go into v2.4.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocker Items that would block a forthcoming release bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants