Skip to content
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

Black flicker when launching application on external display on Thinkpad T430 #1103

Open
charlesdaniels opened this issue Jun 14, 2020 · 27 comments
Labels
bug Something isn't working help wanted Extra attention is needed OS:Linux Tickets affecting only Linux

Comments

@charlesdaniels
Copy link
Member

charlesdaniels commented Jun 14, 2020

Edit: This issue previously referenced CWM, it seems that the window manager is unrelated. See this comment for an update.

Describe the bug:

When any Fyne application is first launched on Ubuntu 20.04, it renders for an instant, then turns black. Resizing the window makes it resume working in perpetuity.

To Reproduce:

Run any Fyne program.

Screenshots:

example

Example code:

I used the example here in the video,

Device (please complete the following information):

  • OS: Ubuntu
  • Version: 20.04
  • Go version: 1.13.8
  • Fyne version: 1.2.5
cad@enki:~ > uname -a
Linux enki 5.4.0-33-generic #37-Ubuntu SMP Thu May 21 12:53:59 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
cad@enki:~ > cat /etc/os-release 
NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
cad@enki:~ > go version
go version go1.13.8 linux/amd64

I seem to have fyne@1.2.5 installed in pkg/mod/fyne.io.

The WM used is a custom fork of CWM. It does have partial EWMH support, but it is possible there is some event that is being ignored/not created/etc. that might be confusing Fyne somehow. I only see this behavior with Fyne, no other toolkits/programs. Further supporting this theory, I cannot reproduce this issue under a stock Ubuntu 20.04 installation in VirtualBox. This could also be related to compositing (or lack thereof).

@andydotxyz
Copy link
Member

Thanks for the report. It does look like it could be triggered by the window manager.
Compositor should not effect as we work with and without them.

Would it be possible to add some debug into internal/driver/glfw/window.go to see what the values are in the resized and frameresized events? Something seems strange and I don't know if it's Fyne or GLFW.

@andydotxyz andydotxyz added bug Something isn't working question A question has been asked labels Jun 15, 2020
@charlesdaniels
Copy link
Member Author

charlesdaniels commented Jun 15, 2020

debug.log

Attached log was captured from script, you may need to download it an cat it to render any escape codes.

The only thing I see in window.go that hits a breakpoint was rescaleOnMain(). After I continue from this breakpoint, the black flicker happens, and no further breakpoints are set.

Here are the breakpoints:

(dlv) b window.go:160
Command failed: Location "window.go:160" ambiguous: /home/cad/.go-workspace/src/fyne.io/fyne/internal/driver/glfw/window.go, /home/cad/.go-workspace/src/fyne.io/fyne/vendor/github.com/go-gl/glfw/v3.3/glfw/window.go…
(dlv) b  /home/cad/.go-workspace/src/fyne.io/fyne/internal/driver/glfw/window.go:160
Breakpoint 1 set at 0x961fb3 for fyne.io/fyne/internal/driver/glfw.(*window).Resize() /home/cad/.go-workspace/src/fyne.io/fyne/internal/driver/glfw/window.go:160
(dlv) b  /home/cad/.go-workspace/src/fyne.io/fyne/internal/driver/glfw/window.go:476
Breakpoint 2 set at 0x963c88 for fyne.io/fyne/internal/driver/glfw.(*window).resized() /home/cad/.go-workspace/src/fyne.io/fyne/internal/driver/glfw/window.go:476
(dlv) b  /home/cad/.go-workspace/src/fyne.io/fyne/internal/driver/glfw/window.go:489
Breakpoint 3 set at 0x963e93 for fyne.io/fyne/internal/driver/glfw.(*window).frameSized() /home/cad/.go-workspace/src/fyne.io/fyne/internal/driver/glfw/window.go:489
(dlv) b  /home/cad/.go-workspace/src/fyne.io/fyne/internal/driver/glfw/window.go:1021
Breakpoint 4 set at 0x9684b8 for fyne.io/fyne/internal/driver/glfw.(*window).rescaleOnMain() /home/cad/.go-workspace/src/fyne.io/fyne/internal/driver/glfw/window.go:1021

Edit: forgot to add: it looks like the problem might be later on. Let me know if there are other breakpoints it would be helpful to check and I can certainly do so.

@andydotxyz
Copy link
Member

Unfortunately I can't see the width/height variables in that output. Can you instead print the two values that are passed into the resized and frameresized methods so we can se their values and also the order they are called in?

@charlesdaniels
Copy link
Member Author

It doesn't look like resized() or frameSizsed() are called at all. If I put a panic() in either of these methods, the application still runs no problem.

@charlesdaniels
Copy link
Member Author

I do hit those breakpoints if I resize the window though, see attached log.

debug.log

Interesting note: CWM seems to think the window's minimum size is 0x0, even though it's clearly taking up more space... maybe Fyne isn't telling Xorg it's window size in a sufficiently convincing fashion?

@andydotxyz andydotxyz changed the title Black flicker when launching application on Ubuntu Black flicker when launching application inside CWM Jun 19, 2020
@andydotxyz andydotxyz added OS:Linux Tickets affecting only Linux and removed question A question has been asked labels Jun 19, 2020
@andydotxyz andydotxyz added this to the 1.3.x milestone Jun 19, 2020
@andydotxyz andydotxyz added the blocker Items that would block a forthcoming release label Jun 19, 2020
@andydotxyz
Copy link
Member

Can you please try something for me? If you replace line 494 (approx) in internal/driver/glfw/window.go with:

	if width == 0 || height == 0 || runtime.GOOS != "darwin" {

(i.e. add the runtime check) does it go away?

andydotxyz added a commit to andydotxyz/fyne that referenced this issue Jun 26, 2020
This is darwin specific and some linux systems were triggering
it by mistake.

May fix fyne-io#1103
@andydotxyz andydotxyz mentioned this issue Jun 26, 2020
3 tasks
@charlesdaniels
Copy link
Member Author

This is the exact change that I applied:

diff --git a/internal/driver/glfw/window.go b/internal/driver/glfw/window.go
index 5ef29458..887a0773 100644
--- a/internal/driver/glfw/window.go
+++ b/internal/driver/glfw/window.go
@@ -487,7 +487,8 @@ func (w *window) resized(_ *glfw.Window, width, height int) {
 }

 func (w *window) frameSized(viewport *glfw.Window, width, height int) {
-       if width == 0 || height == 0 {
+       // if width == 0 || height == 0 {
+       if width == 0 || height == 0 || runtime.GOOS != "darwin" {
                return
        }

It did not work; if I set a break-point there in Delve, that function is never called unless I manually resize the window, but the blacking out / flickering happens even if I don't interact with the window whatsoever.

@andydotxyz
Copy link
Member

OK, thanks. Can you also test the more complete #1138 change please? It contains more things that help with bad resize requests on Linux.

@charlesdaniels
Copy link
Member Author

This did not seem to have any effect.

@andydotxyz
Copy link
Member

:(

Can you please add some debug to see what the canvas scale is each time the painter runs?
That was the source of some issues here

@charlesdaniels
Copy link
Member Author

diff --git a/internal/painter/gl/painter.go b/internal/painter/gl/painter.go
index 81b785c0..fb5c827f 100644
--- a/internal/painter/gl/painter.go
+++ b/internal/painter/gl/painter.go
@@ -9,6 +9,8 @@ import (
        "fyne.io/fyne"
        "fyne.io/fyne/internal/driver"
        "fyne.io/fyne/internal/painter"
+
+       "github.com/y0ssar1an/q"
 )
 
 // Painter defines the functionality of our OpenGL based renderer
@@ -64,6 +66,9 @@ func (p *glPainter) StopClipping() {
 }
 
 func (p *glPainter) Paint(obj fyne.CanvasObject, pos fyne.Position, frame fyne.Size) {
+       q.Q(obj)
+       q.Q(pos)
+       q.Q(frame)
        if obj.Visible() {
                p.drawObject(obj, pos, frame)
        }

With me resizing the window manually:

And with me just letting it sit and not touching it:

@andydotxyz
Copy link
Member

Indeed, seems the object tree is fine.
But what is canvas.Scale() inside canvas.paint()?

@charlesdaniels
Copy link
Member Author

diff --git a/internal/driver/glfw/canvas.go b/internal/driver/glfw/canvas.go
index f5048bb8..b38a2f01 100644
--- a/internal/driver/glfw/canvas.go
+++ b/internal/driver/glfw/canvas.go
@@ -14,6 +14,7 @@ import (
 	"fyne.io/fyne/internal/painter/gl"
 	"fyne.io/fyne/theme"
 	"fyne.io/fyne/widget"
+	"github.com/y0ssar1an/q"
 )
 
 // Declare conformity with Canvas interface
@@ -389,6 +390,8 @@ func updateLayout(objToLayout fyne.CanvasObject) {
 }
 
 func (c *glCanvas) paint(size fyne.Size) {
+	q.Q(c)
+	q.Q(size)
 	if c.Content() == nil {
 		return
 	}
diff --git a/internal/painter/gl/painter.go b/internal/painter/gl/painter.go
index 81b785c0..fb5c827f 100644
--- a/internal/painter/gl/painter.go
+++ b/internal/painter/gl/painter.go
@@ -9,6 +9,8 @@ import (
 	"fyne.io/fyne"
 	"fyne.io/fyne/internal/driver"
 	"fyne.io/fyne/internal/painter"
+
+	"github.com/y0ssar1an/q"
 )
 
 // Painter defines the functionality of our OpenGL based renderer
@@ -64,6 +66,9 @@ func (p *glPainter) StopClipping() {
 }
 
 func (p *glPainter) Paint(obj fyne.CanvasObject, pos fyne.Position, frame fyne.Size) {
+	q.Q(obj)
+	q.Q(pos)
+	q.Q(frame)
 	if obj.Visible() {
 		p.drawObject(obj, pos, frame)
 	}

log.txt

Interestingly, it seems I cannot reproduce this issue anymore... let me try again with the latest HEAD...

@charlesdaniels
Copy link
Member Author

I grabbed a fresh copy by deleting my local copy and getting a new one with go get and now I cannot reproduce anymore. It seems like maybe some other commit has fixed it. I also tested with the examples repo and could not reproduce their either.

@andydotxyz
Copy link
Member

Interesting. Let's wait until all the flicker fixes are in and test again, if it's still good we can close this :)

@charlesdaniels
Copy link
Member Author

Sadly, it seems my initial optimism was unfounded. On the other hand, I guess this suggests that there is a regression, since this doesn't reproduce on the main branch?

Tested this on develop against fce4b1f.

diff --git a/internal/driver/glfw/canvas.go b/internal/driver/glfw/canvas.go
index f5048bb8..24c39c50 100644
--- a/internal/driver/glfw/canvas.go
+++ b/internal/driver/glfw/canvas.go
@@ -14,6 +14,8 @@ import (
        "fyne.io/fyne/internal/painter/gl"
        "fyne.io/fyne/theme"
        "fyne.io/fyne/widget"
+
+       "github.com/y0ssar1an/q"
 )
 
 // Declare conformity with Canvas interface
@@ -389,6 +391,9 @@ func updateLayout(objToLayout fyne.CanvasObject) {
 }
 
 func (c *glCanvas) paint(size fyne.Size) {
+       q.Q("internal/driver/glfw/canvas.go:paint()")
+       q.Q(c)
+       q.Q(size)
        if c.Content() == nil {
                return
        }
diff --git a/internal/painter/gl/painter.go b/internal/painter/gl/painter.go
index 7cb065e4..a26b12a1 100644
--- a/internal/painter/gl/painter.go
+++ b/internal/painter/gl/painter.go
@@ -9,6 +9,8 @@ import (
        "fyne.io/fyne"
        "fyne.io/fyne/internal/driver"
        "fyne.io/fyne/internal/painter"
+
+       "github.com/y0ssar1an/q"
 )
 
 // Painter defines the functionality of our OpenGL based renderer
@@ -64,6 +66,11 @@ func (p *glPainter) StopClipping() {
 }
 
 func (p *glPainter) Paint(obj fyne.CanvasObject, pos fyne.Position, frame fyne.Size) {
+       q.Q("internal/painter/gl/painter.go:Paint()")
+       q.Q(p)
+       q.Q(obj)
+       q.Q(pos)
+       q.Q(frame)
        if obj.Visible() {
                p.drawObject(obj, pos, frame)
        }

log.txt

@andydotxyz
Copy link
Member

Can you please test develop branch and/or fix/1114? There is a lot of work in this area and both have related code changes.

@charlesdaniels
Copy link
Member Author

Tested against fix/1114 and still seeing the same behavior. This was generated with the same logging statements as before:

log.txt

@andydotxyz
Copy link
Member

This is making no sense - all the size and scale values appear correct. The rendering is happening to the right size so why is it not appearing?

In the video above it looks like the content disappears when you move the mouse - is that the case?
The timing may be the only clue left so it would be good to confirm that. I.e. is it time based or is it triggered by the mouse move?

@charlesdaniels
Copy link
Member Author

It seems completely un-correlated with mouse activity. If I don't touch the mouse at all, I see the same behavior, and it seems to stay black indefinitely until I resize or move the window (just noticed that moving the window works as well as resizing). The timing seems pretty consistent, roughly one second after the window is opened.

@charlesdaniels
Copy link
Member Author

Interestingly, occluding the window with another window without interacting directly with it will also make the black-out go away.

My intuition tells me that it's un-blacking-out to Xorgs event that indicates a region of the window has become visible, since it doesn't go away until a portion of the window goes from occluded to not-occluded.

@andydotxyz
Copy link
Member

The un-occluding I can understand as that does trigger a redraw.
What I can't quite get is why it disappears at all - there is no event I can think of that we respond to by hiding content.
And showing on mouse move is strange, because none of the items in that sample respond to Hover to cause a refresh internally.

I am going to try and set up the same environment and step through as my logic isn't strong enough.

@charlesdaniels
Copy link
Member Author

To be clear: mouse move does not affect anything unless it’s to resize or move the window. Just mousing over or hovering does nothing.

If you want to replicate my exact environment, I have provisioning scripts here. My CWM fork is here.

You should be able to run curl 'https://git.sr.ht/~charles/provisioning/blob/master/focal/scripts/bootstrap.sh’ | sh in a stock Ubuntu Server 20.04 VM, that will magically set up everything.

@andydotxyz
Copy link
Member

I cannot replicate this with vanilla CWM - can you?

@charlesdaniels
Copy link
Member Author

charlesdaniels commented Jun 30, 2020

After working with @andydotxyz and others in #fyne-contributors, these are our findings:

  • This issue happens only on the Thinkpad T430. I have also tested with CWM and other window managers on a Thinkpad X220 (running the same OS version), and @andydotxyz tested on a Dell XPS 13 with both my CWM fork and the vanilla version.
  • This issue happens on the Thinkpad T430 under any window manager (tested CWM, IceWM, and XFCE4)
  • This issue happens on the Thinkpad T430 only on external monitors, not the internal display. I wrote the previous comment where I thought the issue had fixed itself while using the internal display.
  • The Thinkpad X220 and Thinkpad T430 have character-for-character identical output under apitrace.
  • The go-gl demo applications work correctly on the affected system.
  • Running with -tags mobile resolves the flickering problem.

For the record, here is some further information on the affected system:

Output of glxinfo: glxinfo.txt

Output of lspci | grep -i vga:

00:02.0 VGA compatible controller: Intel Corporation 3rd Gen Core processor Graphics Controller (rev 09)

Output of uname -a:

Linux enki 5.4.0-39-generic #43-Ubuntu SMP Fri Jun 19 10:28:31 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

Output of dpkg --list | egrep 'intel|video': dpkg.txt

Output of lscpu: lscpu.txt

@charlesdaniels charlesdaniels changed the title Black flicker when launching application inside CWM Black flicker when launching application on external display on Thinkpad T430 Jun 30, 2020
@andydotxyz andydotxyz removed the blocker Items that would block a forthcoming release label Jul 1, 2020
@andydotxyz
Copy link
Member

As discussed taking blocker off this issue as we cant replicate on any other computer currently.

@andydotxyz andydotxyz reopened this Jul 7, 2020
@charlesdaniels
Copy link
Member Author

Confirming that this still occurs in the v1.3.1 release where 7f83254 is included. Tested by doing git checkout v1.3.1 in the fyne directory in GOPATH.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed OS:Linux Tickets affecting only Linux
Projects
None yet
Development

No branches or pull requests

2 participants