Trosnoth freezes when hosting a new game when running from code
Summary
A quick summary of the bug.
Steps to reproduce
I am on windows and running the game from source, using pyCharm. I click the play button in pyCharm. I then click the "play" word button on the many menu of Trosnoth. Then host game. Then the "go!" word button. This bug doesn't always happen, but it does happen every couple of times I try and launc the game from source.
What is the current bug behavior?
The game will then either get stuck on a blank white screen with the ui elements and the word "loading" in the middle. Or it will show the game world, but you cannot move around. I also sometimes the trosnoth server list entries twice in the other window. I do not know if this is related.
What is the expected correct behavior?
That the game starts correctly, your person appears and you can move around and stuff.
Relevant logs and/or screenshots
This is my logs when the bug occurs.
"C:\Users\Peter\Documents\Python\Trosnoth 2022\venv\Scripts\python.exe" -Wdefault "C:/Users/Peter/Documents/Python/Trosnoth 2022/run-trosnoth.py"
:0: UserWarning: You do not have a working installation of the service_identity module: 'No module named 'service_identity''. Please install it from <https://pypi.python.org/pypi/service_identity> and make sure all of its dependencies are satisfied. Without the service_identity module, Twisted can perform only rudimentary TLS client hostname verification. Many valid certificate/hostname mappings may be rejected.
pygame 2.1.2 (SDL 2.0.18, Python 3.8.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
2022-08-02 12:50:06,599 Failed to check trosnoth.org for stable version: [<twisted.python.failure.Failure OpenSSL.SSL.Error: [('STORE routines', '', 'unregistered scheme'), ('system library', '', ''), ('STORE routines', '', 'unregistered scheme'), ('STORE routines', '', 'unsupported'), ('STORE routines', '', 'unregistered scheme'), ('system library', '', ''), ('STORE routines', '', 'unregistered scheme'), ('STORE routines', '', 'unsupported'), ('STORE routines', '', 'unregistered scheme'), ('system library', '', ''), ('STORE routines', '', 'unregistered scheme'), ('STORE routines', '', 'unsupported'), ('SSL routines', '', 'certificate verify failed')]>]
--- deferred stack ---
Traceback (most recent call last):
Failure: twisted.web._newclient.ResponseNeverReceived: [<twisted.python.failure.Failure OpenSSL.SSL.Error: [('STORE routines', '', 'unregistered scheme'), ('system library', '', ''), ('STORE routines', '', 'unregistered scheme'), ('STORE routines', '', 'unsupported'), ('STORE routines', '', 'unregistered scheme'), ('system library', '', ''), ('STORE routines', '', 'unregistered scheme'), ('STORE routines', '', 'unsupported'), ('STORE routines', '', 'unregistered scheme'), ('system library', '', ''), ('STORE routines', '', 'unregistered scheme'), ('STORE routines', '', 'unsupported'), ('SSL routines', '', 'certificate verify failed')]>]
2022-08-02 12:50:10,259 Exception in callback <TaskStepMethWrapper object at 0x00000282CC530FA0>()
handle: <Handle <TaskStepMethWrapper object at 0x00000282CC530FA0>() created at C:\Users\Peter\Documents\Python\Trosnoth 2022\venv\lib\site-packages\asyncqt\__init__.py:364>
source_traceback: [<FrameSummary file C:\Program Files\Python\Python38\lib\contextlib.py, line 113 in __enter__>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\trosnoth\network\server.py, line 200 in run>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\trosnoth\network\server.py, line 214 in __init__>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\trosnoth\game.py, line 155 in __init__>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\trosnoth\model\universe.py, line 1589 in __init__>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\trosnoth\model\universe.py, line 1441 in start>, <FrameSummary file C:\Program Files\Python\Python38\lib\asyncio\tasks.py, line 661 in ensure_future>, <FrameSummary file C:\Program Files\Python\Python38\lib\asyncio\base_events.py, line 431 in create_task>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\venv\lib\site-packages\asyncqt\__init__.py, line 372 in call_soon>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\venv\lib\site-packages\asyncqt\__init__.py, line 364 in call_later>]
Traceback (most recent call last):
File "C:\Program Files\Python\Python38\lib\asyncio\events.py", line 81, in _run
self._context.run(self._callback, *self._args)
RuntimeError: Cannot enter into task <Task pending name='Task-25' coro=<ScenarioManager.run_level() running at C:\Users\Peter\Documents\Python\Trosnoth 2022\trosnoth\model\universe.py:1458> created at C:\Users\Peter\Documents\Python\Trosnoth 2022\trosnoth\model\universe.py:1441> while another task <Task pending name='Task-24' coro=<HostGamePage.ok_clicked() running at C:\Users\Peter\Documents\Python\Trosnoth 2022\trosnoth\welcome\play.py:1137> cb=[AsyncCallbackManager.task_done()] created at C:\Program Files\Python\Python38\lib\asyncio\tasks.py:382> is being executed.
2022-08-02 12:50:12,092 Max server tick jitter: 872 ms
This is my logs for when a game runs normally for comparison.
"C:\Users\Peter\Documents\Python\Trosnoth 2022\venv\Scripts\python.exe" -Wdefault "C:/Users/Peter/Documents/Python/Trosnoth 2022/run-trosnoth.py"
:0: UserWarning: You do not have a working installation of the service_identity module: 'No module named 'service_identity''. Please install it from <https://pypi.python.org/pypi/service_identity> and make sure all of its dependencies are satisfied. Without the service_identity module, Twisted can perform only rudimentary TLS client hostname verification. Many valid certificate/hostname mappings may be rejected.
pygame 2.1.2 (SDL 2.0.18, Python 3.8.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
2022-08-02 12:57:35,590 Failed to check trosnoth.org for stable version: [<twisted.python.failure.Failure OpenSSL.SSL.Error: [('STORE routines', '', 'unregistered scheme'), ('system library', '', ''), ('STORE routines', '', 'unregistered scheme'), ('STORE routines', '', 'unsupported'), ('STORE routines', '', 'unregistered scheme'), ('system library', '', ''), ('STORE routines', '', 'unregistered scheme'), ('STORE routines', '', 'unsupported'), ('STORE routines', '', 'unregistered scheme'), ('system library', '', ''), ('STORE routines', '', 'unregistered scheme'), ('STORE routines', '', 'unsupported'), ('SSL routines', '', 'certificate verify failed')]>]
--- deferred stack ---
Traceback (most recent call last):
Failure: twisted.web._newclient.ResponseNeverReceived: [<twisted.python.failure.Failure OpenSSL.SSL.Error: [('STORE routines', '', 'unregistered scheme'), ('system library', '', ''), ('STORE routines', '', 'unregistered scheme'), ('STORE routines', '', 'unsupported'), ('STORE routines', '', 'unregistered scheme'), ('system library', '', ''), ('STORE routines', '', 'unregistered scheme'), ('STORE routines', '', 'unsupported'), ('STORE routines', '', 'unregistered scheme'), ('system library', '', ''), ('STORE routines', '', 'unregistered scheme'), ('STORE routines', '', 'unsupported'), ('SSL routines', '', 'certificate verify failed')]>]
2022-08-02 12:57:44,797 Exception in callback <TaskWakeupMethWrapper object at 0x00000197EEECED90>(<_GatheringFu...\tasks.py:698>)
handle: <Handle <TaskWakeupMethWrapper object at 0x00000197EEECED90>(<_GatheringFu...\tasks.py:698>) created at C:\Users\Peter\Documents\Python\Trosnoth 2022\venv\lib\site-packages\asyncqt\__init__.py:364>
source_traceback: [<FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\venv\lib\site-packages\twisted\internet\asyncioreactor.py, line 255 in run>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\venv\lib\site-packages\asyncqt\__init__.py, line 286 in run_forever>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\venv\lib\site-packages\asyncqt\__init__.py, line 226 in timerEvent>, <FrameSummary file C:\Program Files\Python\Python38\lib\asyncio\events.py, line 81 in _run>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\trosnoth\gui\app.py, line 460 in pygame_event_loop>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\venv\lib\site-packages\asyncqt\__init__.py, line 226 in timerEvent>, <FrameSummary file C:\Program Files\Python\Python38\lib\asyncio\events.py, line 81 in _run>, <FrameSummary file C:\Program Files\Python\Python38\lib\asyncio\tasks.py, line 805 in _done_callback>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\venv\lib\site-packages\asyncqt\__init__.py, line 372 in call_soon>, <FrameSummary file C:\Users\Peter\Documents\Python\Trosnoth 2022\venv\lib\site-packages\asyncqt\__init__.py, line 364 in call_later>]
Traceback (most recent call last):
File "C:\Program Files\Python\Python38\lib\asyncio\events.py", line 81, in _run
self._context.run(self._callback, *self._args)
RuntimeError: Cannot enter into task <Task pending name='Task-5' coro=<single_entry_task.<locals>.launch_method() running at C:\Users\Peter\Documents\Python\Trosnoth 2022\trosnoth\utils\aio.py:158> wait_for=<_GatheringFuture finished result=[None, None, None, None, None, None, ...] created at C:\Program Files\Python\Python38\lib\asyncio\tasks.py:698> cb=[<TaskWakeupMethWrapper object at 0x00000197EEC94700>()] created at C:\Program Files\Python\Python38\lib\asyncio\tasks.py:382> while another task <Task pending name='Task-27' coro=<PygameRunner.pygame_event_loop() running at C:\Users\Peter\Documents\Python\Trosnoth 2022\trosnoth\gui\app.py:460> cb=[_wait.<locals>._on_completion() at C:\Program Files\Python\Python38\lib\asyncio\tasks.py:507] created at C:\Program Files\Python\Python38\lib\asyncio\tasks.py:382> is being executed.
2022-08-02 12:57:45,022 Max server tick jitter: 982 ms
Possible fixes
I suspect that the reason this happens infrequently is that it is a race condition.