Repository navigation
Conversation
lizschwab
left a comment
There was a problem hiding this comment.
Just a couple of questions. I don't think either is enough to hold back an approval, but take a look.
| Tooltip.unbindMouseEvents(clickTarget); | ||
| delete (clickTarget as any).tooltip; | ||
| } | ||
| this.tooltip = null; |
There was a problem hiding this comment.
Is there a reason this sets the tooltip to null but the others set it to an empty string?
There was a problem hiding this comment.
Yes, the tooltip field is nullable here, but not on the others. Either way will prevent cycles or leaks – I'd prefer to null it out everywhere, but don't want to change the API.
| dom.removeNode(this.svgRoot); | ||
| if (this.svgRoot) { | ||
| tooltip.unbindMouseEvents(this.svgRoot); | ||
| delete (this.svgRoot as any).tooltip; |
There was a problem hiding this comment.
For all of these delete (foo as any).tooltip, is it possible to throw? Would they ever be undefined?
There was a problem hiding this comment.
Icon and Field, which can be headless, both check for non-nullness of the thing on which .tooltip lives. BlockSvg doesn't, but it also will always have an SVG path. The delete keyword is documented as being a no-op if the property being deleted doesn't exist, so this should all be safe.
The basics
The details
Proposed Changes
This PR fixes some memory leaks. These were largely related to (a) not unregistering tooltip listeners or clearing the
.tooltipproperty on DOM elements, which various Blockly-related classes were stuffed into, sometimes creating cycles and (b) missing clearing an element in the block flyout inflater.Reason for Changes
RAM is expensive, and cleaning up your own mess is nice.