empiricaly / empirica

Open source project to tackle the problem of long development cycles required to produce software to conduct multi-participant and real-time human experiments online.
https://empirica.ly/
Apache License 2.0
47 stars 8 forks source link

Players Freezing during unManaged Game when new player begins intro steps #404

Closed Jeffotter closed 1 year ago

Jeffotter commented 1 year ago

Is there an existing issue for this?

What happened?

When I begin a default app and attempt to make a game with a custom assignment. I created four games,

Input their ID -- no issues. Begin intro steps -- (players currently guessing jellybeans freeze to a loading screen)

When I refresh the two original players, they can now see the avatar of the new player while the new player is still in the intro steps.

Game resumes

Steps To Reproduce

  1. Create a default game

  2. Make a treatment

    image
  3. Modify App.jsx , Stage.jsx, Callbacks.jsx, server/index.js (code locations attached below, error was occurring before stage modification ) Custom assignment copied from here (https://github.com/JamesPHoughton/external-grouping)

  4. Start the game and create 3 Players

  5. Run 2 players through the intro steps and the game will begin

  6. While the game is running, start the third player

  7. After the 3rd player submits his ID the other two players will be frozen.

  8. Refresh on the two original players and see the third player who should still be in the intro steps

Empirica Version

Version: v1.6.0
SHA:     0d26251
Branch:  main
Time:    2023-08-10T11:36:38Z

Client:  1.6.0
Server:  1.6.0

What OS are you seeing the problem on?

macOS

What browser are you seeing the problem on?

Chrome

Relevant log output

There are no errors That I can see either the console logs or the IDE logs

Anything else?

https://github.com/Jeffotter/demo_unmanagedGame/blob/main/server/src/callbacks.js https://github.com/Jeffotter/demo_unmanagedGame/blob/main/server/src/index.js

https://github.com/Jeffotter/demo_unmanagedGame/blob/main/client/src/Stage.jsx https://github.com/Jeffotter/demo_unmanagedGame/blob/main/client/src/App.jsx

Code of Conduct

npaton commented 1 year ago

Thank you, @Jeffotter. I can't seem to access your repo. Would you mind adding me as a contributor with Read permission? Thanks!

Jeffotter commented 1 year ago

@npaton done! Sorry about that

npaton commented 1 year ago

It is happening because assignPlayer is called without await. To fix it, you need to add an async around that callback and add await on the assignPlayer line.

It took me a while to find the issue, it did not jump at me, and this is likely to cause problems for others. We'll make sure to have a warning about it in the docs when they are done. I've also created a fix for this, so that we commit all the changes even if await was not used: https://github.com/empiricaly/empirica/pull/410. But I am currently unsure about the consequences of changing this behavior, so I haven't merged it yet. TBD