fyne-io / fyne

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

Content is shaking when resizing #3660

Open S-Varunn opened 1 year ago

S-Varunn commented 1 year ago

Checklist

Describe the bug

When i try to resize the window in Mac (M1 and Intel chip) the contents inside the window is shaking uncontrollably. The window resize is also affected by this.

The issue is only observed in Mac. Works normally in ubuntu and windows.

In arm the glitch is minimal but still exists. In amd it can be observed very clearly. I was able to reduce the glitch a bit by modifying the

func (d *gLDriver) startDrawThread() {
    settingsChange := make(chan fyne.Settings)
    fyne.CurrentApp().Settings().AddChangeListener(settingsChange)
    var drawCh <-chan time.Time
    if d.drawOnMainThread {
        drawCh = make(chan time.Time) // don't tick when on M1
    } else {
        drawCh = time.NewTicker(time.Second / 60).C
    } 

To

func (d *gLDriver) startDrawThread() {
    settingsChange := make(chan fyne.Settings)
    fyne.CurrentApp().Settings().AddChangeListener(settingsChange)
    var drawCh <-chan time.Time
    if d.drawOnMainThread {
        drawCh = make(chan time.Time) // don't tick when on M1
    } else {
        drawCh = time.NewTicker(time.Second / 15).C    // Change here!
    }

But this resulted in the internal logic to slow down.

How to reproduce

  1. Run the fyne demo
  2. Resize the window using the mouse
  3. Observer shaking of contents in Mac m1 and Intel chips.
  4. The Irregular renders can be seen in intervals where you stop dragging or drag continuously and fast.

Screenshots

Mac M1 :

https://user-images.githubusercontent.com/85671418/218434296-7e243597-775e-4cf8-a67a-c5492e7880e0.mov

Mac Intel Chip (amd64) :

https://user-images.githubusercontent.com/85671418/218435771-c617138d-1c3d-4106-bd2b-34b4d9d0ff2a.mov

Example code

Run the fyne_demo

Fyne version

v2.3.0

Go compiler version

1.19.5

Operating system

macOS

Operating system version

Ventura 13.2

Additional Information

Mac arm:

Mac amd:

dweymouth commented 1 year ago

I have seen this issue as well on Intel macs.

andydotxyz commented 1 year ago

I don't see it in the arm video - indeed it should not be possible on M1/2 as the resize and paint share the same run thread. On Intel it is very clear indeed, due to the window size not always matching the painted size during a resize. It affects all OS to some extent but mac intel is the clearest.

We are working on ideas - one is to disable animations during resize and only draw the window size immediately like on M1 but this seems like a regression.

Zambiorix commented 1 year ago

I find it very visible on the M1/2 as well. If you look at the left column, the words "Welcome", "Canvas", .. are jerky when resizing. Even the width of the words are jerky. Since they are left aligned, nothing should move at all when changing the width of the window. I wonder if there is not something else going on besides mismatches between window and paint size?

andydotxyz commented 1 year ago

By default macOS is attempting to stretch the content when resizing - and we have to intercept with a draw frame. It seems we're not getting that timing bang on. It always settles correctly when the resize stops right?

Zambiorix commented 1 year ago

Strange, it's been a while that I have developed for macos, but I have not seen such behavior in the past. I'm new to Fyne, where do you have the actual macos window code?