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

Frequent UI changes inside "tapped" causes crash #99

Closed
Kentaa opened this issue Jan 28, 2019 · 7 comments
Closed

Frequent UI changes inside "tapped" causes crash #99

Kentaa opened this issue Jan 28, 2019 · 7 comments
Milestone

Comments

@Kentaa
Copy link

Kentaa commented Jan 28, 2019

Windows 10.0.17763.195 64-bit
Go 1.11.5
fyne 8ace64e

The following programs will crash if the button is clicked too fast. Also crashes with checkbox, and likely other widgets. Looping the code inside the "tapped" function will cause the crash with a single click.

package main

import (
	"fyne.io/fyne/app"
	"fyne.io/fyne/widget"
)

func main() {
	app := app.New()
	w := app.NewWindow("Hello")
	w.SetContent(
		widget.NewButton("Thing", func() {
			z := app.NewWindow("World")
			z.SetContent(
				widget.NewButton("Test", nil),
			)
			z.Show()
		}),
	)
	w.ShowAndRun()
}
package main

import (
	"fyne.io/fyne/app"
	"fyne.io/fyne/widget"
)

func main() {
	app := app.New()
	w := app.NewWindow("Hello")
	f := &widget.Box{}
	f = widget.NewVBox(
		widget.NewButton("Thing", func() {
			f.Append(widget.NewButton("Test", nil))
		}),
	)
	w.SetContent(f)
	w.ShowAndRun()
}

Crashes with a single click:

package main

import (
	"fyne.io/fyne/app"
	"fyne.io/fyne/widget"
)

func main() {
	app := app.New()
	w := app.NewWindow("Hello")
	f := &widget.Box{}
	f = widget.NewVBox(
		widget.NewButton("Thing", func() {
			for i := 0; i < 100; i++ {
				f.Append(widget.NewButton("Test", nil))
			}
		}),
	)
	w.SetContent(f)
	w.ShowAndRun()
}
@andydotxyz
Copy link
Member

Thanks for the report, this has not been caught before. I am downgrading the title slightly as it's not really everything that will cause it to crash (I hope you don't mind).

This will take a little investigation - do you have the crash log? that could speed things up.

@andydotxyz andydotxyz changed the title UI changes inside "tapped" causes crash Frequent UI changes inside "tapped" causes crash Jan 28, 2019
@andydotxyz andydotxyz added this to the Release 1.0 milestone Jan 28, 2019
@paulhovey
Copy link
Contributor

I ran on my machine (debian 9, KDE desktop, golang 1.11.4) and it crashed immediately as well:

panic: runtime error: index out of range

goroutine 1 [running, locked to thread]:
github.com/golang/freetype/truetype.(*GlyphBuf).loadSimple(0xc000172300, 0xb05d54, 0x98, 0x5bcc0, 0x1, 0xb05d62, 0x50, 0x5bcb2)
        /home/paul/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/truetype/glyph.go:312 +0x62a
github.com/golang/freetype/truetype.(*GlyphBuf).load(0xc000172300, 0x2a01004b00000000, 0x0, 0x0)
        /home/paul/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/truetype/glyph.go:229 +0x328
github.com/golang/freetype/truetype.(*GlyphBuf).Load(0xc000172300, 0xc0001641e0, 0x4b000003cb, 0x0, 0x0, 0x0)
        /home/paul/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/truetype/glyph.go:102 +0xc4
github.com/golang/freetype/truetype.(*face).GlyphAdvance(0xc00016f800, 0xc000000068, 0x100000258)
        /home/paul/go/pkg/mod/github.com/golang/freetype@v0.0.0-20170609003504-e2365dfdc4a0/truetype/face.go:345 +0x6e
fyne.io/fyne/driver/gl.(*compositeFace).GlyphAdvance(0xc00007e780, 0x6800000068, 0x100000000)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/driver/gl/font.go:50 +0x69
golang.org/x/image/font.MeasureString(0x66fda0, 0xc00007e780, 0x637cc3, 0x5, 0x50a214)
        /home/paul/go/pkg/mod/golang.org/x/image@v0.0.0-20190118043309-183bebdce1b2/font/font.go:299 +0x88
fyne.io/fyne/driver/gl.(*gLDriver).RenderedTextSize(0xc00000c460, 0x637cc3, 0x5, 0xe, 0xc000000000, 0x756ea1ce1e98ad, 0xc000095a50)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/driver/gl/driver.go:45 +0xe8
fyne.io/fyne/canvas.(*Text).MinSize(0xc000162070, 0x10, 0xc000162070)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/canvas/text.go:26 +0x7e
fyne.io/fyne/driver/gl.(*glCanvas).drawText(0xc00005c1c0, 0xc000162070, 0xc, 0x8, 0x41, 0x25)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/driver/gl/draw.go:160 +0x62
fyne.io/fyne/driver/gl.(*glCanvas).drawObject(0xc00005c1c0, 0x670580, 0xc000162070, 0x4, 0x4, 0x41, 0x25)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/driver/gl/draw.go:192 +0x26e
fyne.io/fyne/driver/gl.(*glCanvas).paint.func1(0x670580, 0xc000162070, 0x4, 0x4)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/driver/gl/canvas.go:131 +0x64
fyne.io/fyne/driver/gl.walkObjects(0x670580, 0xc000162070, 0x4, 0x4, 0xc000095d48)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/driver/gl/draw.go:29 +0x1f6
fyne.io/fyne/driver/gl.walkObjects(0x670640, 0xc00005e3c0, 0x4, 0x4, 0xc000095d48)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/driver/gl/draw.go:26 +0x197
fyne.io/fyne/driver/gl.walkObjects(0x6705e0, 0xc00005e420, 0x0, 0x0, 0xc000095d48)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/driver/gl/draw.go:26 +0x197
fyne.io/fyne/driver/gl.(*glCanvas).paint(0xc00005c1c0, 0x41, 0x25)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/driver/gl/canvas.go:133 +0x124
fyne.io/fyne/driver/gl.(*gLDriver).runGL(0xc00000c460)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/driver/gl/loop.go:101 +0x456
fyne.io/fyne/driver/gl.(*gLDriver).Run(0xc00000c460)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/driver/gl/driver.go:55 +0x2b
fyne.io/fyne/driver/gl.(*window).ShowAndRun(0xc000162000)
        /home/paul/go/pkg/mod/fyne.io/fyne@v0.0.0-20190127222053-8ace64eeb240/driver/gl/window.go:225 +0x57
main.main()
        /home/paul/Development/fynecentertest/testbutton.go:20 +0x1a5
exit status 2

I've actually been seeing this quite a bit on my machine when buttons are clicked, with what appears to be the same crash in loadSimple().

@paulhovey
Copy link
Contributor

Seems to be the same as golang/freetype#65 🤔

@paulhovey
Copy link
Contributor

Using https://github.com/goki/freetype in place of https://github.com/golang/freetype solved the problem for me. Looks like other people have updated forks for freetype as well: https://github.com/aarzilli/freetype https://github.com/tdewolff/freetype

Might be worthwhile testing the goki one, as they have their own GUI system it appears and it's working for them.

@Kentaa
Copy link
Author

Kentaa commented Jan 29, 2019

The log posted by paulhovey appears identical.

panic: runtime error: index out of range

goroutine 1 [running, locked to thread]:
fyne.io/fyne/vendor/github.com/golang/freetype/truetype.(*GlyphBuf).loadSimple(0xc00006a300, 0x6dd8f4, 0x98, 0x5bcc0, 0x1, 0x6dcf1e, 0x1b, 0x5c696)
        H:/Go/src/fyne.io/fyne/vendor/github.com/golang/freetype/truetype/glyph.go:312 +0x631
fyne.io/fyne/vendor/github.com/golang/freetype/truetype.(*GlyphBuf).load(0xc00006a300, 0x3201004b00000000, 0x0, 0x0)
        H:/Go/src/fyne.io/fyne/vendor/github.com/golang/freetype/truetype/glyph.go:229 +0x32f
fyne.io/fyne/vendor/github.com/golang/freetype/truetype.(*GlyphBuf).Load(0xc00006a300, 0xc000152000, 0x4b000003cb, 0x0, 0x68, 0x3700000000004b)
        H:/Go/src/fyne.io/fyne/vendor/github.com/golang/freetype/truetype/glyph.go:102 +0xcb
fyne.io/fyne/vendor/github.com/golang/freetype/truetype.(*face).GlyphAdvance(0xc000067800, 0xc000000068, 0x100000068)
        H:/Go/src/fyne.io/fyne/vendor/github.com/golang/freetype/truetype/face.go:345 +0x75
fyne.io/fyne/driver/gl.(*compositeFace).GlyphAdvance(0xc000072840, 0x6800000068, 0x100000000)
        H:/Go/src/fyne.io/fyne/driver/gl/font.go:48 +0xa9
fyne.io/fyne/vendor/golang.org/x/image/font.MeasureString(0x90be80, 0xc000072840, 0x8d1f52, 0x5, 0xc000083948)
        H:/Go/src/fyne.io/fyne/vendor/golang.org/x/image/font/font.go:299 +0x8f
fyne.io/fyne/driver/gl.(*gLDriver).RenderedTextSize(0xc0000047e0, 0x8d1f52, 0x5, 0xe, 0xc000000000, 0x756ea19a0e4614, 0xc000083a50)
        H:/Go/src/fyne.io/fyne/driver/gl/driver.go:45 +0xef
fyne.io/fyne/canvas.(*Text).MinSize(0xc000150070, 0x10, 0xc000150070)
        H:/Go/src/fyne.io/fyne/canvas/text.go:26 +0x85
fyne.io/fyne/driver/gl.(*glCanvas).drawText(0xc000050180, 0xc000150070, 0xc, 0x8, 0x78, 0x25)
        H:/Go/src/fyne.io/fyne/driver/gl/draw.go:160 +0x69
fyne.io/fyne/driver/gl.(*glCanvas).drawObject(0xc000050180, 0x90c660, 0xc000150070, 0x4, 0x4, 0x78, 0x25)
        H:/Go/src/fyne.io/fyne/driver/gl/draw.go:192 +0x275
fyne.io/fyne/driver/gl.(*glCanvas).paint.func1(0x90c660, 0xc000150070, 0x4, 0x4)
        H:/Go/src/fyne.io/fyne/driver/gl/canvas.go:131 +0x6b
fyne.io/fyne/driver/gl.walkObjects(0x90c660, 0xc000150070, 0x4, 0x4, 0xc000083d48)
        H:/Go/src/fyne.io/fyne/driver/gl/draw.go:29 +0x1fd
fyne.io/fyne/driver/gl.walkObjects(0x90c720, 0xc000052360, 0x4, 0x4, 0xc000083d48)
        H:/Go/src/fyne.io/fyne/driver/gl/draw.go:26 +0x19e
fyne.io/fyne/driver/gl.walkObjects(0x90c6c0, 0xc0000523c0, 0x0, 0x0, 0xc000083d48)
        H:/Go/src/fyne.io/fyne/driver/gl/draw.go:26 +0x19e
fyne.io/fyne/driver/gl.(*glCanvas).paint(0xc000050180, 0x78, 0x25)
        H:/Go/src/fyne.io/fyne/driver/gl/canvas.go:133 +0x12b
fyne.io/fyne/driver/gl.(*gLDriver).runGL(0xc0000047e0)
        H:/Go/src/fyne.io/fyne/driver/gl/loop.go:101 +0x45d
fyne.io/fyne/driver/gl.(*gLDriver).Run(0xc0000047e0)
        H:/Go/src/fyne.io/fyne/driver/gl/driver.go:55 +0x32
fyne.io/fyne/driver/gl.(*window).ShowAndRun(0xc000150000)
        H:/Go/src/fyne.io/fyne/driver/gl/window.go:225 +0x5e
main.main()
        H:/Henry Jekyll/Projects/Go/ThingerDoStuff/main.go:22 +0x1ac

@andydotxyz
Copy link
Member

Thanks for the details - I have indeed been fighting this bug I just had not seen it come up in this way before.
I will try the forks - thanks for the link :)

@andydotxyz
Copy link
Member

Thanks for the details @paulhovey @Kentaa I resolved this by pulling in the GoKi fork.
Very glad that this crash is sorted now :)

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

3 participants