-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
High CPU use when showing CustomDialogs #4574
Comments
dialog.ShowCustomConfirm
dialog.ShowCustom[Confirm]
Reproes with dialog.ShowCustom too |
dialog.ShowCustom[Confirm]
Is this specific to custom dialogs or dialogs in general? I can’t think of anything specific that the custom ones do but the others don’t |
Specific to custom dialogs. Regular ShowInformation, etc don't show the issue. I think it must be somehow related to the CustomDialog type itself |
It is just a struct with a pointer to the good old dialog struct. Nothing special really. I'm not saying that you are wrong but I have a hard time seeing that it would be specific to custom only |
Yeah I'm equally confused. Maybe it's a platform-specific thing too. Are you able to replicate it? |
Just on my phone now, sorry. Can't guarantee when I can have a look |
Loads continuously |
If you have some controls with data binding or OnChanged defined in |
Hmm sounds like a refresh loop where it's triggering redrawing on every frame |
Are there any other dialogs that also show this behaviour? Form perhaps? |
You can look at https://github.com/vinser/pixyne/blob/master/m_dialogs.go if you wish |
Dialogs in fyne_demo works great - no high CPU load :) |
All but custom dialogs of fyne_demo work great - no high CPU load. But this one do func colorPicked(c color.Color, w fyne.Window) {
log.Println("Color picked:", c)
rectangle := canvas.NewRectangle(c)
size := 2 * theme.IconInlineSize()
rectangle.SetMinSize(fyne.NewSize(size, size))
dialog.ShowCustom("Color Picked", "Ok", rectangle, w)
} |
So the one problematic dialog in fyne_demo is the single one that is created using |
Good find, I can confirm that the colour chosen dialog in fyne_demo causes high CPU here too! It would appear that on every walk it is generating new image textures. |
I wonder if the following is a good solution? It doesn't seem to take the CPU usage to 0 though... --- a/internal/painter/gl/draw.go
+++ b/internal/painter/gl/draw.go
@@ -36,6 +36,9 @@ func (p *painter) drawGradient(o fyne.CanvasObject, texCreator func(fyne.CanvasO
}
func (p *painter) drawImage(img *canvas.Image, pos fyne.Position, frame fyne.Size) {
+ if img.Image == nil && img.File == "" && img.Resource == nil || img.Translucency == 1.0 {
+ return
+ }
p.drawTextureWithDetails(img, p.newGlImageTexture, pos, img.Size(), frame, img.FillMode, float32(img.Alpha()), 0)
} |
Good sleuthing @andydotxyz - if the image is really the root cause, it could be solved for dialogs without even solving #4345 by setting the dialog's image to Hidden whenever it is empty |
Aha that is a much better plan :) |
Fixed on develop, we will pick it into v2.4.4 as well |
Checklist
Describe the bug
Showing a custom confirm dialog using
dialog.ShowCustomConfirm
uses high CPU while the dialog is displayed. After dismissing the dialog the CPU settles back down to normal.How to reproduce
Run the example code, with an Activity Monitor/Task Manager/etc window open, and click the button to show the custom confirm dialog
Screenshots
No response
Example code
Fyne version
2.4.3
Go compiler version
go1.21.1
Operating system and version
macOS Ventura M2
Additional Information
No response
The text was updated successfully, but these errors were encountered: