Closed jbphet closed 1 year ago
Assigning to @zepumph to see if he has any input or insights before I move forward with this. Also labeling it as high priority, since it would be good to work this out before finalizing the disposal behavior for the Greenhouse Effect code review (see https://github.com/phetsims/greenhouse-effect/issues/336).
Oh bummer - according to the calendar, @zepumph is out for the next week.
I'm a bit uncomfortable doing this without talking with some other devs first, since it is in widely used common code, so I think I'll not change SoundGenerator
at this time and will add assertions in the sound generators that currently exist in Greenhouse Effect, and @zepumph can discuss when he gets back.
Disposable is pretty light weight and seems like a great supertype for this case. Happy to talk more next week. Good luck.
I poked around SoundGenerator a bit more and it seems excellent for Disposable. You should be able to remove the disposeSoundGenerator
function and just use the disposeEmitter
.
This is done. I regression tested on the tambo demo, greenhouse-effect, john-travoltage, and a handful of other sims that have sound. I'll also keep an eye out for CT failures that could potentially be related. Closing.
Under https://github.com/phetsims/scenery/issues/1494 a type was created to standardize how we do and don't support disposing of object instances in order to release memory references and prevent leaks. The type (or class) is called
Disposable
, and the main type of Scenery -Node
- extends this type by virtue of extendingPhetioObject
. I'm thinking that I should probably makeSoundGenerator
extend this type also, since it's meant to (sort of) be the audio version ofNode
.