Closed KatieWoe closed 3 months ago
This error is still occurring occassionally (about once per day) as of 10/10/23.
The problem originates at this line in FreeBodyDiagram:
153 xDragForceLabel.visible = dragForceExists;
xDragForceLabel
has apparently been disposed, which in turn has disposed its default visibleProperty
, a TinyProperty. So trying to set xDragForceLabel.visible
fails this assertion in TinyEmitter (the superclass of TinyProperty):
98 public emit( ...args: T ): void {
99 assert && assert( !this.isDisposed, 'should not be called if disposed' );
xDragForceLabel
is a local const in FreeBodyDiagram's constructor, so it can only have been disposed by calling dispose
on the FreeBodyDiagram.
Here is how to reproduce this manually (only found after looking at the code)
?listenerOrder=random(906065)
viewPointListener
and the assertion mentioned above only happens when there is a change in value.(Image showing the last step before ball hits the ground. Toggle Air Resistance here).
This happens when the listeners on ProjectileNode.viewPointProperty are shuffled. One listener in ProjectileNode calls dispose and another updates visibility (the viewPointListener). If the dispose happens first this assertion will happen. It happens even though the dispose unlinks the viewPointListener because of this: https://github.com/phetsims/axon/blob/4f571cbc738bdcba5f9f49050c3f2a1eddde9110/js/TinyEmitter.ts#L195-L199.
Knowing that, it seems OK to me to only update visibility if not disposed. But Ill leave to @matthew-blackman to review in case you want to handle a different way!
The commit above looks good. Tested force diagram behavior and no issues. Nice work @jessegreenberg! CT is also looking good. Closing.