Repository navigation
fix: prevent X11 RECORD notifier busy loops - #224
Merged
deepin-bot[bot] merged 1 commit intoNov 19, 2026
Merged
Conversation
Reviewer's GuideImplementationDrain queued ordinary X events before returning from the RECORD notifier so reply processing can continue.
TestsAdd a pointer-mapping regression test that verifies RECORD input delivery and stop/start, and keep an X client connected across test cases.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 2 issues
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="src/plugin-qt/shortcut/src/backend/x11/modifierkeymonitor.cpp" line_range="600" />
<code_context>
+ // XRecordProcessReplies() calls XPending(), which does not read the
+ // socket while ordinary X events remain in Xlib's queue. Consume them
+ // so RECORD replies keep flowing and the read notifier can become idle.
+ while (XPending(m_dataDisplay) > 0) {
+ XEvent event;
+ XNextEvent(m_dataDisplay, &event);
</code_context>
<issue_to_address>
**Recorded key events stop arriving**
When RECORD replies arrive after the initial enable handshake, `handleEvents()` drains ordinary X events without calling `XRecordProcessReplies()`, so the RECORD callbacks are not dispatched, `handleRecordedData()` stops emitting key signals, and callers stop receiving captured input.
Call `XRecordProcessReplies()` on the notifier path so incoming RECORD replies dispatch their callbacks.
</issue_to_address>
### Comment 2
<location path="src/plugin-qt/shortcut/src/backend/x11/modifierkeymonitor.cpp" line_range="600" />
<code_context>
+ // XRecordProcessReplies() calls XPending(), which does not read the
+ // socket while ordinary X events remain in Xlib's queue. Consume them
+ // so RECORD replies keep flowing and the read notifier can become idle.
+ while (XPending(m_dataDisplay) > 0) {
+ XEvent event;
+ XNextEvent(m_dataDisplay, &event);
</code_context>
<issue_to_address>
**Qt event loop gets monopolized**
When another X client repeatedly changes keyboard or pointer mappings faster than the queue drains, `handleEvents()` keeps draining events while `XPending()` finds queued events, so it does not return to Qt's event loop and other work is not serviced.
Limit the number of queued events drained per call so `handleEvents()` returns to the Qt event loop.
</issue_to_address>XRecordProcessReplies delegates to XPending, which stops reading the data socket when ordinary X events remain in Xlib's queue. A MappingNotify can therefore stall RECORD replies and keep the socket notifier continuously active, consuming a CPU core in service-manager. Consume queued X events so XPending can continue processing RECORD replies. Add a pointer-mapping regression test covering input delivery and RECORD restart, and keep an X client connected to prevent Xvfb resets between tests. XRecordProcessReplies 内部调用 XPending;当 Xlib 队列残留普通 X 事件时, XPending 不再读取数据 socket。MappingNotify 因而可能阻塞 RECORD 回复, 导致 socket 通知器持续触发,service-manager 单线程持续占满 CPU。 消费队列中的普通 X 事件,让 XPending 继续处理 RECORD 回复。新增鼠标 按钮映射变化的回归测试,验证输入上报和 RECORD 重启;测试期间保持 一个 X 客户端连接,防止 Xvfb 在测试用例之间重置。 Log: prevent X11 RECORD notifier busy loops PMS: TASK-398925 Change-Id: If5cc0eb52d3b2981154c5196b3e207793e78cb0d
yixinshark
force-pushed
the
fix/x11-record-notifier-spin
branch
from
November 19, 2026 07:36
610d0e6 to
50269b3
Compare
mhduiy
approved these changes
Nov 19, 2026
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mhduiy, yixinshark The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Contributor
Author
|
/forcemerge |
1 similar comment
Contributor
Author
|
/forcemerge |
|
This pr force merged! (status: behind) |
|
This pr force merged! (status: unknown) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The shortcut plugin can consume a CPU core after an ordinary X event, such as
MappingNotify, enters the RECORD data connection's Xlib queue. XRecordProcessReplies
calls XPending, which returns without reading the socket while that queue is
nonempty, leaving RECORD replies unread and repeatedly activating QSocketNotifier.
Drain ordinary X events with XPending/XNextEvent so RECORD replies continue to be
processed. Add a regression test for pointer-button mapping changes, subsequent
input delivery, and RECORD stop/start. Keep one X client connected during the test
suite to prevent Xvfb resets between cases.
快捷键插件的 RECORD 数据连接收到普通 X 事件后,XPending 会因 Xlib 队列
非空而停止读取 socket,导致通知器持续空转。排空这些事件后恢复 RECORD
数据消费,并补充鼠标按钮映射变化、输入上报及监控重启的回归测试。
Validation:
Pms: TASK-398925
Related: linuxdeepin/developer-center#14213
Summary by Sourcery
Prevent X11 RECORD notifier busy loops by draining queued ordinary X events before processing recorded input.
Bug Fixes:
Tests: