Repository navigation
fix: prevent X11 RECORD notifier busy loops (2500u3) - #225
yixinshark wants to merge 1 commit into
Conversation
Reviewer's GuideImplementationDrain queued ordinary X events before returning from the RECORD notifier so XRecordProcessReplies can continue reading replies and avoid a busy loop.
TestsKeep an X client connected throughout the suite and add regression coverage for pointer-mapping changes, continued input delivery, and RECORD stop/start.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
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-603" />
<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 input stops arriving**
When the data connection receives RECORD replies after context enablement, `handleEvents()` drains Xlib events but never calls `XRecordProcessReplies()`, so queued RECORD data does not reach `handleRecordedData()`. Subsequent key events stop being reported, and the `EndOfData` callback needed to restart capture cannot run.
Call `XRecordProcessReplies()` from `handleEvents()` to dispatch queued RECORD replies.
</issue_to_address>| while (XPending(m_dataDisplay) > 0) { | ||
| XEvent event; | ||
| XNextEvent(m_dataDisplay, &event); | ||
| } |
There was a problem hiding this comment.
🟠 High · Recorded input stops arriving
When the data connection receives RECORD replies after context enablement, handleEvents() drains Xlib events but never calls XRecordProcessReplies(), so queued RECORD data does not reach handleRecordedData(). Subsequent key events stop being reported, and the EndOfData callback needed to restart capture cannot run.
Call XRecordProcessReplies() from handleEvents() to dispatch queued RECORD replies.
Prompt for AI agents
In `src/plugin-qt/shortcut/src/backend/x11/modifierkeymonitor.cpp` at lines 600-603:
**Recorded input stops arriving**
When the data connection receives RECORD replies after context enablement, `handleEvents()` drains Xlib events but never calls `XRecordProcessReplies()`, so queued RECORD data does not reach `handleRecordedData()`. Subsequent key events stop being reported, and the `EndOfData` callback needed to restart capture cannot run.
Call `XRecordProcessReplies()` from `handleEvents()` to dispatch queued RECORD replies.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
ceb8b2b to
3aead6d
Compare
|
[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 |
|
TAG Bot New tag: 6.2.1 |
Backport #224 to
develop/2500u3.The shortcut plugin can consume a CPU core when an ordinary X event remains in
the RECORD data connection's Xlib queue. XRecordProcessReplies delegates to
XPending, which stops reading the socket while that queue is nonempty. Drain
ordinary events with XPending/XNextEvent so RECORD replies continue to be processed.
Add regression coverage for pointer-button mapping changes, subsequent input
delivery, and RECORD stop/start. Keep an X client connected throughout the suite
to prevent Xvfb resets between tests. This PR contains one commit with the same
patch as the master PR.
将 #224 的 RECORD 空转修复移植到 develop/2500u3。排空 Xlib 普通事件队列,
恢复 RECORD 数据消费;回归测试覆盖鼠标按钮映射变化、后续输入上报和
监控停止后重启。
Validation:
Pms: TASK-398925
Related: linuxdeepin/developer-center#14213
Summary by Sourcery
Prevent X11 RECORD notifier busy loops by draining queued ordinary events before processing monitored input.
Bug Fixes:
Tests: