-
-
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
Empty but visible images consume high CPU on 2.4.x #4345
Comments
OK I've managed to work out that it's texture cache misses. newGlImageTexture which is in the pprof trace is only referenced here in drawImage, and print statements in getTexture (which is called by drawTextureWithDetails) reveal that on 2.3.x there are a handful of cache misses on startup (as expected), but then none until mousing over an image. On 2.4.x however it continues to have dozens of cache misses a second even when not interacting with the app |
Should we mark this as blocker for v2.4.3 (i.e. the point release after current work)? |
I imagine this should be a quick fix to someone familiar with the image painter but I don't know what the fix is. On the other hand it has a very easy workaround (hide empty images) so personally I don't feel it needs to be high priority, unless others complain about it. |
I'm inclined to agree - unless there is a common case when images may be empty and developers won't know, or be able to tell? |
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)
} |
Resolved by #5290, I'm glad to have found a better solution than I proposed before - it helps when you identify the root cause ;) |
Checklist
Describe the bug
A canvas.Image that is empty (no image.Image, fyne.Resource or file set) but not hidden will cause high CPU use as it causes constant texture cache misses and a new GL texture to be created for the "image" on every redraw. This is a regression from 2.3.x.
How to reproduce
Run the example app
Screenshots
Example code
Fyne version
2.4.1
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: