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

Render cache cleaning causes freeze in inactive window. #5131

Open
2 tasks done
knusbaum opened this issue Sep 10, 2024 · 1 comment
Open
2 tasks done

Render cache cleaning causes freeze in inactive window. #5131

knusbaum opened this issue Sep 10, 2024 · 1 comment

Comments

@knusbaum
Copy link

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

With the changes in #5112, the cache cleaning is functional. The clean is triggered from the active window on redraws. Redraws mark the renderers in the window's canvas object tree as still active.

Unfortunately, if other windows have been inactive and not redrawn for some time, their renderers will have become stale and when the cache is cleared, their renderers will be evicted.

It looks like the code is setup to regenerate renderers on demand, however this does not seem to completely work, and the other windows cease to be redrawn for things like mousing over buttons and scrolling.

Resizing the windows fixes this.

I don't believe this is the result of my particular choice of cache cleaning time, but is instead a result of more fundamental design decisions in the refresh/cache relationship.

How to reproduce

There is a reproduction application here:
https://github.com/knusbaum/fynetest/tree/freeze-testcase

Just run go tidy and then go build and run the application. Instructions are built into the UI.

Screenshots

No response

Example code

https://github.com/knusbaum/fynetest/tree/freeze-testcase

Fyne version

2.5.1

Go compiler version

1.23.0

Operating system and version

Linux 6.6.48

Additional Information

No response

@knusbaum knusbaum added the unverified A bug that has been reported but not verified label Sep 10, 2024
@dweymouth dweymouth removed the unverified A bug that has been reported but not verified label Sep 11, 2024
@dweymouth
Copy link
Contributor

Just pasting the code here as well - note to reproduce this it should be run on top of PR #5112

package main

import (
	"fmt"
	"time"

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

func main() {
	myApp := app.New()
	w := myApp.NewWindow("freezing-window")
	w2 := myApp.NewWindow("other-window")

	var tab *widget.Table
	tab = widget.NewTable(
		//length
		func() (rows int, cols int) {
			return 100, 100
		},
		//create
		func() fyne.CanvasObject {
			return widget.NewLabel("")
		},
		//update
		func(id widget.TableCellID, o fyne.CanvasObject) {
			l := o.(*widget.Label)
			l.SetText(fmt.Sprintf("(%d,%d)", id.Col, id.Row))
			if l.Size().Width < l.MinSize().Width {
				tab.SetColumnWidth(id.Col, l.MinSize().Width)
			}
		},
	)
	var d dialog.Dialog
	tab.OnSelected = func(id widget.TableCellID) {
		// We make this dialog part of w rather than w2, since making it part of w2 makes the bug disappear.
		if d != nil {
			d.Hide()
		}
		d = dialog.NewInformation("clicked", fmt.Sprintf("SELECTED %v\n", id), w2)
		d.Show()
	}

	l1 := widget.NewLabel("Do not interact with the table window, including mousing over it while the timer counts down.")
	l1.Wrapping = fyne.TextWrapWord
	l2 := widget.NewLabel("")
	l2.Wrapping = fyne.TextWrapWord
	t := time.Second * 120
	go func() {
		for t >= 0 {
			l2.SetText(fmt.Sprintf("%v", t))
			l2.Refresh()
			t = t - 1*time.Second
			time.Sleep(1 * time.Second)
		}
		l2.SetText(fmt.Sprintf("Now, mouse over the table window, try to scroll, etc. It is frozen. This can be corrected by resizing the window. Clicks still appear to work."))
		for {
			l2.Refresh()
			time.Sleep(1 * time.Second)
		}

	}()

	w.SetContent(tab)
	w.Resize(fyne.NewSize(400, 400))
	w2.SetContent(container.NewVBox(
		l1,
		l2,
		// This does nothing except provide correct width so the container sets min height correctly.
		widget.NewButton("I do nothing.", nil),
	))
	w2.Resize(fyne.NewSize(200, 200))
	w.Show()
	w2.Show()
	myApp.Run()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants