diff --git a/renderdoc/os/posix/android/android_network.cpp b/renderdoc/os/posix/android/android_network.cpp index a37725576..24a38f371 100644 --- a/renderdoc/os/posix/android/android_network.cpp +++ b/renderdoc/os/posix/android/android_network.cpp @@ -23,11 +23,26 @@ ******************************************************************************/ #include +#include #include "os/os_specific.h" #include "os/posix/posix_network.h" namespace Network { +void SocketPostSend() +{ + // we need to throttle android sending to ensure it never gets ahead of the PC otherwise the + // forwarded port may encounter a EWOULDBLOCK error. + // adb is buggy and will scompletely drop all writes as soon as a write blocks: + // https://issuetracker.google.com/issues/139078301 + // + // Throttling the device end is a hack but is reasonably reliable as we assume the PC side is fast + // enough to read it. Since we batch most sends, sleeping on each send is not too costly, but this + // may have some impact especially around small packets (we force a flush on the end of each + // chunk/packet). + usleep(1500); +} + uint32_t Socket::GetRemoteIP() const { // Android uses abstract sockets which are only "localhost" accessible diff --git a/renderdoc/os/posix/apple/apple_network.cpp b/renderdoc/os/posix/apple/apple_network.cpp index 8e6f8a8ca..2dd71cfa2 100644 --- a/renderdoc/os/posix/apple/apple_network.cpp +++ b/renderdoc/os/posix/apple/apple_network.cpp @@ -27,6 +27,11 @@ namespace Network { +void SocketPostSend() +{ + // only needed for awful hack on Android +} + uint32_t Socket::GetRemoteIP() const { return GetIPFromTCPSocket((int)socket); diff --git a/renderdoc/os/posix/ggp/ggp_network.cpp b/renderdoc/os/posix/ggp/ggp_network.cpp index 8e6f8a8ca..2dd71cfa2 100644 --- a/renderdoc/os/posix/ggp/ggp_network.cpp +++ b/renderdoc/os/posix/ggp/ggp_network.cpp @@ -27,6 +27,11 @@ namespace Network { +void SocketPostSend() +{ + // only needed for awful hack on Android +} + uint32_t Socket::GetRemoteIP() const { return GetIPFromTCPSocket((int)socket); diff --git a/renderdoc/os/posix/linux/linux_network.cpp b/renderdoc/os/posix/linux/linux_network.cpp index 8e6f8a8ca..2dd71cfa2 100644 --- a/renderdoc/os/posix/linux/linux_network.cpp +++ b/renderdoc/os/posix/linux/linux_network.cpp @@ -27,6 +27,11 @@ namespace Network { +void SocketPostSend() +{ + // only needed for awful hack on Android +} + uint32_t Socket::GetRemoteIP() const { return GetIPFromTCPSocket((int)socket); diff --git a/renderdoc/os/posix/posix_network.cpp b/renderdoc/os/posix/posix_network.cpp index 271642b3e..1fa90c49b 100644 --- a/renderdoc/os/posix/posix_network.cpp +++ b/renderdoc/os/posix/posix_network.cpp @@ -70,6 +70,8 @@ static std::string errno_string(int err) namespace Network { +void SocketPostSend(); + void Init() { } @@ -190,6 +192,9 @@ bool Socket::SendDataBlocking(const void *buf, uint32_t length) RDCASSERT(sent == length); + // incredibly ugly hack necessary for android + SocketPostSend(); + return true; }