-
Notifications
You must be signed in to change notification settings - Fork 248
Android: InterruptedException in AndroidAudioWorker.writeSamples() #2629
Copy link
Copy link
Open
Labels
state-needs-triageBug not triaged yet.Bug not triaged yet.
Description
Is there an existing issue for this?
- I have searched the existing issues
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
- 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
InterruptedExceptioninAndroidAudioWorker.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 phonePlatform
Android (Native)
Anything else?
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
state-needs-triageBug not triaged yet.Bug not triaged yet.