Avoid ANR errors when attempting to start a MP game when server takes too long to respond

This commit is contained in:
yairm210
2024-11-19 08:55:49 +02:00
parent a914571b8e
commit 78c02df317

View File

@ -113,10 +113,12 @@ class NewGameScreen(
private fun startGameAvoidANRs(){ private fun startGameAvoidANRs(){
// Don't allow players to click the game while we're checking if it's ok // Don't allow players to click the game while we're checking if it's ok
Gdx.input.inputProcessor = null Gdx.input.inputProcessor = null
Concurrency.run { // even just *checking* can take time
val success = startGame() val success = startGame()
// if it is successful, the player should wait for the new screen, not touch the old one // if it is successful, the player should wait for the new screen, not touch the old one
if (!success) Gdx.input.inputProcessor = stage if (!success) Gdx.input.inputProcessor = stage
} }
}
private fun startGame(): Boolean { private fun startGame(): Boolean {
mapOptionsTable.cancelBackgroundJobs() mapOptionsTable.cancelBackgroundJobs()