You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I took the example mentioned in a tutorial as a baseline of my code. What I want to achieve is to get the X11 socket and wait on it with epoll. As soon as I get socket ready for reading, I do glfwPollEvents() to drain the event queue. My expectations is that, that the program enters wait state. But I get busy loop with 72 bytes left for read each iteration. These bytes are not belong to the X11 event loop, as the type of XEvent contains garbage.
My setup follows.
#define GLFW_INCLUDE_NONE
#define GLFW_EXPOSE_NATIVE_X11
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
...
/* initialize the library */
x11_display = glfwGetX11Display();
sd_x11 = ConnectionNumber(x11_display);
/* add sd_x11 to epoll */
/* create window set calbacks */
while (!glfwWindowShouldClose(window)) {
/* wait for events to be ready */
epoll_wait(...)
/* here is the issue
printing bytes avaible shows 72 bytes.
sd_x11 seems to have read state every iteration
*/
glfwPollEvents();
glfwSwapBuffers(window);
}
The event that wake-ups the epoll is a generic X11 event. From the frequency of wake-ups I think that the event is related to monitor vertical synchronization. The issue is resolved.
I tried replacing glfw's poll() with epoll(), since according to https://man7.org/linux/man-pages/man7/epoll.7.html, "when used as a level-triggered interface (the default, when EPOLLET is not specified), epoll is simply a faster poll(2)"
The event you're seeing is caused by buffer swap. I guess the X11 fd supplies this event and nothing can be done about it from glfw's side. If I comment out glfwSwapBuffers, or use single buffer + glFlush(), this periodic signal disappears from epoll(). I didn't check, but poll() will likely see the same.
On X11, any performance difference between poll() vs epoll() is currently overwhelmed by latency from rendering, which is causing waits of 2-200 ms with both. No idea why the render thread is clobbering poll() on a different thread, but it's not a glfw-caused problem. I have been unsuccessful in testing Wayland.
I took the example mentioned in a tutorial as a baseline of my code. What I want to achieve is to get the
X11
socket and wait on it withepoll
. As soon as I get socket ready for reading, I doglfwPollEvents()
to drain the event queue. My expectations is that, that the program enters wait state. But I get busy loop with72
bytes left for read each iteration. These bytes are not belong to theX11
event loop, as the type ofXEvent
contains garbage.My setup follows.
RELEASE=21.1
CODENAME=vera
EDITION="Xfce"
DESCRIPTION="Linux Mint 21.1 Vera"
DESKTOP=Gnome
TOOLKIT=GTK
NEW_FEATURES_URL=https://www.linuxmint.com/rel_vera_xfce_whatsnew.php
RELEASE_NOTES_URL=https://www.linuxmint.com/rel_vera_xfce.php
USER_GUIDE_URL=https://www.linuxmint.com/documentation.php
GRUB_TITLE=Linux Mint 21.1 Xfce
The text was updated successfully, but these errors were encountered: