Is there an existing issue for this?
Current Behavior
AndroidAudioWorker.close() sometimes throws unhandled InterruptedException when the _writeThread is interrupted during Semaphore.acquire() in the writeSamples() loop:
java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1048)
at java.util.concurrent.Semaphore.acquire(Semaphore.java:318)
at alphaTab.platform.android.AndroidAudioWorker.writeSamples(AndroidAudioWorker.kt:67)
at alphaTab.platform.android.AndroidAudioWorker._init_$lambda$0(AndroidAudioWorker.kt:47)
at alphaTab.platform.android.AndroidAudioWorker$$ExternalSyntheticLambda1.run(D8$$SyntheticClass:0)
The problem started to appear after applying my version of the fix for issue #2621, but in my opinion the root cause is a bug in the alphaTab code — it just became exposed after applying the fix.
Expected Behavior
AndroidAudioWorker.close should cleanly terminate the _writeThread without throwing unhandled exceptions. InterruptedException from Semaphore.acquire() should be caught and handled to ensure proper cleanup.
Steps To Reproduce
- Apply fix AndreiGorelov@50a701a
- Create a simple Android app screen that hosts alphaTab
- Enable user interaction and cursor in settings, for example:
val settings = alphaTab.Settings().apply {
player.playerMode = PlayerMode.EnabledAutomatic
player.enableCursor = true
player.enableAnimatedBeatCursor = true
player.enableUserInteraction = true
player.scrollMode = ScrollMode.OffScreen
display.scale = 0.8
}
- Load a MusicXML score
- Start playback then close the activity (with call the AlphaTab destroy API)
- Sometimes the app crashes with
InterruptedException in AndroidAudioWorker.writeSamples. If it does not crash, repeat steps 3–5 a few times.
Link to jsFiddle, CodePen, Project
No response
Version and Environment
1. alphaTab version: 1.8.1
2. Platform: Android (Kotlin)
3. Devices: Android 14/16 tablet and phone
Platform
Android (Native)
Anything else?
No response
Is there an existing issue for this?
Current Behavior
AndroidAudioWorker.close()sometimes throws unhandledInterruptedExceptionwhen the_writeThreadis interrupted duringSemaphore.acquire()in thewriteSamples()loop:The problem started to appear after applying my version of the fix for issue #2621, but in my opinion the root cause is a bug in the alphaTab code — it just became exposed after applying the fix.
Expected Behavior
AndroidAudioWorker.closeshould cleanly terminate the_writeThreadwithout throwing unhandled exceptions.InterruptedExceptionfromSemaphore.acquire()should be caught and handled to ensure proper cleanup.Steps To Reproduce
InterruptedExceptioninAndroidAudioWorker.writeSamples. If it does not crash, repeat steps 3–5 a few times.Link to jsFiddle, CodePen, Project
No response
Version and Environment
Platform
Android (Native)
Anything else?
No response