Scirra / Construct-bugs

Public bug report submissions for Construct 3 and Construct Animate. Please read the guidelines then click the 'Issues' tab to get started.
https://www.construct.net
107 stars 83 forks source link

Multiplayer crashes the editor and previews, when a host leaves and tries to host a new game #4601

Open Alaadel opened 3 years ago

Alaadel commented 3 years ago

Problem description

The project is a host and 2 peers. I request room list first, if there are no rooms, the host hosts a game; and if there is a room, the peers can join. Peers keep requesting the room list until a room is found. After the game, the peers leave, and after 5 seconds, the host leaves. When trying to repeat the process, and clicking host on the host (while peers are polling room list), the previews halt, and they crash along with the editor.

Attach a .c3p

Bug MP Crash 3.zip

Steps to reproduce

  1. Run 3 debug previews (as popups). Consider the 1st one to be the host.
  2. In the host preview, enter the name: "testserver" (without quotes). For the peers, enter any other name.
  3. Click "Press here to start" on the 3 previews.
  4. Wait a few seconds (until the peers start requesting room list), and click "Ready" on the host. (You might encounter another bug here, where the peers will be stuck at "joining...". After a few seconds they will disconnect automatically and you can click the button again)
  5. One window will show "Please click the button". Click on "Click Me!" of that window.
  6. A timer will show. Please wait until it reaches 5 seconds (10 on the host). They all will leave the room after that.
  7. Click "Press here to start" in the 3 previews.
  8. Wait a moment, then click on "Ready" on host.

Observed result

The host will show "joining..." message, then all previews, along with the editor, will crash. There will be no crash report dialog in the editor. After force closing the editor, Chrome will show "Error code: RESULT_CODE_HUNG".

On Firefox: The same issue happens, but Firefox can avoid hung up by stopping the script in the host preview. I could get a log file from the console: log.zip

it shows details about a few errors, like:

Expected result

Graceful error handling. Firing OnError with an error message, or a normal disconnect.

More details

I solved it by waiting 5 more seconds after the host leaves and before it goes to the login layout (the relevant action is in "ComGame" group under "Common" group in the Game layout. Here is a working file: Bug MP Crash(1).zip)

Affected browsers/platforms: Chrome (Version 88.0.4324.182 (Official Build) (64-bit)) and Firefox 85.0 (64-bit)

First affected release:

System details

View details PASTE HERE
AshleyScirra commented 3 years ago

I can't seem to follow the steps: at step 5 I don't see anything that says "Please click the button" or "Click me!". I only see a button that says "Ready", but if I click that, I don't see a timer, so none of the remaining steps seem to make sense.

It's also exceptionally difficult to debug reports like this. Multiplayer networking is really hard to begin with, three simultaneously running previews is extremely difficult to test, and you can't step in to a debugger without dropping connections due to a timeout. Can you reduce this further to make the absolutely most minimal possible test case with the fewest events and objects conceivable? It would also be a lot easier if you could reproduce it with just two previews (which is still extremely difficult to handle, but itself easier than three previews). Multiplayer networking is hard, and people often make mistakes with their events anyway - the bug report guidelines are there to try to avoid the situation we end up working for hours or days and it just turns out some event was wrong (as was the case with the room detection check in your other report #4593).

Alaadel commented 3 years ago

Thank you. Sorry if my report was not easy to follow. I really tried to follow the guidelines as much as I can.

I have attached 2 videos of reproduction. One on Chrome where the editors and previews hang, and one on Firefox where FF suggests to stop the script causing the error in the editor.

You can test with 2 previews now (you can test with 3, just change the TEST_PEER_COUNT variable to 3 in the "Game events" sheet):

  1. Run 2 previews
  2. Enter "testserver" without quotes in the host. Enter any other name for peer.
  3. Click "Press Here To Start" on both.
  4. Wait a moment and then click "Ready" on the host.
  5. The peer should join the game.
  6. Click the button "Click Me" in peer.
  7. Wait a moment for the timers on both previews.
  8. The game will restart.
  9. Click "Press Here To Start" on both.
  10. Wait a moment and then click "Ready" on the host.

I know I might have made a mistake in my code, but I can't imagine why that would crash the editor. Thank you very much for your time.