Is there an existing issue for this?
Current Behavior
On a simple MusicXML viewer screen with alphaTab, a single tap on the score sometimes causes a fatal crash:
java.lang.NullPointerException
at alphaTab.AlphaTabApiBase._internalCursorUpdateBeat(AlphaTabApiBase.kt:1192)
at alphaTab.AlphaTabApiBase._cursorUpdateBeat$lambda$0(AlphaTabApiBase.kt:1119)
at alphaTab.AlphaTabApiBase$$ExternalSyntheticLambda0.invoke(D8$$SyntheticClass:0)
at alphaTab.platform.android.AndroidUiFacade.beginInvoke$lambda$0(AndroidUiFacade.kt:348)
at alphaTab.platform.android.AndroidUiFacade$$ExternalSyntheticLambda5.run(D8$$SyntheticClass:0)
at android.os.Handler.handleCallback(Handler.java:942)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loopOnce(Looper.java:226)
at android.os.Looper.loop(Looper.java:313)
at android.app.ActivityThread.main(ActivityThread.java:8810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)
In my build line AlphaTabApiBase.kt:1192 corresponds to alphaTab/packages/alphatab/src/AlphaTabApiBase.ts:2421:
const relativePosition = this._previousTick - this._currentBeat!.start;
From logs and behavior it looks like the code is invoked asynchronously while so _currentBeat becomes null sometimes.
Expected Behavior
alphaTab should not crash when the user taps on the score, even if cursors are being created/destroyed, player state changes, or resize events are happening in parallel.
Steps To Reproduce
- Create a simple Android app screen that hosts alphaTab
- Enable user interaction and cursor in settings, similar to:
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 tap on the notation area a few times
- On some taps, the app crashes with NullPointerException in
AlphaTabApiBase._internalCursorUpdateBeat
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?
Possible Fix
In my fork I implemented an fix by adding the guard from null pointer exeption. After that the crash disappeared in my app.
My fork commit for reference: AndreiGorelov@e5d3131
Is there an existing issue for this?
Current Behavior
On a simple MusicXML viewer screen with alphaTab, a single tap on the score sometimes causes a fatal crash:
In my build line
AlphaTabApiBase.kt:1192corresponds toalphaTab/packages/alphatab/src/AlphaTabApiBase.ts:2421:From logs and behavior it looks like the code is invoked asynchronously while so
_currentBeatbecomes null sometimes.Expected Behavior
alphaTab should not crash when the user taps on the score, even if cursors are being created/destroyed, player state changes, or resize events are happening in parallel.
Steps To Reproduce
AlphaTabApiBase._internalCursorUpdateBeatLink to jsFiddle, CodePen, Project
No response
Version and Environment
Platform
Android (Native)
Anything else?
Possible Fix
In my fork I implemented an fix by adding the guard from null pointer exeption. After that the crash disappeared in my app.
My fork commit for reference: AndreiGorelov@e5d3131