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

libwebsocket increase bandwidth #2353

Merged
merged 1 commit into from Apr 22, 2020

Conversation

PatriceJiang
Copy link
Contributor

// cocos thread and trigger user callbacks by 'Scheduler::performFunctionInCocosThread'. If game's fps is set
// to 60 (16.66ms), the latency will be (2ms + 3ms + 16.66ms + internet delay) > 21ms
lws_service(__wsContext, 2);
std::this_thread::sleep_for(std::chrono::milliseconds(3));
Copy link
Contributor Author

Choose a reason for hiding this comment

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

不需要sleep, lws_service 已经有类似的行为. 移除此逻辑同时可以减少延时.

Choose a reason for hiding this comment

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

这个变更会造成安卓下 cpu 暴增,2.4.4 实测,用 PerfDog 看性能,未连接 ws 时 cpu 3%,连接执行后 cpu 58%,且居高不下。
this.socketTask = new WebSocket(this.server_ip);

Choose a reason for hiding this comment

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

将这两行改回去后,重新打包发现 cpu 占用降回个位数。
论坛其他人也遇到这个问题:2.4.2 CPU占用率大幅度增加,发热耗电严重很多

@PatriceJiang
Copy link
Contributor Author

@minggo @wuzhiming 麻烦review下

minggo
minggo approved these changes Apr 20, 2020
minggo
minggo approved these changes Apr 20, 2020
@holycanvas holycanvas merged commit 47711e2 into cocos:v2.4.0 Apr 22, 2020
@PatriceJiang PatriceJiang deleted the v2.3-websocket-poll branch June 15, 2020 07:13
PatriceJiang added a commit to PatriceJiang/cocos2d-x-lite that referenced this pull request Sep 28, 2020
minggo pushed a commit that referenced this pull request Sep 28, 2020
@AnkoGo123
Copy link

2.4.6竟然还存在,我就说怎么window打包后客户机子经常无响应提示,我现在有理由严重怀疑无响应这个问题跟官方这个websocket问题有严重的挂钩

@minggo
Copy link
Contributor

minggo commented Oct 15, 2021

你的意思是这个修复引入了其他的问题?

@ChasenTsai
Copy link

ChasenTsai commented Oct 15, 2021

@minggo 请看我在上方的 回复

@AnkoGo123
Copy link

你的意思是这个修复引入了其他的问题?

不知道,我这边是打包win10后,采用到websocket,对方机子是cpu比较低,内存4g的机子,经常长时间运行会出现白屏无响应,我头疼的很,也不知道什么原因,得看下改后是否还出现这个问题,过几天叫客户测试下

@minggo
Copy link
Contributor

minggo commented Oct 15, 2021

@minggo 请看我在上方的 回复

好的。
@PatriceJiang 麻烦把 3.x 版本的修复同步到 2.x。

PatriceJiang added a commit to PatriceJiang/cocos2d-x-lite that referenced this pull request Oct 15, 2021
minggo pushed a commit that referenced this pull request Oct 15, 2021
PatriceJiang added a commit to PatriceJiang/cocos2d-x-lite that referenced this pull request Oct 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants