macOS + Node server: Latency with high polling rate devices
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 20/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- cpp, macos, node.js
调研方向
从 bindings/Node/libpointing/pointing/pointing.cc 开始,检查 commit 11bb753de457cfce719e1edbe4509739f557cbbc 中 macOS 事件处理的变更。在 macOS 上使用轮询频率高于 125Hz 的设备复现 Node binding,然后研究 HID callback 延迟与 JavaScript 响应性之间的权衡。当回调能够及时到达且不会冻结应用程序时,即视为完成。
由索引模型根据 Issue 内容生成。
描述
With libpointing's new nodejs binding on macOS, devices with high polling rate (i.e. > 125Hz) "lag": the js client receives the reports much later than it should, creating a very high latency.
After some digging, it seems to be related to the cohabitation of the Cocoa's event loop with Node's main loop. Long story short: Node does not process all macOS events in its main loop and therefore HID callbacks are never called. libpointing solves this problem by processing macOS events every tick for Xms (see https://github.com/INRIA/libpointing/blob/master/bindings/Node/libpointing/pointing/pointing.cc#L30, the time given to macOS event processing was recently reduced in 11bb753de457cfce719e1edbe4509739f557cbbc). This solution is basically a trade-off: if we give more time to process macOS events, then JS events are not treated as quickly and the app freezes, but if we prioritize the JS event loop, then the HID callbacks are not called as quickly. I experimented with different values to find a better trade-off, but nothing seemed ideal. The current value seems fine for devices with low poll rates (<125Hz).
Related StackOverflow issue (no answer): https://stackoverflow.com/questions/33599653/c-callbacks-are-not-called-for-node-bindings
It seems that this problem could also be solved from the js code, by re-writing node's main loop to process macOS events, but it is pretty involved and require the use of platform dependent APIs in JS: https://github.com/TooTallNate/NodObjC/issues/2
Tested on macOS Catalina.
- 主要语言
- C++
- 星标
- 54
- 派生
- 14
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
INRIA/libpointing 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 42/100
INRIA/libpointing#40 ·
-
难度 3/5 1-2 天 新手友好度 38/100
INRIA/libpointing#26 ·
-
难度 4/5 3-5 天 新手友好度 35/100
INRIA/libpointing#22 ·
-
难度 4/5 3-5 天 新手友好度 28/100
INRIA/libpointing#17 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 20/100
INRIA/libpointing#10 ·
查看 INRIA/libpointing 的全部 Issue
相似的 Issue
-
os:Linux
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
acceptable_buffer_backends: unknown backend names are silently ignored可能已有人在做 @mini-1235 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 70/100
ros2/rmw_fastrtps#945 ·
维护者通常 1 天内回复
-
bot-triaged module: correctness (silent) module: mps module: NaNs and Infs triage review
难度 2/5 半天 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
SCIInstitute/SCIRun#2842 ·
维护者通常 3 天内回复