Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Summer.removeInput() throws ArrayOutOfBoundsException #25

Closed
dmitrc opened this issue May 2, 2014 · 4 comments
Closed

Summer.removeInput() throws ArrayOutOfBoundsException #25

dmitrc opened this issue May 2, 2014 · 4 comments
Milestone

Comments

@dmitrc
Copy link

dmitrc commented May 2, 2014

We have a single-threaded Processing sketch, where we are dealing with a lot of simultaneous playbacks, number of which is capped to an integer variable. After the queue is overfilled, ugens are being unpatched and sound removed from the queue.

However, sometimes (still mysterious), when trying to run pan.unpatch(out);, ArrayOutOfBoundsException is thrown by AudioOutput's Summer object. It tries to access one position beyond the end of an array (that we assume could've changed WHILE the loop was running).

We looked through our code and couldn't pinpoint the source of the problem (ArrayList that's throwing exception belongs to AudioOutput.Summer) - we don't even use ArrayLists. Thus, I am not really sure whether it's a bug or just us overloading Minim, we thought you'd like to know this anyway.

As a suggestion: maybe make Summer's m_ugens array synchronized or save the array's size explicitly, such that no modifications to it are allowed in such way (during unpatching).

Stack trace:

java.lang.RuntimeException: java.lang.IndexOutOfBoundsException: Index: 11, Size: 11
< ... >
Caused by: java.lang.IndexOutOfBoundsException: Index: 11, Size: 11
    at java.util.ArrayList.rangeCheck(ArrayList.java:635)
    at java.util.ArrayList.get(ArrayList.java:411) <- ArrayList = Summer.m_ugens
    at ddf.minim.ugens.Summer.removeInput(Unknown Source) <- (!!!)
    at ddf.minim.UGen.unpatch(Unknown Source)
    at ddf.minim.UGen.unpatch(Unknown Source)
    at main$Sonify$Chain.dispose(main.java:662)
    at main$Sonify.updateSamples(main.java:779)
    at main$Sonify.play(main.java:794)
    at main.draw(main.java:217)

Our code is available here:
http://github.com/dmitryfd/Zond

The problematic part is in Sonify.pde:44 (we put try/catch around it).

Thanks a lot!

@ddf
Copy link
Owner

ddf commented May 2, 2014

Thanks for the excellent report, will try to look into it soon.

@ddf
Copy link
Owner

ddf commented May 6, 2014

Hi, I added synchronization on the ugens list inside Summer and I think this will fix the error you are seeing. Would you be so kind as to grab the lastest minim.jar from here and replace the version you are running against in your Processing setup:

https://github.com/ddf/Minim/tree/master/library

@dmitrc
Copy link
Author

dmitrc commented May 7, 2014

Thanks a lot! I will give a try :)

That error was kind of mysterious and not quite trivial to reproduce.
Should it ever pop up again, however, I will let you know here.

@ddf
Copy link
Owner

ddf commented Jan 3, 2015

Have you seen this crop up again?

@ddf ddf added the Review label Jan 4, 2015
@ddf ddf added this to the 2.2.1 milestone Jan 5, 2015
@ddf ddf closed this as completed Aug 24, 2015
@ddf ddf removed the Review label Aug 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants