Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Game Crashes with exception #13

Closed
kyrashelwo opened this issue Aug 29, 2022 · 7 comments
Closed

Game Crashes with exception #13

kyrashelwo opened this issue Aug 29, 2022 · 7 comments
Labels
bug Something isn't working

Comments

@kyrashelwo
Copy link

after ending my turn the game crashed with the following call stack (including a bit of context leading up to the crash):

[de.sesu8642.feudaltactics.gamelogic.ingame.BotAi] conquering tile 'Position: (-18.0,13.0) Color: 00ff00ff, Kingdom: de.sesu8642.feudaltactics.gamelogic.gamestate.Kingdom@70685436; savings: 12, Content: null' with stored unit 'BARON'
[de.sesu8642.feudaltactics.gamelogic.ingame.BotAi] acquiring a new unit
[de.sesu8642.feudaltactics.gamelogic.ingame.BotAi] conquering tile 'Position: (-19.0,14.0) Color: ffaaaaff, Kingdom: de.sesu8642.feudaltactics.gamelogic.gamestate.Kingdom@4b0a9690; savings: 0, Content: de.sesu8642.feudaltactics.gamelogic.gamestate.Capital' with stored unit 'SPEARMAN'
[de.sesu8642.feudaltactics.gamelogic.ingame.BotAi] acquiring a new unit
[de.sesu8642.feudaltactics.gamelogic.ingame.BotAi] selling previously bought castles again
[de.sesu8642.feudaltactics.gamelogic.ingame.BotAi] picking up all available units
[de.sesu8642.feudaltactics.gamelogic.ingame.BotAi] defending most important tiles
[de.sesu8642.feudaltactics.gamelogic.ingame.BotAi] protecting the kingdom with leftover units
YOUR TURN
Exception in thread "main" java.lang.NullPointerException
        at com.badlogic.gdx.scenes.scene2d.ui.Table.computeSize(Table.java:806)
        at com.badlogic.gdx.scenes.scene2d.ui.Table.layout(Table.java:953)
        at com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.validate(WidgetGroup.java:113)
        at com.badlogic.gdx.scenes.scene2d.ui.Table.draw(Table.java:108)
        at com.badlogic.gdx.scenes.scene2d.Group.drawChildren(Group.java:124)
        at com.badlogic.gdx.scenes.scene2d.Group.draw(Group.java:58)
        at com.badlogic.gdx.scenes.scene2d.ui.WidgetGroup.draw(WidgetGroup.java:170)
        at com.badlogic.gdx.scenes.scene2d.ui.Table.draw(Table.java:126)
        at com.badlogic.gdx.scenes.scene2d.Group.drawChildren(Group.java:111)
        at com.badlogic.gdx.scenes.scene2d.Group.draw(Group.java:58)
        at com.badlogic.gdx.scenes.scene2d.Stage.draw(Stage.java:129)
        at de.sesu8642.feudaltactics.ui.screens.IngameScreen.render(IngameScreen.java:411)
        at com.badlogic.gdx.Game.render(Game.java:48)
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:387)
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:192)
        at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:166)
        at de.sesu8642.feudaltactics.desktop.DesktopLauncher.main(DesktopLauncher.java:15)
<===========--> 87% EXECUTING [1h 42m 16s]

Autosafe worked, so no progress was lost.

I am running with ./gradlew desktop:run on commit 329d372 in linux. I don't have android SDK installed but I don't think this should be related. usually the game just fails to start first try and complains about the missing SDK and the second try works flawlessly.

@Sesu8642
Copy link
Owner

Thanks for reporting! This seems to be a bug in libGDX. I recently added the buttons that give you control over the enemy turn speed and the ability to skip it. Maybe the manipulation of the UI can cause this crash if it happens while rendering is in progress. It might also be caused by the changing texture of the speed button. Do you remember if you pressed that button when the crash happened?

@kyrashelwo
Copy link
Author

Interesting! Thanks for the quick response. I don't recall changing the speed, but I can't rule it out 100% sadly. I will observe it more closely if the crash happens again.

@Sesu8642 Sesu8642 added the bug Something isn't working label Aug 29, 2022
@kyrashelwo
Copy link
Author

kyrashelwo commented Aug 29, 2022

I observed it again, same callstack after Your Turn console log. This time I am sure I only clicked the end turn button. The crash happened immediately after clicking the "end turn" button, the moves of the enemy were not executed (or at least not displayed, even though I have set it to 300ms).

Possibly an additional related bug: I think restoring from the saved game allowed me to skip the enemy turn.

@Sesu8642
Copy link
Owner

I just observed it as well. I will try to re-do the UI change in a different way and see if the crash still happens.

@Sesu8642
Copy link
Owner

When the exception happens, only the UI thread crashes. The bots still do their turns and when they are done, an autosave happens. It would be better if all threads ended in case of an exception. Not sure if there is an easy way to do this.

@kyrashelwo
Copy link
Author

Ok, if just the animation is missing, but everything is saved and resumed correctly then it is not a big issue to me, especially if it only happens in case of an exception which usually will be rare. Thanks for the investigation!

@Sesu8642
Copy link
Owner

Sesu8642 commented Sep 5, 2022

Changing from one set of buttons to the other was triggered by a change of the game state which was triggered by the bot AI thread. It looks like the UI classes from libGDX are not thread-safe. When the button change happened at the same time as the rendering thread tried to render the UI, this exception (and possibly others) could occur.
If something similar happens again, please re-open.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants