OK, so I just found out that this bug is being caused by the screen being started by the network thread instead of the game thread:
I suspect a lot of other surprise crashes have been happening this way occasionally in the normal build too! (modifying things in use while ui is drawing). What we should do is keep the thread for receiving packets, but then send them to a queue which is read and run through in the game thread just before the game update loop. This will keep our client code simple and cost barely anything performance wise - since processing input packets instantly is not important for this game.
I suspect a lot of other surprise crashes have been happening this way occasionally in the normal build too! (modifying things in use while ui is drawing). What we should do is keep the thread for receiving packets, but then send them to a queue which is read and run through in the game thread just before the game update loop. This will keep our client code simple and cost barely anything performance wise - since processing input packets instantly is not important for this game.