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
10.79k stars 2.12k forks source link

CCCR - SF2 - Ad-hoc netplay broken #14547

Open samosaphile opened 3 years ago

samosaphile commented 3 years ago

What happens?

Communication error occurs when doing versus mode and deluxe versus mode in street fighter 2 champion and hyper editions. This is from capcom classic collection reloaded (USA version). This was tested on ports 1500, 10k and 60k of socom.cc and 2500 on sushi. The rest of the games in this collection probably do not work either, but I lost the patience to test them all. Screenshot_20210619-024422

What should happen?

I should be able to play with my friend, like every other game that works properly that is.

What are you using?

What hardware / device and operating system?

Pixel 4a. Pixel OS. Stock Android 11.

What graphics card (GPU) or mobile phone model?

Adeno 618 / Sunfish.

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

1.11.2-432 and 1.11.3-742, not sure if it worked before.

Which game or games?

ULUS10134

Checklist

anr2me commented 3 years ago

As i remembered Capcom Classics Collection Reloaded is using GameSharing feature which is not implemented at all on PPSSPP as of now.

Is there any other multiplayer mode on this game? May i know how to get to that multiplayer menu? because from main menu i can only find Game Sharing mode

anr2me commented 3 years ago

Okay, i managed to test Street Fighter 2 Hyper on localhost, multiplayer worked fine on Debug build but getting Communication error on Release build.. something may need to be slowed down i guess

anr2me commented 3 years ago

Hmm.. instead of speed issue, i feels there is something wrong from this PTP/TCP communication:

Host on Debug Build image The host is sending 6 bytes followed by 55 bytes and then waited for reply

Joined client on Debug Build image The client is receiving 6 bytes followed by 55 bytes and then sending a reply Both (Host and Client) keeps sending and receiving and the game progressed to the next screen.


Host on Release build image The host is sending 6 bytes followed by 55 bytes and then waited for reply (which never arrived)

Joined client on Release Build image The client is receiving 61 bytes (which is a combination of 6+55) and do nothing (where a reply was expected to be sent) Both (Host and Client) just waiting for data without sending anything and then showing Communication error message.

It seems there is an issue with combined TCP packets... i'll need to dump the contents to check whether they are corrupted or not later

samosaphile commented 3 years ago

As i remembered Capcom Classics Collection Reloaded is using GameSharing feature which is not implemented at all on PPSSPP as of now.

Is there any other multiplayer mode on this game? May i know how to get to that multiplayer menu? because from main menu i can only find Game Sharing mode

probably already figured it out by now, but if anyone still curious .. need to get into game, then it shows a versus and deluxe mode.

Do let me know if you need anything. Will try to do my best.

anr2me commented 3 years ago

Hmm.. i didn't see any corruption on the contents of the data being sent and received image image The contents on both 6 + 55 bytes being sent matched with 61 bytes being received.

Since this game never been released it could be a bug on the game it self if it can't handle TCP/Stream packets properly, since packets optimization are done at lower layer, it's not something we can change. But apparently this packet optimization didn't exist on debug build (may be it use debug version of winsock?), not sure about other platform tho.

anr2me commented 3 years ago

Okay i did another test to confirm whether this games are bad at handling stream packets or not by peeking on the packet size first, if it's larger than 55 bytes i forcefully making it only read the 1st 6 bytes image image The client ended receiving 6 bytes followed by 55 bytes and then replying (as expected by the sender) However, after awhile the game will shows Communication error again, probably another merged packets happening again somewhere with different variation of packet's size and the game ended broken again.

Anyway, since it's confirmed that this game can't handle dynamic stream packet's size, it can be considered as a bug on the game itself and should be fixed by the game developer, so i won't be fixing it, unless if there is a way for us to prevent TCP Stream packets from being merged upon arrival (which probably platform dependent)

PS: I also did another test to make sure it wasn't speed-related by overclocking Debug build to 1000 mhz and underclocking Release build to 16 mhz (also tried using interpreter to slow it down), both still have the same result with auto cpu clock (ie. Debug build worked fine, Release build didn't work)

ghost commented 3 years ago

Good thing you can play all of the games in the collection on other emulators. Even use rollback netcode with them which is superior.

samosaphile commented 3 years ago

There aren't many (good) options on android atm. The few that exist either force you to have a Google account as they rely on Google play services for online multiplayer. Or have terrible default controls (retroarch), you can edit the controls manually by textpad, but it abit of hassle / pain, nobody is gonna do that. They should really make it easier to modify controls on android.

Is rollback netcode something that the game dev's have to implement or can it be later added through emu? I ask because certain psp games could really benefit (street fighter alpha 3, possibly darkstalkers aswell).

anr2me commented 3 years ago

Rollback netcode is implemented by the game dev, usually combined with action prediction.

The game will predict a sequence of actions based on player's habit, for example when a player do a forward jump during a fight they will most likely do a flying kick or assuming the player is keep pressing the last button(ie. jump button), so the game makes this assumption and do a kick even before that player pressed the kick button, but if after a certain time (usually a few milliseconds) the packet that was received wasn't saying it's a kick button, then the state of the fight will be rolled back to before the kick was predicted.

This prediction + rollback is done to make the game have less delay, eventho in reality there were delays (due to latency) on input button over the network.

PS: Predicting player's habit may only exist on newer games nowadays, while old games will most-likely do the easy prediction, which is assuming the player is keep pressing the last button. https://arstechnica.com/gaming/2019/10/explaining-how-fighting-games-use-delay-based-and-rollback-netcode/

ghost commented 3 years ago

There aren't many (good) options on android atm. The few that exist either force you to have a Google account as they rely on Google play services for online multiplayer. Or have terrible default controls (retroarch), you can edit the controls manually by textpad, but it abit of hassle / pain, nobody is gonna do that. They should really make it easier to modify controls on android.

Is rollback netcode something that the game dev's have to implement or can it be later added through emu? I ask because certain psp games could really benefit (street fighter alpha 3, possibly darkstalkers aswell).

Fmulators/Frontends like FightCade got rollback netcode in them. The emulator devs added them into their emulators and thats what FightCade uses. But even if not you can use RetroArch instead and use the SNES/Genesis cores and then use Netplay with them. They will often be better to play then throught PPSSPP most likely.

Android is not a good candidate for rollback netcode because most of the devices use Wi-Fi... Wi-Fi in general and netplay dont go together well moreso with rollback.

To implement GGPO into the emulator one will need to use this SDK : https://github.com/pond3r/ggpo

anr2me commented 3 years ago

GGPO SDK only suitable for game developers and emulators that emulate devices that doesn't actually have network support (ie. NES, SNES, Genesis, etc). Basically these emulators only streams the input over network and sync the state of the emulators (or streams the output/screen/audio similar to Parsec), so it's more related to input device than networking.

While games that originally support network multiplayer have their own implementation of netcode, input reading, and state synchronization which are designed specific for each games by their developers.

ghost commented 3 years ago

Talking in general about other emulators that could implement it on Android. I know PPSSPP cant implement it because the console natively supports networking in it.

anr2me commented 2 years ago

I think the only way to solve this "TCP merged packets" issue is by implementing PTP protocol using datagram/UDP or raw socket instead of TCP socket, so the packets will remains intact without being merged/concatenated, but this will be like reinventing the wheel of TCP, which can be complex and there is also an issue of compatibility with pro-online and other emulators too.