-
Notifications
You must be signed in to change notification settings - Fork 12
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
Voicing can be initialized twice in RawRichTextLink #1365
Comments
Actually, this seems somewhat backwards to me, and might be broken. It looks like we only want to call Voicing's initialize in the constructor, and NOT in the repeated "initialize" that can later happen multiple times. I'll look into a solution. |
Actually, I take that back. If Voicing is creating something that has an initialize method, that NOTES poolability, it should be friendly to pooling. Right now it is not lazily creating Properties, but it is doing a lot of work that breaks pooling. |
I don't think I understand what is going on. If something is in Voicing's initialize() uses none of its arguments, so it should... be a no-op. I don't see any cleanup. Voicing's initialize() seems to do the opposite of what pooling initialize is for. Instead of this._voicingCanSpeakProperty = new TinyProperty<boolean>( true ); pooling initialization would do lazy construction: this._voicingCanSpeakProperty = this._voicingCanSpeakProperty || new TinyProperty<boolean>( true ); So... currently when intialize is called a second time on a RichTextLink, it is recreating Properties, and leaking memory. |
Looks like we aren't leaking in this specific case, because Voicing provides... a clean(), which is implementing RichTextCleanable? So that does pair things up with initialize/clean cycles, so it looks like we aren't explicitly leaking directly. Maybe I'm confused that Voicing is set up to API-match with RichTextCleanable, and that it is not reusing things in initialize() - why is that? @jessegreenberg and @zepumph, perhaps we can schedule a call on this? |
The issue is this: scenery/js/util/rich-text/RichTextLink.ts Lines 20 to 24 in 45ea411
Because of this: scenery/js/accessibility/voicing/Voicing.ts Line 245 in e8bf225
So initialize() is called twice, once in a super() that is meant to basically be a no-op for |
Discovered with @zepumph - Voicing is mixed into RawRichTextLink. Its constructor looks like
Voicing is then initialized in the first super call, and then also in the initialize, which follows up with a
super.initialize()
. We fixed this by conditionally calling thesuper.initialize
in RawRichTextLink.initialize. See the following commit. We weren't sure about this as a long term solution, @jonathanolson would you recommend anything different here?The text was updated successfully, but these errors were encountered: