Why do game logs get jumbled up?

Game development with Board Game Arena Studio
Post Reply
User avatar
ShaPhi7
Posts: 37
Joined: 22 April 2020, 20:44

Why do game logs get jumbled up?

Post by ShaPhi7 »

I have an interesting one that I'm a bit stuck on!

I am trying to work out what caused this bug https://boardgamearena.com/bug?id=147610, so that I can stop it happening.
The bug is that when the game is refreshed (most noticeable in turn based mode) the logs are showing out of order: imgur.com/a/LR48KLq

I have thought for a while that the game was just logging too much, and that the timestamps of logs were too close together for BGA to cope with showing them correctly, so my solution is to not log as often.

However, when I think of other games that cause lots of logs in a short space of time e.g. exploding kittens (example game: https://boardgamearena.com/3/explodingk ... =722696613), I can't find any evidence of this being a problem.

So I don't really understand why the issue is only present in the below code. What is it doing wrong/differently to everything else?

The code with the bug is here (note that it's on the original edition branch, not Main): https://github.com/ShaPhi7/loveletter/b ... r.game.php
User avatar
firgon
Posts: 56
Joined: 14 October 2014, 06:27

Re: Why do game logs get jumbled up?

Post by firgon »

I think there is a mess around public and private notifs. I remember you should always send private notif first and end with a public notif. If you do not proceed like this it can produce weird thing as what you have on your screenshot. I would search around that.
User avatar
Tisaac
Posts: 2736
Joined: 26 August 2014, 21:28

Re: Why do game logs get jumbled up?

Post by Tisaac »

It's a known issue of bga, private and public notifs are stored separately into packets and are not correctly reordered when placed into the log. Nothing you can do about that
User avatar
ShaPhi7
Posts: 37
Joined: 22 April 2020, 20:44

Re: Why do game logs get jumbled up?

Post by ShaPhi7 »

Thanks for sharing, that knowledge is really helpful actually.

I will take a look at how some other games use public and private notifications with that in mind and work out how to minimise the impact.
User avatar
ShaPhi7
Posts: 37
Joined: 22 April 2020, 20:44

Re: Why do game logs get jumbled up?

Post by ShaPhi7 »

Some further research in case it's useful for anyone in the future:

At the bottom of the Notify section of https://en.doc.boardgamearena.com/Main_ ... ifications, it says:
Important: If both public and private notifications are sent to the same player in the same action (AJAX call), they will initially appear in the log in the order in which they were called, but they are placed into the game log in the following order: All private notifications first, then all public notifications. This means that when the page is refreshed, or when a player loads an asynchronous game, if you have called any public notifications before the last private notification, they will appear out of order in the log.
I think the best thing to do if you are seeing your logs mixed up is to arrange your notifications private first, and then public (not always possible), or review whether you could break whatever is happening down into multiple actions, though based on the original bug screenshot, this doesn't fully fix the issue, as some of the notifications you see there are sent in different actions.

If for whatever reason you can't break it down, then a slightly more hacky workaround is probably to stick to private notifications, but send them to all players.

A couple of things to note though.

It is mentioned at https://en.doc.boardgamearena.com/Main_ ... ifications that "If you are ONLY sending private notifications during action handling, they will not have an associated move_id (to avoid this, add simple public notification with empty message)."

Also, no public notifications means that spectators get missed. To notify a spectator, you could send a public notification that is ignored by players (you can ignore notifications via https://en.doc.boardgamearena.com/Game_ ... ifications).

If you have a better ideas, please share :)
Post Reply

Return to “Developers”