From 096f62a7198219502b357ac816d551f066cf60d8 Mon Sep 17 00:00:00 2001 From: yairm210 Date: Tue, 17 Dec 2024 11:42:53 +0200 Subject: [PATCH] Solve ANRs - play overlay music on another thread --- core/src/com/unciv/ui/audio/MusicController.kt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/src/com/unciv/ui/audio/MusicController.kt b/core/src/com/unciv/ui/audio/MusicController.kt index a3aa7afdd0..62d130e9d4 100644 --- a/core/src/com/unciv/ui/audio/MusicController.kt +++ b/core/src/com/unciv/ui/audio/MusicController.kt @@ -630,8 +630,10 @@ class MusicController { isLooping: Boolean = false, fadeIn: Boolean = false ) { - val file = getMatchingFiles(folder, name).firstOrNull() ?: return - playOverlay(file, volume, isLooping, fadeIn) + Concurrency.run { // no reason for this to run on GL thread + val file = getMatchingFiles(folder, name).firstOrNull() ?: return@run + playOverlay(file, volume, isLooping, fadeIn) + } } /** Called for Leader Voices */