7.4. Reference for Developing Applications With Synchronized Input Communication

This document provides reference information that is useful when developing applications with synchronized input communication.

Desync Caused by Unmatched States When Starting Synchronization

Desync can result if stations are not in matching states when synchronized communication starts.

Solution

Do not synchronize communication until the status of all stations match and synchronized communication has become possible. For example, desync can occur if states do not match and other processes that influence gameplay are executed before calling SyncProtocol::Start.

 

Desync at the End of Synchronization

Synchronization data that is sent immediately before synchronization ends may not be received by all stations because not all stations are on the same frame number. Desync can occur if the unreceived synchronization data affects gameplay.

Solution

Avoid this problem by ending synchronization after all stations no longer need synchronization data to proceed (such as after the level cleared screen), not immediately after the game ends. Also, transmit the end sync frame as synchronization data so that all stations end on the same frame.

 

Desync Caused by The Number of Times the Random Generator Has Been Called

Desync can occur if each station uses a different random number that affects game progress. For example, most effects do not influence gameplay. However, desync can occur if random numbers are used while processing an effect and the number of times the random generator is called differs.

Solution

Share the random seed before starting synchronization. Not only must all stations use the same random seed, but the number of times the random generator is called and the order in which it is called in must match for all stations.

Desync can be made easier to detect by putting all random generator calls inside a single function. For example, it enables you to handle desync by switching from generating a random number to returning a fixed one when desync is detected. Also, you can use one random number generator to get random numbers that influence gameplay and another random number generator to get random numbers that do not influence gameplay.

 

Desync Caused by Asynchronous Processing

Desync can occur if the result of an asynchronous process (such as loading a resource) that has just completed is applied to gameplay that uses synchronized communication.

Solution

Make sure that the time at which results are applied to gameplay match on each station after the asynchronous process completes.

 

Desync Caused by Culling Game Objects

When each station has a different viewpoint and computes different objects and behaviors due to culling, desyncing can occur because of differences in behavior and differences in the number of times the random number generator is called.

Solution

Make sure that the same objects are calculated on each station.

 

Desync Caused by Mismatched Player Information

Desync can occur when a game has elements such as having an item appear after the player has killed 100 enemies.

Solution

Be sure to share this information (such as items in inventory and total enemy kills) with all stations before starting synchronization.

 

Desync Caused by Background Music Syncing

If a game changes enemy behavior based on the background music, or performs a special effect in concert with a specific part of the background music, desyncing can occur if the streaming playback is not synchronized.

Solution

Include the background music trigger of the session host in the synchronization data, and have the session clients use that information for their operations.

 

Desync Detection

Desync can be easily detected by sharing information (such as the position of players, the position of a ball, and so on) that can easily get out of sync when desync occurs among all stations, and by checking whether the data on all stations matches. Only use this technique for debugging because the amount of data being transferred increases proportionally and can easily result in dropped frames.

 

Checking for Desync

If implementing desync detection as just described is too difficult, you can check whether desync has occurred by displaying the frame value and synchronization data on the screen. You can easily identify the cause of desync and know when it has occurred by recording the game screen for multiple stations and then visually comparing screens.