You’ve probably either have played or seen videos of Super Mario Maker 2’s online “Multiplayer Versus” mode. You’ve probably also noticed just how laggy it can be sometimes. It’s almost as if the Switch console can’t handle the game and is dropping frames! Ever wondered why?
Before we begin, I’d just like to thank all of our Patrons. Your donations allow this site and our services (SSBUBot and JelonzoBot) to stay online. I’d also like to extend a very special thanks to our Generous-tier Patrons:
Note: The next few sections consist of content from my previous articles about the Splatoon 2 netcode and how Splatoon 2’s ranking system works with some edits. If you are already familiar with those articles, you may skip to “Synchronization”. It might be good to skim the next few sections for a refresher, however.
Let’s go over some concepts and terminology you will need to know to understand what I am talking about.
Basic Netcode Terminology
Please have a look over PCGamer’s excellent netcode overview if you aren’t familiar with netcode concepts and terms. I will not be explaining everything here otherwise this post would be a million words long. You don’t need to know every single thing, but knowing the basics goes a long way. You may want to keep it open to cross-reference some concepts that I will mention.
Pia Strikes Back
Pia is a library developed by Nintendo which makes creating networking features for games easier. It implements network features based on a “peer-to-peer” architecture, unlike the traditional “client-server” model. This means that instead of one server having a “one-on-one conversation” with every Nintendo Switch console to exchange information, all of the consoles communicate directly with each other. This group of systems connected together using pia is called a “session”.
But how do other people find each other’s sessions?
The Return of NEX
NEX is a two-part system comprising of a game server and a library containing APIs which game developers use to communicate with the server. NEX handles matchmaking for peer-to-peer sessions, NAT traversal (helping people behind firewalls and/or routers with getting connected to others), rankings, and data storage. Pia has built-in support for NEX’s matchmaking and NAT traversal features, making it easier for developers who are already using pia to implement online play. (NEX actually has its own peer-to-peer networking library independent of pia called VSocket, but I don’t think any game uses it?)
NEX actually began its life as Quazal Technologies Inc.’s Rendez-Vous, which started development all the way back in 2003. Ubisoft later acquired Quazal Technologies in 2010. Rendez-Vous lives on at Ubisoft, as their Montreal studio has continued to add features to it. Ubisoft also posted a job offer 3 months ago for a programmer that will work on Rendez-Vous, suggesting that Ubisoft continues to use it even in their modern games. Here is a selection of games (both new and old) that have used Rendez-Vous to implement multiplayer features:
- Hitman: Blood Money
- Spellforce 2
- Rock Band
- Assassin’s Creed III
- Tom Clancy’s Rainbow Six Siege
- For Honor
- Tom Clancy’s Ghost Recon: Wildlands
As for NEX, it appears Nintendo must have either bought or licensed Rendez-Vous’s source code from Quazal. Under Nintendo, Rendez-Vous was rebranded as “NEX” and Nintendo has continued to develop it in parallel to Rendez-Vous. Unfortunately, I’m not sure if Ubisoft and Nintendo collaborate on NEX.
Attack of the “Libraries”
In the previous sections, I referred to pia and NEX as “libraries”. If you are not a programmer: a “library” is a set of common code which is shared between multiple programs. Developers often split off reusable code into a library and then include the library in other programs in order to save development time. You might see where I’m going with this. Pia and NEX are actually used by multiple games on the 3DS, Wii U, and Switch. They were not built specifically for Super Mario Maker 2. Here is a selection of software that is powered by pia and/or NEX:
- Rhythm Heaven Megamix (pia only)
- Super Mario Maker for 3DS (NEX only)
- Friends service (NEX only)
- Mario Kart 8
- Super Mario Maker (NEX only)
- Friends service (NEX only)
- Splatoon 2
- Mario Kart 8 Deluxe
- Nintendo Entertainment System – Nintendo Switch Online
- Super Mario Maker 2
- Super Mario Odyssey (NEX only)
- Tetris 99 (NEX only)
This isn’t an exhaustive list – I’m less familiar with 3DS games, though both of the libraries are definitely available for 3DS. Here is a list that Kinnay has made which lists a bunch more Wii U and Switch games which utilize pia and/or NEX. (In addition, while Tetris 99 does use NEX, it is not a peer-to-peer game. It uses NEX to match people together, then control is seemingly transferred to a dedicated server to run the match.)
Now that we know everything that we need, let’s apply our knowledge to Super Mario Maker 2!
A big part of what causes lag is the connection quality of the other players in your session. So how does Super Mario Maker 2 determine whom to match you with?
As you may remember, the NEX game server handles matchmaking with other players. Depending on the availability of lobbies, a player may be instructed to open their own session or to join another session. In the latter case, there are various criteria which the server uses to determine which session a player should join. Each criterion is assigned a score value, and the session with the highest total score is chosen.
Here is the list of criteria that Nintendo can assign scores to:
- The difference in the Glicko2 rating between the session owner and the joining player
- The difference in the rate of disconnection between the owner and joining player
- How far the distance between the owner and the joining player is (calculated using GeoIP)
- If the country of origin matches
- How long the session has been waiting for players
- and more…
Having multiple criteria allows Nintendo’s server to be flexible when matching people together. For example, it may prefer matching people who are close in distance at first. However, if a player has been waiting a while for people to join, it could start to consider sessions with players who are further away than usual.
Unfortunately, we are unable to retrieve the specific values used for the matchmaking criteria. They are only visible to Nintendo.
Glicko2 is a public domain rating system invented by Professor Mark Glickman as a replacement for the Elo rating system. Because Super Mario Maker uses this system, you have a rating, a rating deviation (RD), and a volatility value in addition to your versus rating. The Glicko2 rating is what is used to matchmake you with other players in the first criterion above. These numbers are never exposed to the player. I can’t explain all the details about Glicko2 here, so for further reading, I suggest the following sites:
- http://www.glicko.net/glicko/glicko2.pdf (A paper written by Prof. Glickman)
With every win, your rating increases. With every loss, your rating decreases. It should be noted that Glicko2 only considers whether you won, lost, or if there was a draw. No in-game action will affect your rating value.
Once people have gathered in a session, how does the game keep everything in sync between all of the players? Each player’s position, power up state, invincibility state, and more must be kept the same on every console. There is no “server” to help out since the netcode is built on a peer-to-peer architecture. Super Mario Maker 2 primarily implements its netcode with the “sync” component from pia. I will refer to this component as “Pia Sync” from now on for convenience.
Pia Sync is a portion of pia that is primarily intended to synchronize controller inputs, though it can also be used to synchronize any data that the game programmers want. While I’m not 100% certain that Pia Sync is used for controller inputs, given some game code, Pia Sync’s primary purpose, and the game itself being suited towards this type of netcode, it does seem likely that controller sync is the use case. I will continue my explanation based on this assumption.
What does Pia Sync do exactly? Let’s use a simple example – a single A button press. (The Super Mario 64 TAS community must be freaking out at this point.) If the A button is pressed on one console’s controller, a signal is sent to all connected consoles which says that the A button was pressed on that console. When online, Super Mario Maker 2 simulates “virtual controllers” for each player and sets their input states from other consoles using Pia Sync. Mario would be assigned virtual controller 1, Luigi would be assigned 2, and so on. This simplifies synchronization greatly, as the states of objects or “actors” within the game world do not need to be synchronized. Only the controller inputs are sent over the network. It is like the people you are playing with are physically right next to you with their own controllers.
While it may seem like Pia Sync solves the issue of synchronization entirely, it does come with a significant trade-off. If a button press is not replayed on the exact frame that it happened on receiving consoles, it will likely cause the game state to be inconsistent between the source and destinations. This is called a “desynchronization”. For example, if an A button press is replayed late, it can make a difference between a player jumping on a platform and a player missing the platform then falling into an abyss. The player would then be considered dead on that console, but on the source console, they are actually still alive.
Pia Sync works around this issue by pausing the game until all of the inputs have arrived and restarting the game logic once that has happened. This means that while Pia Sync is waiting, the entire game will appear to be frozen or laggy depending on how severe the wait time is. While effective when everyone’s connections are able to keep up, this does mean that if even one person has a bad connection, it brings down the entire lobby’s game speed. This is the primary cause of lag within Super Mario Maker 2’s online multiplayer.
What other games work on this principle of synchronizing controllers? One example is Nintendo Switch Online’s NES emulator – it also uses Pia Sync. (If you’ve tried the online there, you might have seen the similarities to Super Mario Maker 2 in how lag manifests during gameplay.) Smash may also work like this, but I haven’t looked at that game much, so I can’t say for certain. Other non-Nintendo games and applications use the concept of syncing the controllers as well. For example, unofficial emulators such as Dolphin synchronize controller inputs in their netplay features. As games on older systems generally do not have any online support whatsoever, implementing controller input sync is the next best thing.
While I completely understand why the netcode was implemented in this fashion, I think there is definitely more that can be done in terms of optimization. The number of times that I get games which are laggy to the point that they are nearly unplayable is unacceptable for a paid online service. I don’t have any lag issues whatsoever in other Nintendo online games like Splatoon 1/2, Mario Kart 8 Deluxe, and ARMS, so it is not my connection.
I might get crucified for this opinion, but I don’t think peer-to-peer is the issue here. 4 players for a platformer game does not seem dedicated server worthy to me. (Splatoon 2, on the other hand…) At this point in time, I don’t expect a full netcode overhaul. Nintendo has never done anything similarly drastic to a game in post-launch updates at least to my knowledge. Perhaps Nintendo should work more on having a smoother experience on less-capable connections, especially since just one console which is unable to keep up can lag the entire session. Another option could be decreasing the maximum amount of latency / distance between consoles when matchmaking.
Whatever Nintendo ends up doing, I hope they manage to improve the netcode. It is a shame that one of the most exciting games in 2019 has this issue.
Again, thank you very much to our Generous-tier Patrons:
If you enjoyed this content, please consider supporting us on Patreon. While we currently have a focus on Splatoon 2, we will try our best to make your donations worth it. (Now that Splatoon 2 updates are dying down, we will likely move on to other Nintendo games like Super Mario Maker 2.) The money we raise from Patreon currently goes towards our server hosting costs for this website and our services (SSBUBot and JelonzoBot). Any excess funding will be saved for starting new services and rainy days.