Hello guys.
I have simple echo server (nodejs). And cocos2d-js application that measures ping time.
Here is results for different platforms:
Web ~ 1-2ms
Android ~ 70-250ms
I run this test using home wi-fi router (no internet data transfer).
Why ping on android is so huge? How can I achieve 1-2ms?
Thanks in advance
I found this also using websockets on android sending data every update crashes sometimes on android but is fine on desktop and ios devices
I found this also using websockets on android sending data every update crashes sometimes on android but is fine on desktop and ios devices
I have similar problem. Thatβs another thing to investigate. Maybe we should report this strange behavior to issue tracker?
Yes i suppose so but im assuming they know about it??
The only way around it on android is to slow down the updates by a huge amount.
Really irritating though!
@samuele3hu is taking charge of network libraries of Cocos2d, can you check this issue ?
@pandamicro @samuele3hu Sorry to bother you. Do you have new information about this problem?
1 Like
Can you give me the test codes,thanks.
I dont have any test codes!
But on android if you use websockets to send a message every update loop it will run then crash after a few seconds when it gets overloaded.
If you delay and only send one message every 8 loops it runs fine.
This was my issue anyway but on ios devices its perfect and able to handle constantly sending messages
Hello @samuele3hu, sorry for the delay.
Client:
var socket = new WebSocket("ws://192.168.88.226:8899"), time;
console.log('Started');
function ping() {
time = new Date().getTime();
console.log('Ping sent!');
socket.send('ping');
}
socket.onmessage = function (event) {
console.log('Ping is ' + (new Date().getTime() - time));
setTimeout(ping, 1000);
};
setTimeout(ping, 1000);
Server:
var WebSocketServer = require('ws').Server,
socket = new WebSocketServer({port: 8899});
console.log('Started!');
socket.on('connection', function (clientSocket) {
clientSocket.on('message', function () {
console.log('Ping!');
clientSocket.send('pong');
});
console.log('Connected!');
});
On andriod ping value is 70-250ms On web 1-2ms
Changing client code to:
var socket = new WebSocket("ws://192.168.88.226:8899"), time, count;
console.log('Started');
function ping() {
time = new Date().getTime();
console.log('Ping sent!');
socket.send('ping');
}
count = 5000;
while (count--) {
ping();
}
Fatal signal 11 (SIGSEGV), code 1, fault addr 0x4 in tid 4891 (GLThread 4804)
Take a look at screenshot: http://joxi.ru/Y82QzP5twZMwAd
I tested it with android-ndk-r9d, cocos 3.0 and 3.1, LG-Nexus 5
1 Like
This is exactly my issue on android hopefully can be resolved somehow
@nimble_vv, thank you for your replay. I would call JS-developer to check it,@pandamicro. And , i have a question that the data of Web you got were based on the pc?
@samuele3hu Yes. I have launched test on mobile browser (chrome). Result is 4-30ms.
@samuele3hu, @pandamicro any updates, guys?
Can I help you to solve this issue?
3 Likes
Has this problem been resolved?