lichess-org / lila

♞ lichess.org: the forever free, adless and open source chess server ♞
https://lichess.org
GNU Affero General Public License v3.0
15.62k stars 2.28k forks source link

Consistency is haphazard #755

Closed chadparry closed 9 years ago

chadparry commented 9 years ago

When the network connection is temporarily lost, the game's consistency is no longer guaranteed. The typical way this manifests is that the player makes a move, then the app loses the connection, then regains the connection, and the app reports that no more moves are being made. To the player on the mobile app, it looks like the other player is still moving. Meanwhile, according to the server, the other player has already moved. Eventually, the UI shows that the time runs out, and the player thinks that the game is won, when according to the server the game was lost.

I've seen several games on my own phone where an opponent's move was never reported to me. Because of a related issue in the Android client, I also saw one game where the board shown on my phone was a board that never existed in the game; the opponent's queen and bishop were shown in places which they never actually occupied at the same time in the real game. These are all manifestations of the same consistency bug. See http://en.lichess.org/qa/151/my-reconnected-games-dont-show-all-the-moves.

While the connection is down, a message can be lost. The client does not recover gracefully from a lost message. The correct protocol should be to have a message that updates the entire board state from the server, including all pieces, the move count, the clock, and other state. Then, that message should be requested whenever there is a gap detected in the message sequence.

Note that the Android client also has the same consistency bug. See https://github.com/veloce/lichobile/issues/185.

chadparry commented 9 years ago

Was this closed by accident? The website code should not have race conditions that affect the outcome of games.

Unihedro commented 9 years ago

I'm pretty sure this issue is specific to the mobile app's connection method, as when I reconnect with the web interface, it automatically refreshes to reconnect when my connection is back.

chadparry commented 9 years ago

I just reproduced this right now to double-check. I started a game on my phone, and during the game I briefly turned on airplane mode. Afterward, the Chrome instance on my phone thought that it had 3:52 to move, but the Chrome instance on the opponent's desktop thought that it only had 3:30 to move. I let the time on the phone decrease down to 0:20 and then suddenly it informed me that I had already lost the game.

I've also seen this issue where the clock wasn't the only problem. Sometimes the opponent's move does not get reported to the phone at all. To be clear, the webpage does not refresh on its own when the connection is restored. The workaround is to guess when maybe the state is wrong and to manually refresh. (I have a tunnel on my commute home and I frequently lose games because of the lack of consistency).