diff --git a/README.md b/README.md index 59addf3..69dbcf3 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,13 @@ This project is a demo for a websocket-based rollback netcode inspired by [GGPO] ![Merged_cut_annotated_spedup](./charts/Merged_cut_annotated_spedup.gif) +(battle between 2 celluar 4G users using Android phones, [original video here](https://pan.baidu.com/s/1RL-9M-cK8cFS_Q8afMTrJA?pwd=ryzv)) + +![Phone4g_battle_spedup](./charts/Phone4g_battle_spedup.gif) + As lots of feedbacks ask for a discussion on using UDP instead, I tried to summarize my personal opinion about it in [ConcerningEdgeCases](./ConcerningEdgeCases.md) -- **since v0.9.25, the project is actually equipped with UDP capabilities as follows**. - When using the so called `native apps` on `Android` and `Windows` (I'm working casually hard to support `iOS` next), the frontends will try to use UDP hole-punching w/ the help of backend as a registry. If UDP hole-punching is working, the rollback is often less than `turn-around frames to recover` and thus not noticeable, being much better than using websocket alone. This video shows how the UDP holepunched p2p performs for [Phone-Wifi v.s. PC-Wifi (viewed by PC side)](https://pan.baidu.com/s/1K6704bJKlrSBTVqGcXhajA?pwd=l7ok). -- If UDP hole-punching is not working, e.g. for Symmetric NAT like in 4G/5G cellular network, the frontends will use backend as a UDP tunnel (or relay, whatever you like to call it). This video shows how the UDP tunnel performs for [Phone-4G v.s. PC-Wifi (viewed by PC side)](https://pan.baidu.com/s/1IZVa5wVgAdeH6D-xsZYFUw?pwd=dgkj). +- If UDP hole-punching is not working, e.g. for Symmetric NAT like in 4G/5G cellular network, the frontends will use backend as a UDP tunnel (or relay, whatever you like to call it). This video shows how the UDP tunnel performs for [Phone-4G v.s. PC-Wifi (merged view@v0.9.34, excellent synchronization)](https://pan.baidu.com/s/1yeIrN5TSf6_av_8-N3vdVg?pwd=7tzw). - Browser vs `native app` is possible but in that case only websocket is used. diff --git a/charts/Phone4g_battle_spedup.gif b/charts/Phone4g_battle_spedup.gif new file mode 100644 index 0000000..c2239d9 Binary files /dev/null and b/charts/Phone4g_battle_spedup.gif differ diff --git a/frontend/build-templates/.cocos-project.json b/frontend/build-templates/.cocos-project.json new file mode 100644 index 0000000..f7598f6 --- /dev/null +++ b/frontend/build-templates/.cocos-project.json @@ -0,0 +1,7 @@ +{ + "engine_version": "2.2.1", + "has_native": true, + "project_type": "js", + "projectName": "DelayNoMore", + "packageName": "org.genxium.delaynomore" +} diff --git a/frontend/build-templates/jsb-link/cocos-project-template.json b/frontend/build-templates/jsb-link/cocos-project-template.json index 1856b9c..6354270 100644 --- a/frontend/build-templates/jsb-link/cocos-project-template.json +++ b/frontend/build-templates/jsb-link/cocos-project-template.json @@ -18,11 +18,11 @@ "from": "cocos/scripting/js-bindings/manual/jsb_module_register.cpp", "to": "frameworks/runtime-src/Classes/jsb_module_register.cpp" }, { - "from": "frameworks/runtime-src/Classes/send_ring_buff.hpp", - "to": "frameworks/runtime-src/Classes/send_ring_buff.hpp" + "from": "frameworks/runtime-src/Classes/ring_buff.hpp", + "to": "frameworks/runtime-src/Classes/ring_buff.hpp" }, { - "from": "frameworks/runtime-src/Classes/send_ring_buff.cpp", - "to": "frameworks/runtime-src/Classes/send_ring_buff.cpp" + "from": "frameworks/runtime-src/Classes/ring_buff.cpp", + "to": "frameworks/runtime-src/Classes/ring_buff.cpp" }, { "from": "frameworks/runtime-src/Classes/udp_session.hpp", "to": "frameworks/runtime-src/Classes/udp_session.hpp" diff --git a/frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/send_ring_buff.cpp b/frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/ring_buff.cpp similarity index 98% rename from frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/send_ring_buff.cpp rename to frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/ring_buff.cpp index fe0a486..84ed0b8 100644 --- a/frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/send_ring_buff.cpp +++ b/frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/ring_buff.cpp @@ -1,5 +1,5 @@ #include -#include "send_ring_buff.hpp" +#include "ring_buff.hpp" // Sending void SendRingBuff::put(BYTEC* const newBytes, size_t newBytesLen, PeerAddr* pNewPeerAddr) { @@ -77,7 +77,7 @@ bool RecvRingBuff::pop(RecvWork* out) { if (0 >= oldCnt) { // "pop" could be accessed by either "GameThread/pollUdpRecvRingBuff" or "UvRecvThread/put", thus we should be proactively guard against concurrent popping while "1 == cnt" ++cnt; - return NULL; + return false; } // When concurrent "pop"s reach here, over-popping is definitely avoided. @@ -99,4 +99,4 @@ bool RecvRingBuff::pop(RecvWork* out) { ++cnt; return false; } -} \ No newline at end of file +} diff --git a/frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/send_ring_buff.hpp b/frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/ring_buff.hpp similarity index 100% rename from frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/send_ring_buff.hpp rename to frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/ring_buff.hpp diff --git a/frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/udp_session.hpp b/frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/udp_session.hpp index f9e2042..da6719a 100644 --- a/frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/udp_session.hpp +++ b/frontend/build-templates/jsb-link/frameworks/runtime-src/Classes/udp_session.hpp @@ -1,7 +1,7 @@ #ifndef udp_session_hpp #define udp_session_hpp -#include "send_ring_buff.hpp" +#include "ring_buff.hpp" int const maxPeerCnt = 10; diff --git a/frontend/build-templates/jsb-link/frameworks/runtime-src/proj.android-studio/app/jni/Android.mk b/frontend/build-templates/jsb-link/frameworks/runtime-src/proj.android-studio/app/jni/Android.mk index 4af1fdf..6252fac 100644 --- a/frontend/build-templates/jsb-link/frameworks/runtime-src/proj.android-studio/app/jni/Android.mk +++ b/frontend/build-templates/jsb-link/frameworks/runtime-src/proj.android-studio/app/jni/Android.mk @@ -15,7 +15,7 @@ LOCAL_SRC_FILES := hellojavascript/main.cpp \ ../../../Classes/jsb_module_register.cpp \ ../../../Classes/udp_session.cpp \ ../../../Classes/udp_session_bridge.cpp \ - ../../../Classes/send_ring_buff.cpp + ../../../Classes/ring_buff.cpp LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes diff --git a/frontend/build-templates/jsb-link/frameworks/runtime-src/proj.win32/DelayNoMore.vcxproj b/frontend/build-templates/jsb-link/frameworks/runtime-src/proj.win32/DelayNoMore.vcxproj index c29d7c0..7d031b6 100644 --- a/frontend/build-templates/jsb-link/frameworks/runtime-src/proj.win32/DelayNoMore.vcxproj +++ b/frontend/build-templates/jsb-link/frameworks/runtime-src/proj.win32/DelayNoMore.vcxproj @@ -190,11 +190,11 @@ copy "$(ProjectDir)..\..\..\project.json" "$(OutDir)\" /Y - + - + diff --git a/frontend/build-templates/jsb-link/frameworks/runtime-src/proj.win32/DelayNoMore.vcxproj.filters b/frontend/build-templates/jsb-link/frameworks/runtime-src/proj.win32/DelayNoMore.vcxproj.filters index a5df7d6..c3c94fb 100644 --- a/frontend/build-templates/jsb-link/frameworks/runtime-src/proj.win32/DelayNoMore.vcxproj.filters +++ b/frontend/build-templates/jsb-link/frameworks/runtime-src/proj.win32/DelayNoMore.vcxproj.filters @@ -22,7 +22,7 @@ Classes - + Classes @@ -40,7 +40,7 @@ win32 - + Classes