Navigation Menu

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

Window becomes unresponsive on resize #1189

Closed
AvaneraTV opened this issue Jul 16, 2020 · 5 comments
Closed

Window becomes unresponsive on resize #1189

AvaneraTV opened this issue Jul 16, 2020 · 5 comments
Labels
blocker Items that would block a forthcoming release bug Something isn't working OS:Windows Tickets affecting only Microsoft Windows
Milestone

Comments

@AvaneraTV
Copy link

Describe the bug:

When updating the window contents, the application resizes the active window, but fails to display the new content and becomes unresponsive. This reproduces with a relatively small piece of code, but it's not unlikely that I'm simply doing something incorrectly. My application isn't particularly robust yet.

To Reproduce:

Steps to reproduce the behaviour:

  1. Launch the sample code below.
  2. Upon pressing the included button, the issueoccurs.

Screenshots:

Before:
image

After:
image

Example code:

package main

import (
	"strconv"

	"fyne.io/fyne/app"
	"fyne.io/fyne/layout"
	"fyne.io/fyne/widget"

	"fyne.io/fyne"
)

func main() {
	fyneApp := app.New()
	configWindow := fyneApp.NewWindow("Example - Problems")
	containerContents(&configWindow)
	configWindow.ShowAndRun()
}

var (
	hackyGlobalExample []int // Please don't judge me...
)

func containerContents(window *fyne.Window) {
	items := []fyne.CanvasObject{}

	for i := range hackyGlobalExample {
		items = append(items, widget.NewLabel(strconv.Itoa(i)))
	}

	addButton := widget.NewButton("Add", func() {
		hackyGlobalExample = append(hackyGlobalExample, len(hackyGlobalExample))
		containerContents(window)
	})
	items = append(items, addButton)

	configContainer := fyne.NewContainerWithLayout(layout.NewVBoxLayout(),
		fyne.NewContainerWithLayout(layout.NewGridLayout(1),
			items...,
		),
	)

	(*window).SetContent(configContainer)
}

Device (please complete the following information):

  • OS: Windows 10
  • Go version: 1.14.3
  • Fyne version: 1.3.2
@AvaneraTV AvaneraTV changed the title Window crashing on resize Window becomes unresponsive on resize Jul 16, 2020
@andydotxyz
Copy link
Member

You should not make pointers to, then dereference, the Window by the way. Your function would be better as:
func containerContents(window fyne.Window) {

@andydotxyz andydotxyz added the OS:Windows Tickets affecting only Microsoft Windows label Jul 16, 2020
@andydotxyz
Copy link
Member

I'll look into this next time I am on a Windows computer, but in the meantime I would recommend not re-building your layout every time. Instead consider using Container.AddObject() instead.
Also I think the VBox container is not adding anything to your code (in this slimmed down version at least).

@AvaneraTV
Copy link
Author

As some additional information, this reproduces on a separate Windows device, though it's another local device so unsurprisingly my environment is virtually identical. I'm trying to access a different device to see if I can continue to reproduce.

The same issue reproduces if I use AddObject as well, the modified sample I ran is below.

package main

import (
	"strconv"

	"fyne.io/fyne/app"
	"fyne.io/fyne/layout"
	"fyne.io/fyne/widget"

	"fyne.io/fyne"
)

func main() {
	fyneApp := app.New()
	configWindow := fyneApp.NewWindow("Example - Problems")
	containerContents(configWindow)
	configWindow.ShowAndRun()
}

var (
	hackyGlobalExample []int // Please don't judge me...
)

func containerContents(window fyne.Window) {
	items := []fyne.CanvasObject{}

	for i := range hackyGlobalExample {
		items = append(items, widget.NewLabel(strconv.Itoa(i)))
	}

	configContainer := fyne.NewContainerWithLayout(layout.NewGridLayout(1),
		items...,
	)

	addButton := widget.NewButton("Add", func() {
		hackyGlobalExample = append(hackyGlobalExample, len(hackyGlobalExample))
		configContainer.AddObject(widget.NewLabel(strconv.Itoa(len(hackyGlobalExample))))
	})
	configContainer.AddObject(addButton)

	window.SetContent(configContainer)
}

@andydotxyz andydotxyz added this to the 1.3.x milestone Jul 17, 2020
@andydotxyz
Copy link
Member

OK, I can replicate this on Windows. Fix should be easier now :)

@andydotxyz andydotxyz added bug Something isn't working blocker Items that would block a forthcoming release labels Jul 20, 2020
andydotxyz added a commit that referenced this issue Jul 20, 2020
Internal content expanding triggered this on Windows
Fixes #1189
@andydotxyz
Copy link
Member

This should now be fixed on develop, apologies for the trouble

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 OS:Windows Tickets affecting only Microsoft Windows
Projects
None yet
Development

No branches or pull requests

2 participants