Is there an existing issue for this?
Current Behavior
When I try to use AlphaTab in Unity3D var api = new AlphaTabApiBase<Settings>(facade, settings); api, I'm getting
Error: Collection was modified; enumeration operation may not execute.
This edge case appears when using Mono framework that Unity3D is using.
I created C# Project (Ported it from my Unity3D project and vibe coded it to simplify it) but my code is not really important as it's in code where AlphaTab is handling beaming.
The error was introduced in one of the early 1.8 versions, the 1.8.0-alpha.1640 was latest working.
I tracked the error to:
|
this.drawingInfos.clear(); |
Confirmed the pattern with custom snippet, which basically modifies the dictionary while we are looping over it. (That's what mono doesn't like)
var dict = new Dictionary<int, int> { {1,1}, {2,2}, {3,3} };
foreach (var v in dict.Values)
{
dict[v + 10] = v; // modify during iteration
Debug.Log(v);
}
Expected Behavior
When using Mono framework (Basically in Unity3D) and calling api.Load(score); I expect it to not throw error and in debugger print
Render complete
[DBG] Rendering: Rendering finished
Confirming it didnt fail
Steps To Reproduce
Reproducing from scratch:
- Use any version after
1.8.0-alpha.1640 (Error introduced between 1.7 -> 1.8)
- Use Mono Framework
.csproj (<TargetFramework>net481</TargetFramework>)
- Install any version of AlphaTab after
1.8.0-alpha.1640 (The 1.8.0-alpha.1640 is the latest working with mono)
- Load Score from file and then load it using api
api.Load(score);
Error: Collection was modified; enumeration operation may not execute. will appear.
Reproducing in my example project:
- Clone my project https://github.com/dawidprosba/issue-alpha-tab-error/ and initialize it.
- You need to have mono installed I'm on mac so I ran
brew install mono (https://formulae.brew.sh/formula/mono)
- Run
mono-with-error-latest-version (Error path)
- You should see
Error: Collection was modified; enumeration operation may not execute. among other logs. (Error will be at the bottom`
- Run
mono-without-error-version-when-it-was-working (Happy path)
- You should see
Render Complete and [DBG] Rendering: Rendering Finished
- Run
net90-no-error (Happy path)
- You should see
Render Complete and [DBG] Rendering: Rendering Finished
Link to jsFiddle, CodePen, Project
https://github.com/dawidprosba/issue-alpha-tab-error
Version and Environment
[DBG] VersionInfo: alphaTab 1.9.0-alpha.1813
[DBG] VersionInfo: commit: b6031affe32bc709f352b9f7ee70e51b983a4b4c
[DBG] VersionInfo: build date: 2026-05-25T04:46:13.698Z
[DBG] VersionInfo: High DPI: 1
[DBG] VersionInfo: .net Runtime: Mono 6.14.1 (tarball Tue Apr 29 17:43:02 UTC 2025)
[DBG] VersionInfo: Process: Arm64
[DBG] VersionInfo: OS Description: Unix 25.5.0.0
[DBG] VersionInfo: OS Arch: Arm64
[DBG] VersionInfo: alphaTab 1.9.0-alpha.1813
[DBG] VersionInfo: commit: b6031affe32bc709f352b9f7ee70e51b983a4b4c
[DBG] VersionInfo: build date: 2026-05-25T04:46:13.698Z
[DBG] VersionInfo: High DPI: 1
[DBG] VersionInfo: .net Runtime: Mono 6.14.1 (tarball Tue Apr 29 17:43:02 UTC 2025)
[DBG] VersionInfo: Process: Arm64
[DBG] VersionInfo: OS Description: Unix 25.5.0.0
[DBG] VersionInfo: OS Arch: Arm64
[DBG] ScoreLoader: Loading score from 1282 bytes using 6 importers
[DBG] ScoreLoader: Importing using importer Guitar Pro 3-5
[DBG] ScoreLoader: Guitar Pro 3-5 does not support the file
[DBG] ScoreLoader: Importing using importer Guitar Pro 6
[DBG] Guitar Pro 6: Loading GPX filesystem
[DBG] ScoreLoader: Guitar Pro 6 does not support the file
[DBG] ScoreLoader: Importing using importer Guitar Pro 7-8
[DBG] Guitar Pro 7-8: Loading ZIP entries
[DBG] Guitar Pro 7-8: Zip entries loaded
[DBG] ScoreLoader: Guitar Pro 7-8 does not support the file
[DBG] ScoreLoader: Importing using importer MusicXML
[DBG] ScoreLoader: Score imported using MusicXML
[DBG] AlphaTab: Generating Midi
[DBG] Midi: Begin midi generation
[DBG] Midi: Midi generation done
[DBG] AlphaTab: Generating Midi
[DBG] Midi: Begin midi generation
[DBG] Midi: Midi generation done
[DBG] Rendering: Rendering 1 tracks
[DBG] Rendering: Track 0: Piano
[DBG] Rendering: Rendering at scale 1 with layout PageView
[DBG] ScoreLayout: Creating score info glyphs
[DBG] PageView: Layouting score info
[ERR] API: An unexpected error occurred
Error: Collection was modified; enumeration operation may not execute.
Platform
.net (Other)
Anything else?
No response
Is there an existing issue for this?
Current Behavior
When I try to use AlphaTab in Unity3D
var api = new AlphaTabApiBase<Settings>(facade, settings);api, I'm gettingThis edge case appears when using
Monoframework that Unity3D is using.I created C# Project (Ported it from my Unity3D project and vibe coded it to simplify it) but my code is not really important as it's in code where AlphaTab is handling beaming.
The error was introduced in one of the early 1.8 versions, the
1.8.0-alpha.1640was latest working.I tracked the error to:
alphaTab/packages/alphatab/src/rendering/utils/BeamingHelper.ts
Line 113 in 9f53dc5
Confirmed the pattern with custom snippet, which basically modifies the dictionary while we are looping over it. (That's what mono doesn't like)
Expected Behavior
When using Mono framework (Basically in Unity3D) and calling
api.Load(score);I expect it to not throw error and in debugger printConfirming it didnt fail
Steps To Reproduce
Reproducing from scratch:
1.8.0-alpha.1640(Error introduced between 1.7 -> 1.8).csproj(<TargetFramework>net481</TargetFramework>)1.8.0-alpha.1640(The1.8.0-alpha.1640is the latest working with mono)api.Load(score);Error: Collection was modified; enumeration operation may not execute.will appear.Reproducing in my example project:
brew install mono(https://formulae.brew.sh/formula/mono)mono-with-error-latest-version(Error path)Error: Collection was modified; enumeration operation may not execute.among other logs. (Error will be at the bottom`mono-without-error-version-when-it-was-working(Happy path)Render Completeand[DBG] Rendering: Rendering Finishednet90-no-error(Happy path)Render Completeand[DBG] Rendering: Rendering FinishedLink to jsFiddle, CodePen, Project
https://github.com/dawidprosba/issue-alpha-tab-error
Version and Environment
Platform
.net (Other)
Anything else?
No response