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

blank black window #10

Closed
whbdupree opened this issue Jan 7, 2017 · 23 comments
Closed

blank black window #10

whbdupree opened this issue Jan 7, 2017 · 23 comments

Comments

@whbdupree
Copy link

It builds, but when I run it, it just opens a blank black window. I am running archlinux.
These are the relevant installed package versions:
Python 3.5.2 (default, Nov 7 2016, 11:31:36)
glew 2.0.0-1
glfw-x11 3.2.1-1
freetype2 2.7.1-1
fontconfig 2.12.1-3
xorg-xdpyinfo 1.3.2-1
xsel 1.2.0.20160929-1
gcc (GCC) 6.2.1 20160830

@kovidgoyal
Copy link
Owner

Run it ina terminal and see if there are any error messages being output

@wulczer
Copy link

wulczer commented Jan 7, 2017

I might be getting the same problem, when running python3 . from the clone directory, a blank black window appears (I'm using Debian testing).

However, when I maximize the window, I see something displaying, namely a small red field. After resizing the window back to the regular size, I get correct display.

Here's how the kitty window looks like after maximixing it:

kitty-maximised

And after resizing back to the regular size:

kitty-back-to-normal-size

Seems that if the window resize callback gets called twice, the display starts working properly.

@whbdupree
Copy link
Author

There is no error message when I run it from command line.

When I maximize, I see the prompt, and then when I return to the original size, I see the prompt.

@kovidgoyal
Copy link
Owner

Might be a timing issue with the launch of the child process (bash) and the first resize of the window. You can test that by inserting the following two lines at line 62 of child.py

import time
time.sleep(2)

Remember to maintain correct indentation.

This will cause kitty to wait a couple of seconds before running the child process

@whbdupree
Copy link
Author

is that before or after the "try:"?

@wulczer
Copy link

wulczer commented Jan 7, 2017

Just tried, but I still see the same issue.

What's interesting, even in the blank-screen state, the terminal works (although I can't see my prompt or my keypresses being echoed out). When I blindly type in touch /tmp/foo and then close kitty, I see the file appear in /tmp anyway, even though the kitty screen is all black the whole time.

This suggests the bash process is running and it's a render issue.

@geordieF
Copy link

geordieF commented Jan 7, 2017

That seems like problem with the renderer ajusting the OpenGL render size, can't check now because mine won't build but make sure that the render aspect ratio is correctly set, as this seems to be an issue that occurs on some graphics hardware, as the system is a bit slow at sending resize events.

@wulczer
Copy link

wulczer commented Jan 7, 2017

Ah, I just ran a different experiment, simulating the resizing the window twice by adding this to boss.py

diff --git a/kitty/boss.py b/kitty/boss.py
index 310d268..c757b7e 100644
--- a/kitty/boss.py
+++ b/kitty/boss.py
@@ -105,6 +105,11 @@ class Boss(Thread):
         self.glfw_window.set_click_cursor(False)
         self.show_mouse_cursor()
         self.start_cursor_blink()
+        import time
+        time.sleep(2)
+        self.on_window_resize(self.glfw_window, 60, 60)
+        time.sleep(2)
+        self.on_window_resize(self.glfw_window, 320, 320)
 
     def signal_received(self):
         try:

After running I get a few seconds of blank screen and then the prompt appears.

@geordieF
Copy link

geordieF commented Jan 7, 2017

@wulczer you should probably move import time to the start, python runs imports before everything else if they aren't in a class for function. What you are doing makes it so that the import doesn't happen untile the class is parsed, which isn't great for performance.

@wulczer
Copy link

wulczer commented Jan 7, 2017

That was just an experiment, I'm not concerned with performance (and it's not an acceptable fix anyhow, it's just a clue about where the real problem might lie).

@geordieF
Copy link

geordieF commented Jan 7, 2017

@wulczer Right. Pretty much confirms what I was saying though, with the resize call running late.

@geordieF
Copy link

geordieF commented Jan 7, 2017

Is this wayland or X11. My X11 seems to be going fine.

@kovidgoyal
Copy link
Owner

Do you actually need two resizes or does one suffice? I'm guessing the problem is that apply_pending_resize() is not being called, which will cause render() to not do anything since rendering is disabled until at least one resize occurs. Can your stick a couple of print statements into on_window_resize() and apply_pending_resize() to see if theya re ever being called?

@geordieF
Copy link

geordieF commented Jan 7, 2017

@kovidgoyal A quick fix which works for me is just to wait for the last resize event before calling the resize function. A bit dirty, but it works.

@kovidgoyal
Copy link
Owner

@geordieF Sorry I'm not sure I understand what you're asying exactly, a git diff would help :)

@wulczer
Copy link

wulczer commented Jan 7, 2017

@kovidgoyal you're right, a single resize is enough. I ran with this:

diff --git a/kitty/boss.py b/kitty/boss.py
index 310d268..4edd17c 100644
--- a/kitty/boss.py
+++ b/kitty/boss.py
@@ -105,6 +105,9 @@ class Boss(Thread):
         self.glfw_window.set_click_cursor(False)
         self.show_mouse_cursor()
         self.start_cursor_blink()
+        # import time
+        # time.sleep(2)
+        # self.on_window_resize(self.glfw_window, 320, 320)
 
     def signal_received(self):
         try:
@@ -215,12 +218,15 @@ class Boss(Thread):
 
     @callback
     def on_window_resize(self, window, w, h):
+        print('on window resize')
         # debounce resize events
         self.pending_resize = True
         yield
+        print('scheduling applying the resize')
         self.timers.add(0.02, self.apply_pending_resize, w, h)
 
     def apply_pending_resize(self, w, h):
+        print('applying the resize')
         viewport_size.width, viewport_size.height = w, h
         self.tab_manager.resize()
         self.resize_gl_viewport = True

With the sleep and resize commented out and no user input, I get no prints and no prompt, the window is stuck in blank mode.

With the sleep and resize uncommented, I get

on window resize
scheduling applying the resize
applying the resize

And the prompt appears without any additional intervention.

@geordieF Polish, actually :)

@wulczer
Copy link

wulczer commented Jan 7, 2017

Actually, this fixes the problem on its own for me:

diff --git a/kitty/boss.py b/kitty/boss.py
index 310d268..c31d14e 100644
--- a/kitty/boss.py
+++ b/kitty/boss.py
@@ -72,7 +72,7 @@ class Boss(Thread):
         self.cursor_blinking = True
         self.glfw_window_title = None
         self.action_queue = Queue()
-        self.pending_resize = True
+        self.pending_resize = False
         self.resize_gl_viewport = False
         self.shutting_down = False
         self.screen_update_delay = opts.repaint_delay / 1000.0

@geordieF
Copy link

geordieF commented Jan 7, 2017

Should i do a PR for this, or will kovid do it

@kovidgoyal
Copy link
Owner

Yes, the issue seems to be that there is no initial resize event on your systems. I'll have to think a little bit about whether allowing rendering without an initial resize is acceptable or will it have any other side-effects. If not then I will commit that change.

@wulczer
Copy link

wulczer commented Jan 7, 2017

This might be relevant: glfw/glfw#62

@geordieF
Copy link

geordieF commented Jan 7, 2017

After reading that bug, wait for the last resize and then wait about a ms for the change to occur, it's a bit hacky, but actually improves performance

@kovidgoyal
Copy link
Owner

Resizes are already debounced, the problem is that there is no resize event at all unless the user resizes the windows, and currently kitty assumes there will be at least one resize. After staring at the code for a bit I cant see any problems with allowing rendering with no resize (there might be a bit of flicker at the startup, is the worst I could find). So I am commit this change. Fingers crossed :)

@wulczer
Copy link

wulczer commented Jan 7, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants