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

Remove XFlush call in event loop #982

Merged
merged 1 commit into from
Jun 25, 2019

Conversation

murarth
Copy link
Contributor

@murarth murarth commented Jun 25, 2019

Internally, XFlush calls _XSend to write data. It then calls
XEventsQueued(display, QueuedAfterReading), which reads data from the
X server connection. This prevents the event loop source callback from
being run, as there is no longer data waiting on the socket.

Ideally, we would want to call _XSend directly to ensure that no
output is buffered by Xlib. However, this function is not exported as
part of Xlib's public API.

Testing with the XFlush call removed does not appear to adversely
affect the performance of an application. If any bugs should eventually
arise from this change, perhaps another function may be used in place of
XFlush, such as XPending, which writes buffered output but does not
so aggressively read from the X server connection.

Closes #865

  • Tested on all platforms changed
  • cargo fmt has been run on this branch
  • Added an entry to CHANGELOG.md if knowledge of this change could be valuable to users
  • Updated documentation to reflect any user-facing changes, including notes of platform-specific behavior
  • Created or updated an example program if it would help users understand this functionality
  • Updated feature matrix, if new features were added or implemented

Internally, `XFlush` calls `_XSend` to write data. It then calls
`XEventsQueued(display, QueuedAfterReading)`, which reads data from the
X server connection. This prevents the event loop source callback from
being run, as there is no longer data waiting on the socket.

Ideally, we would want to call `_XSend` directly to ensure that no
output is buffered by Xlib. However, this function is not exported as
part of Xlib's public API.

Testing with the `XFlush` call removed does not appear to adversely
affect the performance of an application. If any bugs should eventually
arise from this change, perhaps another function may be used in place of
`XFlush`, such as `XPending`, which writes buffered output but does not
so aggressively read from the X server connection.

Closes rust-windowing#865
Copy link
Contributor

@elinorbgr elinorbgr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not know XFlush had such special semantics. If everything works without it, then we're good removing it.

@goddessfreya goddessfreya merged commit 29e2481 into rust-windowing:master Jun 25, 2019
@murarth murarth deleted the issue-865 branch June 25, 2019 21:38
@Osspial
Copy link
Contributor

Osspial commented Jun 26, 2019

Now that this has been merged, I think we should release an alpha2 so X11 users can properly use the new event loop.

@aloucks
Copy link
Contributor

aloucks commented Jun 27, 2019

@murarth
Copy link
Contributor Author

murarth commented Jun 27, 2019

@aloucks That one appears to be called only when necessary. It doesn't seem to be interfering with the event loop.

kosyak pushed a commit to kosyak/winit that referenced this pull request Jul 10, 2019
Internally, `XFlush` calls `_XSend` to write data. It then calls
`XEventsQueued(display, QueuedAfterReading)`, which reads data from the
X server connection. This prevents the event loop source callback from
being run, as there is no longer data waiting on the socket.

Ideally, we would want to call `_XSend` directly to ensure that no
output is buffered by Xlib. However, this function is not exported as
part of Xlib's public API.

Testing with the `XFlush` call removed does not appear to adversely
affect the performance of an application. If any bugs should eventually
arise from this change, perhaps another function may be used in place of
`XFlush`, such as `XPending`, which writes buffered output but does not
so aggressively read from the X server connection.

Closes rust-windowing#865
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

EventLoop 2.0 swallowing events
5 participants