-
-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Emulated local Wi-Fi multiplayer support (2 players max) #242
Conversation
Thanks for contributing! I'll review and test this and get back to you as soon as I can. |
72efaba
to
1d5cb99
Compare
I seem to have made a bit of a mess when trying to rebase this to the dev branch. I Will try to fix it. |
1d5cb99
to
2d2c7fc
Compare
Would close issue #225 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution, and for your patience. Broadly speaking this looks okay, but there are some changes I'd like you to make. Some of the proposed changes will reduce the number of copies made of packets, which may help performance.
I also suggest adding Tracy markers at the start of important functions, then running a RelWithDebInfo
build through Tracy.
Once you make these changes I'll take another review pass and test it. Keep up the good work!
Added the tracepoints, will run with Tracy and analyze the result later. |
Ran it with Tracy, it appears that most of the time spent in the multiplayer code is spent waiting blocking for a packet. Sending a packet and receiving one are super quick by comparison. |
I've been trying to get Tracy to connect to my Android phone, but no luck so far. Any ideas? |
After testing more, it seems timeout has little impact on performance. However, too low of a timeout will cause frequent crashes. The value of 25 ms is good. |
I'll test this today and get back to you with thoughts. I'll also compare this to the upstream implementation, see if there's something we can do about the blocking. |
I had a chance to reproduce the lag in the core you described. Notably, standalone melonDS does not have this issue. Before we can merge this PR, we need to diagnose the lag and see how much of it actually comes from the core. I'll take some traces and get back to you. |
When you took your trace, what build settings did you use? I built the core (but not RetroArch itself) with optimizations and the lag wasn't as pronounced. I'm still looking over the trace for specifics. |
The traces I took were taken in a RelWithDebInfo build. |
I wonder if upstream melonDS does the same thing? I'll look into it. |
The lag is far less pronounced when building the core in Let me see what happens when using a wireless connection. |
Not too bad over wireless. It looks like on frames where |
I had a helpful conversation with @Arisotura on the melonDS Discord server about how the standalone frontend handles networking, starting here. If you're on Discord, what's your username? If not, I'll copy the discussion here. |
I implemented dropping stale packets. However, it made it harder at the beginning of a connection (taking me four times in Mario Kart DS on Wi-Fi LAN) for little (maybe none) performance benefit. |
That little, huh? I'm starting to suspect that future optimizations may be needed in RetroArch itself. Especially because I just noticed that RetroArch doesn't actually implement We've established that LAN netplay works okay in the core, so I'd like to avoid spinning our wheels forever. With that in mind, I'd like you to revert 545871b, unless you happen to discover a benefit that outweighs the drawbacks. Once you do that, I'll give your PR one more code review pass -- once outstanding feedback (if any) is addressed, I'll merge it and it'll be in the next release! I'll also want to include a warning in the core that this will only work on a real LAN; players trying to use LAN netplay across the Internet is a common source of support requests, and I don't want to add to the deluge. I can do that before releasing 1.2.0, though. |
This reverts commit 545871b.
Can you test Dragon Quest IX with up to 4 players? This is the game that should be the most popular with Netplay. |
@BernardoGomesNegri Just checking in, seeing if you need anything. From our last conversation on Discord, I recall that this is what you were working on:
|
Currently fixing >2 players., having a few issues. Also haven't worked much on the problem lately. |
I think this is ready for a re-review. Right now, it only works for 2 players. Support for 3 players and more is only doable once MAC address randomization is done. |
Good to merge! There's some follow-up work that I'd like to occur before this makes it into the next release, but those can be done in separate PRs later. I'll open tickets with more details. Thanks for your work! |
This patch adds support for emulated local (Wi-Fi) multiplayer using libretro's netpacket API, which allows a core to send and receive arbitrary data packets across the network. In RetroArch, this can be done by using the same interface used for netplay.
Unfortunately, due to the DS's tight latency requirements for local networks, it only works for good LAN connections on a few games. I managed to play Pokémon HeartGold between my phone (connected to a WiFi AP very close by) and my PC (wired), for example. On an emulated connection, the same game worked with 8ms ping and 3% packet loss, but it could get rather laggy at times.
Thanks to @JesseTG for helping me with this.