hrydgard / ppsspp

A PSP emulator for Android, Windows, Mac and Linux, written in C++. Want to contribute? Join us on Discord at https://discord.gg/5NJB6dD or just send pull requests / issues. For discussion use the forums at forums.ppsspp.org.
https://www.ppsspp.org
Other
11.42k stars 2.19k forks source link

SBAR freezing during online ad-hoc play #14453

Open samosaphile opened 3 years ago

samosaphile commented 3 years ago

What happens?

In Shin Budokai Another Road, sometimes when in selecting fighter screen, after both players select who they wanna play as, the game freezes. It gets mad annoying because once it starts happening it tends to continue over and over and kills the experience. Sometimes selecting a specific fighter (in this case it was unlocked Gohan), triggers the freezing (does not matter what the opponent chooses to play as it seems). The only way around it was basically to stop selecting unlocked Gohan (and even then other times random freezing still happens). Please note this is between 2 android ppsspp client builds, unsure if reproducible when it's win-pc <-> android. Also, when the freezes happen, it's usually only one player it happens to while the other player hasn't frozen at all (find this quite interesting actually).

Another issue is during matches it'll sometimes freeze, but I think this is triggered when one or someone simply presses too many buttons at same time usually.

What should happen?

Well, it shouldn't freeze at all tbh.

What are you using?

What hardware / device and operating system?

Pixel 4a on stockOS (android 11)

What graphics card (GPU) or mobile phone model?

Adreno 618. Sunfish.

What PPSSPP version (standalone/official), and did it work before?

1.11.2-432 Dev build and I don't think this issue happens when playing with a win pc user / player but can't really confirm as I'm mostly playing with other fellow mobile android users.

Which game or games?

USA region.

Checklist

anr2me commented 3 years ago

1.11.2-432 is kinda old, please test it using the latest dev builds from https://buildbot.orphis.net/ppsspp/ to find out whether this issue still exist or already fixed on recent updates.

Btw, are you testing this on LAN or over the internet/VPN? because freezes/stutters could also caused by lost packets, where the game need to resend the data causing the other side need to wait longer time (looks frozen on screen because the new state is not synced yet on that side)

samosaphile commented 3 years ago

I know, it's old. I actually tried updating fairly recently but ended up playing allot worse and now paranoid of newer builds making things worse :p. But I will try to update latest and test and get back to you here.

I usually always test socom.cc port 1500 for this game.

That's a good point about freezing being caused by lost packets. The friend I'm playing lives in New York and I'm in Uk. So it's quite abit of distance travel.

Just found it strange some of the freezes occured during menu selection. One would think there aren't many packets being sent there. Which made me think it was more memory related....

ghost commented 3 years ago

I also got this Windows to Android. I am not sure but I think its because TCP No Delay being on all the time by default. I remember it caused that issue in the past but now you cant even disable it while being online. Maybe because the game moves from TCP to UDP and back it causes issues or something. Windows to Windows worked fine with someone very very far from me (American to Europe).

anr2me commented 3 years ago

I also got this Windows to Android. I am not sure but I think its because TCP No Delay being on all the time by default. I remember it caused that issue in the past but now you cant even disable it while being online. Maybe because the game moves from TCP to UDP and back it causes issues or something. Windows to Windows worked fine with someone very very far from me (American to Europe).

You can try disabling it from INI file, there should still be TCPNoDelay in it, and see if it have any effect or not, most-likely not, because delaying the packet will just be giving additional latency.

ghost commented 3 years ago

Can Android disable it too tho? Maybe having it disabled by default is better.

anr2me commented 3 years ago

Oops sorry, it can't be disabled anymore, the code that checked TCPNoDelay config is not existed anymore. The code for Android and desktop/PC are the same, since most posix-compatible OS [supposedly] worked the same.

ghost commented 3 years ago

rip

samosaphile commented 3 years ago

Disabling TCP no delay is no solution to me. With this option enabled in this game, I am able to play someone all the way from California while me being in uk, both on wifi, and still not that laggy. Even forgetting about that distance, last time I tried playing someone close to me in EU with this option off and it was unplayable. Just too laggy.

I am not too sure what exactly this option does but it matters massively for this game. Hopefully, there is someway to mimic whatever it does but without causing the freezing issue, haven't got to test this game again yet, will get to it soon (hopefully)

hrydgard commented 3 years ago

If it helps so much, why are you saying "Disabling TCP no delay is no solution to me" ? Did you add an extra negation? I'm confused.

unknownbrackets commented 3 years ago

So if I'm understanding properly, TCP no delay => causes freezes, but also massively improves latency problems. Removing TCP no delay => freezes gone, but latency issues are significant. When you say "freeze" is it a temporary stall and then it comes back, or is it stuck until you restart?

My guess is the PSP probably always did "no delay", at least for adhoc. But if the two clients have different power, and are not using real clock sync, I could see the packets coming in in an order that's confusing which might lead to hangs potentially... could be a race condition.

-[Unknown]

anr2me commented 3 years ago

If it helps so much, why are you saying "Disabling TCP no delay is no solution to me" ? Did you add an extra negation? I'm confused.

LOL the wording can be confusing but he saying it correctly :D

TCP_NODELAY is a socket option on TCP socket, the default is Disabled (on most system) when a socket is created (or inherited if from the parent socket when accepted)

By default, Nagle's algorithm and Delayed ACK are broadly implemented across networks, including the internet. Nagle's algorithm effectively only allows one packet to be actively transporting on the network at any given time, this tends to hold back traffic due to the interactions between the Nagle's algorithm and delayed ACKs. Hence Nagle's algorithm is undesirable in highly interactive environments.

https://www.extrahop.com/company/blog/2016/tcp-nodelay-nagle-quickack-best-practices/

Anyway, most games (especially PC games) usually Disable Nagle's algorithm (TCP_NODELAY=True) to improve response time, since games usually use many small packets.

ghost commented 3 years ago

So if I'm understanding properly, TCP no delay => causes freezes, but also massively improves latency problems. Removing TCP no delay => freezes gone, but latency issues are significant. When you say "freeze" is it a temporary stall and then it comes back, or is it stuck until you restart?

My guess is the PSP probably always did "no delay", at least for adhoc. But if the two clients have different power, and are not using real clock sync, I could see the packets coming in in an order that's confusing which might lead to hangs potentially... could be a race condition.

-[Unknown]

Didn't thought about "real clock" in that scenerio. Could be that it helps if both people enable it the issue is its so demanding on some Android devices lol. Anyway I do really remember that disabling the option "Enable TCP No Delay" from PPSSPP Networking helped with getting rid of the freezes when I last tried it, I am not saying it for nothing most of what I say ends up being correct (in regards to PPSSPP anyway) :S . I remember it even happened on local instances on single PC but that stopped occuring.

Updated: I tried playing with someone online , TCP no Delay option was on and the freeze occured. Back into version 1.11.3 and the freeze didnt occur with TCP No Delay option being disabled. Not sure about "real clock" though. @samosaphile could confirm.

samosaphile commented 3 years ago

Using newer build did not fix issue. Using 10k port did not either. Switching to different server (from socom to sushi) made no difference.

I think what @unknownbrackets said, might be possibly true about race condition occurring.

I didn't test much with the TCP No Delay option being disabled, but I did go back to 1.11.3 build for abit. I think there was still some freezing? Maybe it is abit more stable, but it did freeze once for me here too.

Might just be my friend's phone tbh. I don't really get freezes much with anyone else but him. But then again, I mostly don't get any games with anyone else but him either so...

samosaphile commented 3 years ago

Would just like to add, I take back saying that TCP no delay option when disabled/enabled .. has a massive difference. If the two players have a somewhat decent connection, with that option off, it is slightier laggier but not by much tbh after testing again.

I think when the two players have poor connections, this option makes a bigger difference tho. (The difference between bearly playable to completely unplayable)

If it helps, do you think knowing the device that my friend plays on and providing a log next time this happens would help get to the bottom of this? Cuz really not sure what next steps to take now...

EDIT:

I should probably make another new thread for this, as it's a different ad-hoc issue. But in an android-to-windows-pc client setup. If the android player sends a match request to the pc player. It crashes his game. So only the pc player is able to send match requests. This bug isn't just unique to this game tho and happens in other games too.

samosaphile commented 3 years ago

Another update:

My friends device / phone is:

Coolpad legacy - (cp3705A)

ghost commented 3 years ago

Would just like to add, I take back saying that TCP no delay option when disabled/enabled .. has a massive difference. If the two players have a somewhat decent connection, with that option off, it is slightier laggier but not by much tbh after testing again.

I think when the two players have poor connections, this option makes a bigger difference tho. (The difference between bearly playable to completely unplayable)

If it helps, do you think knowing the device that my friend plays on and providing a log next time this happens would help get to the bottom of this? Cuz really not sure what next steps to take now...

EDIT:

I should probably make another new thread for this, as it's a different ad-hoc issue. But in an android-to-windows-pc client setup. If the android player sends a match request to the pc player. It crashes his game. So only the pc player is able to send match requests. This bug isn't just unique to this game tho and happens in other games too.

The crash only happens if you are on stable PPSSPP build. It got fixed later on the dev builds of PPSSPP. But now it will just give you an error instead if you try to connect from pc or something.