-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
I have an application where in one tab I have some richtext with an image and in another tab I have a drop down menu where you can select different themes for the application. If I open the application for the first time and I DONT click on the tab that has the rich text, I can change the theme from the other tab without issues, consistently.
If I click on the richtext tab and go back to select the theme from the dropdown, the application might freeze after I choose a theme. (this is intermittent behaviour)
So this is what happens when I select a theme
(c *glCanvas) MinSize()calls RLock and thenc.canvasSize(c.content.MinSize())- The type of c.content in this case is
container.AppTabs (t *AppTabs) MinSize()callst.BaseWidget.MinSize().- The type of BaseWidget is
*widget.textRenderer - inside
(r *textRenderer) MinSize()there is a for loopfor range bound.segments. One of the objects in that loop iswidget.richImage (r *richImage) MinSize()callsinternal.ScaleInt(c, orig.Width)internal.ScaleIntcallsc.Scale().c is a fyne.Canvas interface which with reflect I checked that is the glfw.glCanvas type.(c *glCanvas) Scale()calls RLock
Step 8 tries to get RLock but step 1 has not released it yet.
I managed to replicate the same issue in a much simpler example. Please check the provided code below. The application will freeze after a few seconds.
How to reproduce
Refer to the Go code below.
Screenshots
No response
Example code
package main
import (
"time"
fyne "fyne.io/fyne/v2"
"fyne.io/fyne/v2/app"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"
)
var currentmfolder string
func main() {
myApp := app.New()
myWindow := myApp.NewWindow("Test Dialog")
l := widget.NewLabel("hello")
rich := widget.NewRichTextFromMarkdown(``)
cont := container.NewVBox(l, rich)
myWindow.SetContent(cont)
go func() {
for i := 0; i < 1000; i++ {
go func() { fyne.CurrentApp().Settings().SetTheme(theme.DarkTheme()) }()
time.Sleep(500 * time.Millisecond)
go func() { fyne.CurrentApp().Settings().SetTheme(theme.LightTheme()) }()
time.Sleep(500 * time.Millisecond)
}
}()
myWindow.ShowAndRun()
}Fyne version
v2.3.0
Go compiler version
1.19.4
Operating system
Linux
Operating system version
Ubuntu 18.04
Additional Information
No response