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

Winit/WR doesnt works well on hyprland #494

Open
declantsien opened this issue Feb 27, 2023 · 9 comments
Open

Winit/WR doesnt works well on hyprland #494

declantsien opened this issue Feb 27, 2023 · 9 comments
Labels
bug Something isn't working

Comments

@declantsien
Copy link
Contributor

Issue created based on comment

I run hyprland mostly and it's definitely more of a problem than e.g. weston. E.g. it sends lots of resize events, so the queue needs to be filtered before processing them, or they take forever to process (and occasionally hang).

It should be specific when using winit as windowing implementation.

@declantsien declantsien added the bug Something isn't working label Feb 27, 2023
@2e0byo
Copy link
Contributor

2e0byo commented Feb 27, 2023

Actually this one is also a problem on tao.

@declantsien
Copy link
Contributor Author

it sends lots of resize events

There used to be a recursive loop of resize in the code-base. I think I've fixed that in latest master.
Can you confirm? @2e0byo

@2e0byo
Copy link
Contributor

2e0byo commented Mar 10, 2023

Resize events are fixed, thanks. There's still a problem---I think locking---with the event loop though. E.g. if you mouse off the window it flickers and sometimes blanks entirely; the same happens if you change size too much. I need to confirm that these are Hyprland specific. It's possible to get into a state where the window simply doesn't redraw at all. It should just be a matter of working out in the debugger where the window gets cleared and then what blocks it from redrawing. (Ideally ofc we the window should only get cleared when we're ready to swap a new buffer into it.)

A side effect of fixing the resize loop is that windows open up with the wrong scale/size much more frequently on Hyprland, but I think this is again just a matter of finding out where the event is getting stuck. It may be that the initial size event comes too quickly to get handled at all.

I'll fire up GDB this weekend unless it's been magically solved by then like all the other things I was going to fix :D

@declantsien
Copy link
Contributor Author

declantsien commented Mar 10, 2023 via email

@2e0byo
Copy link
Contributor

2e0byo commented Mar 10, 2023

I assumed you are using TAO with glutin then. I believe this can't be avoid. Since glutin is using the native Wayland window OpenGL context, and TAO(GTK) window is also using Wayland window. I think they are fighting over each other. That why I add --with-wr-gl=gtk3 for tao, using GTKs gl_area. So there is no conflicting.

Ah, that makes sense. I've started a rebuild and will test. TBH I'd like to work on the winit port again but haven't the time atm (if we're going to use gtk (tao) we might as well use pgtk). Having the windowing entirely in rust would fix a lot of the random segfaults you can get with the FFI into gtk.

(BTW, the ScaleFactorChanged is never fired for both winit and TAO).

Drat. I was assuming that would handle it.

Like we talked before, there is a better way: We always set scale to 1 for font and Emacs frame size, send to Emacs redisplay for glyph strings. Then applied the scale when draw. But that is some refactoring work.

I do think this is the right way long term. It should also reduce memory/cpu usage on Emacs's size. But it will mean that non-vector graphics gets rasterised. Presumably though things like the glyph objects will handle being multiplied by a scale? (pdf-view already handles this by sending an image multiplied by the scale factor, so there's no reason to worry about it I think.)

Apparently firefox takes this approach, so I guess we should have a look at the source to see how they do it.

@declantsien
Copy link
Contributor Author

declantsien commented Mar 10, 2023 via email

@2e0byo
Copy link
Contributor

2e0byo commented Mar 10, 2023

the tao/glutin thing is indeed the cause of flickering. I've updated the docs and merged the PR since it was trivial, but feel free to edit.

@declantsien
Copy link
Contributor Author

declantsien commented Mar 10, 2023 via email

@declantsien
Copy link
Contributor Author

Like we talked before, there is a better way: We always set scale to 1 for font and Emacs frame size, send to Emacs redisplay for glyph strings. Then applied the scale when draw. But that is some refactoring work.

I do think this is the right way long term. It should also reduce memory/cpu usage on Emacs's size. But it will mean that non-vector graphics gets rasterised. Presumably though things like the glyph objects will handle being multiplied by a scale? (pdf-view already handles this by sending an image multiplied by the scale factor, so there's no reason to worry about it I think.)

Apparently firefox takes this approach, so I guess we should have a look at the source to see how they do it.

I implemented it here #518. Would you like to give it a test?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants