fyne-io / fyne

Cross platform GUI toolkit in Go inspired by Material Design
https://fyne.io/
Other
24.87k stars 1.38k forks source link

Window periodically misdraws into a smaller area on startup #4964

Open dweymouth opened 3 months ago

dweymouth commented 3 months ago

Checklist

Describe the bug

Seems to only happen on Linux, and on Ubuntu 24.04 it happens up to 50% of the time, much more often than 22.04, according to Supersonic user reports. When this happens the window canvas also isn't responsive to mouse events at all.

I'm really tempted to mark this as a blocker since it is a huge negative to the UX of Fyne apps on Linux, at least on whatever distros are affected. Though manually resizing the window does fix it when it gets in this state.

How to reproduce

Launch a Fyne app on Ubuntu 24.04 until it shows up misdrawn

Screenshots

Screenshot from a Supersonic user:

image

Example code

n/a

Fyne version

develop

Go compiler version

n/a

Operating system and version

Linux (especially Ubuntu 24.04)

Additional Information

No response

dweymouth commented 3 months ago

I'll just share my incredibly hacky workaround here (which replaced my previous, ineffective attempt at a workaround) in case anyone else is affected: https://github.com/dweymouth/supersonic/commit/2736fe9955006444eb3bb58181b5e6b1bee68c61

I send a resize event through X11 shortly after the window is shown, so that if it ends up in the misdrawn state it will be forced out of it

p4k1tz commented 3 months ago

I can also confirm this is happening on Windows as well. Not created a workaround yet.

dweymouth commented 2 months ago

This also happens with native Wayland builds (go build -tags wayland) according to user reports

dweymouth commented 2 months ago

marking this as blocker since it happens quite frequently to a lot of users of Fyne apps, and apparently not just on Linux either

dweymouth commented 2 months ago

System info from an affected user. They seem to see the issue on 10-20% of startups (and all of my attempted workarounds in app code have been at best partially effective)

image

and3rson commented 1 week ago

I'm experiencing the same issue. In my setup, I have AdaptiveGrid with 2 lists inside. List items randomly appear too narrow. Reproducible in both wayland & X.

EDIT: I noticed this only happens when list widgets are wrapped inside a custom struct.

andydotxyz commented 1 week ago

That may be an unrelated issue... If you are extending a widget and don't do it currently the renderer can fail to get Resize right - did you call ExtendBaseWidget?

and3rson commented 6 days ago

@andydotxyz yes, I can reproduce it with and without ExtendBaseWidget:

type myList struct {
    *widget.List
    // same behavior when extending `widget.List`
}

// ...
l := myList{widget.NewListWithData(...)}
l.ExtendBaseWidget(l)

// This works fine:
l := widget.NewListWithData(...)

Resizing the window does not fix list's width.

Behavior without custom struct (and 90% of time with custom struct): HQSEIf1

Behavior with custom struct 10% of time: s91A1i9

(Please don't be confused by Windows-like path on screenshot, this is a Linux app that communicates with another Windows client app)

andydotxyz commented 6 days ago

Your code is creating two lists (or two list pointers, depending on the setup) - this will confuse things. Try this instead:

type myList struct {
    widget.List
    // same behavior when extending `widget.List`
}

// ...
l := myList{}
l.Bind(...)
l.ExtendBaseWidget(l)

If you call a widget constructor inside your widget constructor then (to simplify a complex problem) the UI does not know which of the two you are rendering. Instead instantiate your struct with the parent widget embedded directly (not with a pointer) and then configure it using the inherited methods or fields.