mirror of
https://github.com/genxium/DelayNoMore
synced 2024-12-26 03:39:00 +00:00
Enhanced logging efficiency.
This commit is contained in:
parent
642adff919
commit
5d92b339f6
18
README.md
18
README.md
@ -120,6 +120,24 @@ When building for native platforms, it's much more convenient to trigger the Coc
|
|||||||
```
|
```
|
||||||
shell> cd <proj-root>
|
shell> cd <proj-root>
|
||||||
shell> /path/to/CocosCreator.exe --path ./frontend --build "platform=win32;debug=true"
|
shell> /path/to/CocosCreator.exe --path ./frontend --build "platform=win32;debug=true"
|
||||||
|
shell> cd ./frontend/build/jsb-link/frameworks/runtime-src/proj.win32 && MSBUILD DelayNoMore.vcxproj -property:Configuration=Debug
|
||||||
|
```
|
||||||
|
or
|
||||||
|
```
|
||||||
|
shell> cd <proj-root>
|
||||||
|
shell> /path/to/CocosCreator.exe --path ./frontend --build "platform=win32;debug=false"
|
||||||
|
shell> cd ./frontend/build/jsb-link/frameworks/runtime-src/proj.win32 && MSBUILD DelayNoMore.vcxproj -property:Configuration=Release
|
||||||
|
```
|
||||||
|
|
||||||
|
for release.
|
||||||
|
|
||||||
|
If `MSBUILD` command is not yet added to `PATH`, Use `Get-Command MSBUILD` in `Developer Command Prompt for VS 2017/2019` to see where the command should come from and add it to `PATH`.
|
||||||
|
|
||||||
|
Similarly for Android release build
|
||||||
|
```
|
||||||
|
shell> cd <proj-root>
|
||||||
|
shell> /path/to/CocosCreator.exe --path ./frontend --build "platform=android;debug=false"
|
||||||
|
shell> cd ./frontend/build/jsb-link/frameworks/runtime-src/proj.android-studio && ./gradlew assembleRelease
|
||||||
```
|
```
|
||||||
|
|
||||||
### 2.4 CococCreator native build reloading
|
### 2.4 CococCreator native build reloading
|
||||||
|
@ -461,7 +461,7 @@
|
|||||||
"array": [
|
"array": [
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
216.65450766436658,
|
210.4441731196186,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -549,7 +549,7 @@
|
|||||||
"array": [
|
"array": [
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
216.65450766436658,
|
210.4441731196186,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -385,6 +385,7 @@ cc.Class({
|
|||||||
self.rdfIdToActuallyUsedInput = new Map();
|
self.rdfIdToActuallyUsedInput = new Map();
|
||||||
|
|
||||||
self.networkDoctor = new NetworkDoctor(20);
|
self.networkDoctor = new NetworkDoctor(20);
|
||||||
|
self.allowSkippingRenderFrameFlag = true;
|
||||||
self.skipRenderFrameFlag = false;
|
self.skipRenderFrameFlag = false;
|
||||||
|
|
||||||
self.allowRollbackOnPeerUpsync = true;
|
self.allowRollbackOnPeerUpsync = true;
|
||||||
@ -443,7 +444,7 @@ cc.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
onLoad() {
|
onLoad() {
|
||||||
cc.game.setFrameRate(59);
|
cc.game.setFrameRate(60);
|
||||||
cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
|
cc.view.setOrientation(cc.macro.ORIENTATION_LANDSCAPE);
|
||||||
cc.view.enableAutoFullScreen(true);
|
cc.view.enableAutoFullScreen(true);
|
||||||
|
|
||||||
@ -902,12 +903,15 @@ cc.Class({
|
|||||||
--------------------------------------------------------
|
--------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
// The actual rollback-and-chase would later be executed in update(dt).
|
// The actual rollback-and-chase would later be executed in update(dt).
|
||||||
|
if (CC_DEBUG) {
|
||||||
|
// Printing of this message might induce a performance impact.
|
||||||
console.log(`Mismatched input detected, resetting chaserRenderFrameId: ${self.chaserRenderFrameId}->${renderFrameId1} by
|
console.log(`Mismatched input detected, resetting chaserRenderFrameId: ${self.chaserRenderFrameId}->${renderFrameId1} by
|
||||||
firstPredictedYetIncorrectInputFrameId: ${firstPredictedYetIncorrectInputFrameId}
|
firstPredictedYetIncorrectInputFrameId: ${firstPredictedYetIncorrectInputFrameId}
|
||||||
lastAllConfirmedInputFrameId=${self.lastAllConfirmedInputFrameId}
|
lastAllConfirmedInputFrameId=${self.lastAllConfirmedInputFrameId}
|
||||||
recentInputCache=${self._stringifyRecentInputCache(false)}
|
recentInputCache=${self._stringifyRecentInputCache(false)}
|
||||||
batchInputFrameIdRange=[${batch[0].inputFrameId}, ${batch[batch.length - 1].inputFrameId}]
|
batchInputFrameIdRange=[${batch[0].inputFrameId}, ${batch[batch.length - 1].inputFrameId}]
|
||||||
fromUDP=${fromUDP}`);
|
fromUDP=${fromUDP}`);
|
||||||
|
}
|
||||||
self.chaserRenderFrameId = renderFrameId1;
|
self.chaserRenderFrameId = renderFrameId1;
|
||||||
let rollbackFrames = (self.renderFrameId - self.chaserRenderFrameId);
|
let rollbackFrames = (self.renderFrameId - self.chaserRenderFrameId);
|
||||||
if (0 > rollbackFrames) {
|
if (0 > rollbackFrames) {
|
||||||
@ -965,7 +969,7 @@ fromUDP=${fromUDP}`);
|
|||||||
//console.log(`Updated encoded input of peerJoinIndex=${peerJoinIndex} to ${peerEncodedInput} for inputFrameId=${inputFrameId}/renderedInputFrameIdUpper=${renderedInputFrameIdUpper} from ${JSON.stringify(inputFrame)}; newInputFrameDownsyncLocal=${self.gopkgsInputFrameDownsyncStr(newInputFrameDownsyncLocal)}; existingInputFrame=${self.gopkgsInputFrameDownsyncStr(existingInputFrame)}`);
|
//console.log(`Updated encoded input of peerJoinIndex=${peerJoinIndex} to ${peerEncodedInput} for inputFrameId=${inputFrameId}/renderedInputFrameIdUpper=${renderedInputFrameIdUpper} from ${JSON.stringify(inputFrame)}; newInputFrameDownsyncLocal=${self.gopkgsInputFrameDownsyncStr(newInputFrameDownsyncLocal)}; existingInputFrame=${self.gopkgsInputFrameDownsyncStr(existingInputFrame)}`);
|
||||||
self.recentInputCache.SetByFrameId(newInputFrameDownsyncLocal, inputFrameId);
|
self.recentInputCache.SetByFrameId(newInputFrameDownsyncLocal, inputFrameId);
|
||||||
|
|
||||||
if (self.allowRollbackOnPeerUpsync) {
|
if (true == self.allowRollbackOnPeerUpsync) {
|
||||||
// Reaching here implies that "true == self.allowRollbackOnPeerUpsync".
|
// Reaching here implies that "true == self.allowRollbackOnPeerUpsync".
|
||||||
// Shall we update the "chaserRenderFrameId" if the rendered history was wrong? It doesn't seem to impact eventual correctness if we allow the update of "chaserRenderFrameId" upon "inputFrameId <= renderedInputFrameIdUpper" here, however UDP upsync doesn't reserve order from a same sender and there might be multiple other senders, hence it might result in unnecessarily frequent chasing.
|
// Shall we update the "chaserRenderFrameId" if the rendered history was wrong? It doesn't seem to impact eventual correctness if we allow the update of "chaserRenderFrameId" upon "inputFrameId <= renderedInputFrameIdUpper" here, however UDP upsync doesn't reserve order from a same sender and there might be multiple other senders, hence it might result in unnecessarily frequent chasing.
|
||||||
if (
|
if (
|
||||||
@ -1048,7 +1052,7 @@ fromUDP=${fromUDP}`);
|
|||||||
|
|
||||||
Kindly note that Significantly different network bandwidths or delay fluctuations would result in frequent [type#1 forceConfirmation] too, but CAUSE FROM DIFFERENT LOCAL "update(dt)" RATE SHOULD BE THE FIRST TO INVESTIGATE AND ELIMINATE -- because we have control on it, but no one has control on the internet.
|
Kindly note that Significantly different network bandwidths or delay fluctuations would result in frequent [type#1 forceConfirmation] too, but CAUSE FROM DIFFERENT LOCAL "update(dt)" RATE SHOULD BE THE FIRST TO INVESTIGATE AND ELIMINATE -- because we have control on it, but no one has control on the internet.
|
||||||
*/
|
*/
|
||||||
if (self.skipRenderFrameFlag) {
|
if (self.allowSkippingRenderFrameFlag && self.skipRenderFrameFlag) {
|
||||||
self.networkDoctor.logSkippedRenderFrameCnt();
|
self.networkDoctor.logSkippedRenderFrameCnt();
|
||||||
self.skipRenderFrameFlag = false;
|
self.skipRenderFrameFlag = false;
|
||||||
return;
|
return;
|
||||||
@ -1125,7 +1129,9 @@ othersForcedDownsyncRenderFrame=${JSON.stringify(othersForcedDownsyncRenderFrame
|
|||||||
self.lastRenderFrameIdTriggeredAt = performance.now();
|
self.lastRenderFrameIdTriggeredAt = performance.now();
|
||||||
let t3 = performance.now();
|
let t3 = performance.now();
|
||||||
const [skipRenderFrameFlag, inputFrameIdFront, sendingFps, srvDownsyncFps, peerUpsyncFps, doctorRollbackFrames, skippedRenderFrameCnt] = self.networkDoctor.isTooFast(self);
|
const [skipRenderFrameFlag, inputFrameIdFront, sendingFps, srvDownsyncFps, peerUpsyncFps, doctorRollbackFrames, skippedRenderFrameCnt] = self.networkDoctor.isTooFast(self);
|
||||||
|
if (self.allowSkippingRenderFrameFlag) {
|
||||||
self.skipRenderFrameFlag = skipRenderFrameFlag;
|
self.skipRenderFrameFlag = skipRenderFrameFlag;
|
||||||
|
}
|
||||||
if (self.showNetworkDoctorInfo) {
|
if (self.showNetworkDoctorInfo) {
|
||||||
self.showNetworkDoctorLabels(inputFrameIdFront, sendingFps, srvDownsyncFps, peerUpsyncFps, doctorRollbackFrames, skippedRenderFrameCnt);
|
self.showNetworkDoctorLabels(inputFrameIdFront, sendingFps, srvDownsyncFps, peerUpsyncFps, doctorRollbackFrames, skippedRenderFrameCnt);
|
||||||
}
|
}
|
||||||
|
@ -89,23 +89,28 @@ NetworkDoctor.prototype.isTooFast = function(mapIns) {
|
|||||||
const [inputFrameIdFront, sendingFps, srvDownsyncFps, peerUpsyncFps, rollbackFrames, skippedRenderFrameCnt] = this.stats();
|
const [inputFrameIdFront, sendingFps, srvDownsyncFps, peerUpsyncFps, rollbackFrames, skippedRenderFrameCnt] = this.stats();
|
||||||
if (sendingFps >= this.inputRateThreshold + 3) {
|
if (sendingFps >= this.inputRateThreshold + 3) {
|
||||||
// Don't send too fast
|
// Don't send too fast
|
||||||
|
if (CC_DEBUG) {
|
||||||
|
// Printing of this message might induce a performance impact.
|
||||||
console.log(`Sending too fast, sendingFps=${sendingFps}`);
|
console.log(`Sending too fast, sendingFps=${sendingFps}`);
|
||||||
|
}
|
||||||
return [true, inputFrameIdFront, sendingFps, srvDownsyncFps, peerUpsyncFps, rollbackFrames, skippedRenderFrameCnt];
|
return [true, inputFrameIdFront, sendingFps, srvDownsyncFps, peerUpsyncFps, rollbackFrames, skippedRenderFrameCnt];
|
||||||
} else {
|
} else {
|
||||||
const sendingFpsNormal = (sendingFps >= this.inputRateThreshold);
|
const sendingFpsNormal = (sendingFps >= this.inputRateThreshold);
|
||||||
// An outstanding lag within the "inputFrameDownsyncQ" will reduce "srvDownsyncFps", HOWEVER, a constant lag wouldn't impact "srvDownsyncFps"! In native platforms we might use PING value might help as a supplement information to confirm that the "selfPlayer" is not lagged within the time accounted by "inputFrameDownsyncQ".
|
// An outstanding lag within the "inputFrameDownsyncQ" will reduce "srvDownsyncFps", HOWEVER, a constant lag wouldn't impact "srvDownsyncFps"! In native platforms we might use PING value might help as a supplement information to confirm that the "selfPlayer" is not lagged within the time accounted by "inputFrameDownsyncQ".
|
||||||
const recvFpsNormal = (srvDownsyncFps >= this.inputRateThreshold || peerUpsyncFps >= this.inputRateThreshold * (window.boundRoomCapacity - 1));
|
const recvFpsNormal = (srvDownsyncFps >= this.inputRateThreshold || peerUpsyncFps >= this.inputRateThreshold * (window.boundRoomCapacity - 1));
|
||||||
if (sendingFpsNormal && recvFpsNormal) {
|
if (sendingFpsNormal && recvFpsNormal) {
|
||||||
let selfInputFrameIdFront = gopkgs.ConvertToNoDelayInputFrameId(mapIns.renderFrameId);
|
|
||||||
let minInputFrameIdFront = Number.MAX_VALUE;
|
let minInputFrameIdFront = Number.MAX_VALUE;
|
||||||
for (let k = 0; k < window.boundRoomCapacity; ++k) {
|
for (let k = 0; k < window.boundRoomCapacity; ++k) {
|
||||||
if (k + 1 == mapIns.selfPlayerInfo.JoinIndex) continue;
|
if (k + 1 == mapIns.selfPlayerInfo.JoinIndex) continue;
|
||||||
if (mapIns.lastIndividuallyConfirmedInputFrameId[k] >= minInputFrameIdFront) continue;
|
if (mapIns.lastIndividuallyConfirmedInputFrameId[k] >= minInputFrameIdFront) continue;
|
||||||
minInputFrameIdFront = mapIns.lastIndividuallyConfirmedInputFrameId[k];
|
minInputFrameIdFront = mapIns.lastIndividuallyConfirmedInputFrameId[k];
|
||||||
}
|
}
|
||||||
if ((selfInputFrameIdFront > minInputFrameIdFront) && ((selfInputFrameIdFront - minInputFrameIdFront) > (mapIns.inputFrameUpsyncDelayTolerance + 1))) {
|
if ((inputFrameIdFront > minInputFrameIdFront) && ((inputFrameIdFront - minInputFrameIdFront) > (mapIns.inputFrameUpsyncDelayTolerance + 1))) {
|
||||||
// first comparison condition is to avoid numeric overflow
|
// first comparison condition is to avoid numeric overflow
|
||||||
console.log(`Game logic ticking too fast, selfInputFrameIdFront=${selfInputFrameIdFront}, minInputFrameIdFront=${minInputFrameIdFront}, inputFrameUpsyncDelayTolerance=${mapIns.inputFrameUpsyncDelayTolerance}`);
|
if (CC_DEBUG) {
|
||||||
|
// Printing of this message might induce a performance impact.
|
||||||
|
console.log(`Game logic ticking too fast, selfInputFrameIdFront=${inputFrameIdFront}, minInputFrameIdFront=${minInputFrameIdFront}, inputFrameUpsyncDelayTolerance=${mapIns.inputFrameUpsyncDelayTolerance}`);
|
||||||
|
}
|
||||||
return [true, inputFrameIdFront, sendingFps, srvDownsyncFps, peerUpsyncFps, rollbackFrames, skippedRenderFrameCnt];
|
return [true, inputFrameIdFront, sendingFps, srvDownsyncFps, peerUpsyncFps, rollbackFrames, skippedRenderFrameCnt];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ void RecvRingBuff::put(char* newBytes, size_t newBytesLen) {
|
|||||||
}
|
}
|
||||||
slotEle->bytesLen = newBytesLen;
|
slotEle->bytesLen = newBytesLen;
|
||||||
memset(slotEle->ui8Arr, 0, sizeof slotEle->ui8Arr);
|
memset(slotEle->ui8Arr, 0, sizeof slotEle->ui8Arr);
|
||||||
for (int i = 0; i < newBytesLen; i++) {
|
for (size_t i = 0; i < newBytesLen; i++) {
|
||||||
*(slotEle->ui8Arr + i) = *(newBytes + i);
|
*(slotEle->ui8Arr + i) = *(newBytes + i);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user