Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues
I have read the contribution rules
- I have read CONTRIBUTING.md and, if any AI agent helped draft this issue, AGENTS.md.
AI authorship
AI-assisted (disclosure block included as described in AGENTS.md)
Current Behavior
Note
AI-authored disclosure (alphatab-ai-authored-v1)
Portions of this content were authored by an AI agent. The agent has read
AGENTS.md and the human submitter accepts responsibility for
compliance with the rules in that document.
A playback range highlight set with highlightPlaybackRange(), then cleared with api.playbackRange = null and api.clearPlaybackRangeHighlight(), disappears from the score, but:
- The next render draws it again. In the repro below, a scale change followed by
api.render()shows the highlight block again whileapi.playbackRangestaysnull. - Loading another score afterwards (
api.tex()in the repro) throws once the new score has rendered, andpostRenderFinishedis not raised for that score:
Uncaught TypeError: Cannot read properties of undefined (reading 'realBounds')
at _cursorSelectRange (alphaTab.js:52915:30)
at _refreshSelectionHighlight (alphaTab.js:52680:9)
at _onPostRenderFinished (alphaTab.js:53198:9)
at (alphaTab.js:50475:10)
at trigger (alphaTab.js:26472:37)
at (alphaTab.js:49568:82)
at trigger (alphaTab.js:26472:37)
at _handleWorkerMessage (alphaTab.js:39975:30)
In our app, a user who removes a loop and then zooms sees the old loop shading come back on the score, and opening another song afterwards throws.
Expected Behavior
Once cleared, the highlight stays gone until a new range is selected or highlighted, whatever renders in between, and loading another score does not throw.
Steps To Reproduce
- Save the page below as
repro.htmland open it in a browser. It loads alphaTab 1.9.0 from jsDelivr and renders two small alphaTex scores, no file needed. - In the console, run
await runRepro(). - The returned
logshows:- 1 highlight block after
highlightPlaybackRange()over bars 1 to 3; - 0 after
playbackRange = nullandclearPlaybackRangeHighlight(); - 1 again after the re-render, with
playbackRangestillnull; postRenderFinished raised: falseafter loading the second score.
- 1 highlight block after
- The console shows the TypeError above when the second score renders. (Inside the page it only reads « Script error. », because the script comes from another origin.)
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>alphaTab: cleared range highlight repro</title>
<style>.at-selection div { background: rgba(64, 64, 255, .2); }</style>
</head>
<body>
<p>Open the console and run <code>await runRepro()</code>.</p>
<div id="at"></div>
<script src="https://cdn.jsdelivr.net/npm/@coderline/alphatab@1.9.0/dist/alphaTab.js"></script>
<script>
const CDN = 'https://cdn.jsdelivr.net/npm/@coderline/alphatab@1.9.0/dist/'
const SONG_A = '\\title "A" . :4 3.3 3.3 3.3 3.3 | 5.3 5.3 5.3 5.3 | 0.2 0.2 0.2 0.2 | 3.2 3.2 3.2 3.2'
const SONG_B = '\\title "B" . :4 0.1 0.1 0.1 0.1 | 1.1 1.1 1.1 1.1'
const api = new alphaTab.AlphaTabApi(document.getElementById('at'), {
core: { fontDirectory: `${CDN}font/` },
player: { playerMode: alphaTab.PlayerMode.EnabledSynthesizer, soundFont: `${CDN}soundfont/sonivox.sf2`, enablePlaybackRangeSelection: true }
})
const log = []
window.addEventListener('error', (e) => log.push(`uncaught error: ${e.message}`))
// Resolves on the next postRenderFinished, or reports that it never came.
const nextRender = (ms = 3000) => new Promise((resolve) => {
const done = () => {
clearTimeout(timer)
api.postRenderFinished.off(done)
setTimeout(() => resolve(true), 50)
}
const timer = setTimeout(() => {
api.postRenderFinished.off(done)
resolve(false)
}, ms)
api.postRenderFinished.on(done)
})
const highlightBlocks = () => document.querySelectorAll('.at-selection > *').length
// printEnvironmentInfo() writes to console.debug: capture it so it comes back with the results.
function environment() {
const lines = []
const debug = console.debug
console.debug = (...args) => lines.push(args.map(String).join(' '))
try {
alphaTab.Environment.printEnvironmentInfo()
} finally {
console.debug = debug
}
return lines
}
window.runRepro = async () => {
api.tex(SONG_A)
await nextRender()
const bars = api.score.tracks[0].staves[0].bars
api.highlightPlaybackRange(bars[0].voices[0].beats[0], bars[2].voices[0].beats[3])
api.applyPlaybackRangeFromHighlight()
log.push(`1. highlightPlaybackRange() over bars 1 to 3: ${highlightBlocks()} highlight block(s), playbackRange set: ${!!api.playbackRange}`)
api.playbackRange = null
api.clearPlaybackRangeHighlight()
log.push(`2. after playbackRange = null and clearPlaybackRangeHighlight(): ${highlightBlocks()} highlight block(s)`)
api.settings.display.scale = 1.2
api.updateSettings()
api.render()
await nextRender()
log.push(`3. after a re-render (scale 1.2): ${highlightBlocks()} highlight block(s), playbackRange set: ${!!api.playbackRange}`)
api.tex(SONG_B)
const rendered = await nextRender()
log.push(`4. after loading another score: postRenderFinished raised: ${rendered}`)
return { log, environment: environment() }
}
</script>
</body>
</html>Link to jsFiddle, CodePen, Project
No response
Version and Environment
[AlphaTab][VersionInfo] alphaTab 1.9.0"
[AlphaTab][VersionInfo] commit: 9f1aa10460df1b326123d28a2222f7b20d081e61"
[AlphaTab][VersionInfo] build date: 2026-10-31T21:16:42.187Z"
[AlphaTab][VersionInfo] High DPI: 1"
[AlphaTab][VersionInfo] Platform: Browser"
[AlphaTab][VersionInfo] WebPack: false"
[AlphaTab][VersionInfo] Vite: false"
[AlphaTab][VersionInfo] Turbopack: false"
[AlphaTab][VersionInfo] Browser: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:160.0) Gecko/20100101 Firefox/160.0"
[AlphaTab][VersionInfo] Window Size: 1920x1048"
[AlphaTab][VersionInfo] Screen Size: 1920x1080"Platform
Web
Anything else?
No response
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Effort
Area
Platform
Work State
Activity