{"action":"created","issue":{"url":"https://api.github.com/repos/phetsims/sun/issues/270","repository_url":"https://api.github.com/repos/phetsims/sun","labels_url":"https://api.github.com/repos/phetsims/sun/issues/270/labels{/name}","comments_url":"https://api.github.com/repos/phetsims/sun/issues/270/comments","events_url":"https://api.github.com/repos/phetsims/sun/issues/270/events","html_url":"https://github.com/phetsims/sun/issues/270","id":178406865,"number":270,"title":"Make it possible to reuse FontAwesome shapes without introducing memory leaks","user":{"login":"samreid","id":679486,"avatar_url":"https://avatars.githubusercontent.com/u/679486?v=3","gravatar_id":"","url":"https://api.github.com/users/samreid","html_url":"https://github.com/samreid","followers_url":"https://api.github.com/users/samreid/followers","following_url":"https://api.github.com/users/samreid/following{/other_user}","gists_url":"https://api.github.com/users/samreid/gists{/gist_id}","starred_url":"https://api.github.com/users/samreid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samreid/subscriptions","organizations_url":"https://api.github.com/users/samreid/orgs","repos_url":"https://api.github.com/users/samreid/repos","events_url":"https://api.github.com/users/samreid/events{/privacy}","received_events_url":"https://api.github.com/users/samreid/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"jonathanolson","id":480878,"avatar_url":"https://avatars.githubusercontent.com/u/480878?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathanolson","html_url":"https://github.com/jonathanolson","followers_url":"https://api.github.com/users/jonathanolson/followers","following_url":"https://api.github.com/users/jonathanolson/following{/other_user}","gists_url":"https://api.github.com/users/jonathanolson/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathanolson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathanolson/subscriptions","organizations_url":"https://api.github.com/users/jonathanolson/orgs","repos_url":"https://api.github.com/users/jonathanolson/repos","events_url":"https://api.github.com/users/jonathanolson/events{/privacy}","received_events_url":"https://api.github.com/users/jonathanolson/received_events","type":"User","site_admin":false},"assignees":[{"login":"jonathanolson","id":480878,"avatar_url":"https://avatars.githubusercontent.com/u/480878?v=3","gravatar_id":"","url":"https://api.github.com/users/jonathanolson","html_url":"https://github.com/jonathanolson","followers_url":"https://api.github.com/users/jonathanolson/followers","following_url":"https://api.github.com/users/jonathanolson/following{/other_user}","gists_url":"https://api.github.com/users/jonathanolson/gists{/gist_id}","starred_url":"https://api.github.com/users/jonathanolson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonathanolson/subscriptions","organizations_url":"https://api.github.com/users/jonathanolson/orgs","repos_url":"https://api.github.com/users/jonathanolson/repos","events_url":"https://api.github.com/users/jonathanolson/events{/privacy}","received_events_url":"https://api.github.com/users/jonathanolson/received_events","type":"User","site_admin":false},{"login":"samreid","id":679486,"avatar_url":"https://avatars.githubusercontent.com/u/679486?v=3","gravatar_id":"","url":"https://api.github.com/users/samreid","html_url":"https://github.com/samreid","followers_url":"https://api.github.com/users/samreid/followers","following_url":"https://api.github.com/users/samreid/following{/other_user}","gists_url":"https://api.github.com/users/samreid/gists{/gist_id}","starred_url":"https://api.github.com/users/samreid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samreid/subscriptions","organizations_url":"https://api.github.com/users/samreid/orgs","repos_url":"https://api.github.com/users/samreid/repos","events_url":"https://api.github.com/users/samreid/events{/privacy}","received_events_url":"https://api.github.com/users/samreid/received_events","type":"User","site_admin":false},{"login":"pixelzoom","id":3046552,"avatar_url":"https://avatars.githubusercontent.com/u/3046552?v=3","gravatar_id":"","url":"https://api.github.com/users/pixelzoom","html_url":"https://github.com/pixelzoom","followers_url":"https://api.github.com/users/pixelzoom/followers","following_url":"https://api.github.com/users/pixelzoom/following{/other_user}","gists_url":"https://api.github.com/users/pixelzoom/gists{/gist_id}","starred_url":"https://api.github.com/users/pixelzoom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixelzoom/subscriptions","organizations_url":"https://api.github.com/users/pixelzoom/orgs","repos_url":"https://api.github.com/users/pixelzoom/repos","events_url":"https://api.github.com/users/pixelzoom/events{/privacy}","received_events_url":"https://api.github.com/users/pixelzoom/received_events","type":"User","site_admin":false}],"milestone":null,"comments":10,"created_at":"2016-09-21T17:05:16Z","updated_at":"2016-09-23T19:24:01Z","closed_at":null,"body":"From https://github.com/phetsims/joist/issues/329 we removed caching from FontAwesomeNode because it was causing a memory leak.  In https://github.com/phetsims/function-builder/issues/102 we identified that some sims, such as Function Builder spend a lot of time (like 1000ms) during startup parsing the same svg path over and over.\r\n\r\nThe memory leak was caused because Path assumes the Shape is dynamic, and adds listeners to it like so:\r\n```js\r\n        // Add Shape invalidation listener if applicable\r\n        if ( this._shape ) {\r\n          this._shape.onStatic( 'invalidated', this._invalidShapeListener );\r\n        }\r\n```\r\n\r\n@pixelzoom and I discussed it and would like to investigate adding a new Path option `{staticShape}` which indicates that no listeners would be attached to the Shape.  This would make it possible to reuse the shapes created by FontAwesomeNodes without inadvertently introducing memory leaks.\r\n\r\n@pixelzoom also recommends making the shape creation function public so that clients can manage how the shape is created (if a different strategy is necessary).\r\n\r\nIt would be great to hear from @jonathanolson whether this proposed strategy would work well, or if there are better recommendations.\r\n\r\nIt would also be nice to factor out FontAwesomeShape, but it is unclear how to do this because the shapes must be transformed and it is unclear whether it is possible to transform a shape in-place.  Another alternative would be to preprocess all of the Shapes, transform them and use getSVGPath so they don't have to be re-transformed each time the sim launches.  "},"comment":{"url":"https://api.github.com/repos/phetsims/sun/issues/comments/249280868","html_url":"https://github.com/phetsims/sun/issues/270#issuecomment-249280868","issue_url":"https://api.github.com/repos/phetsims/sun/issues/270","id":249280868,"user":{"login":"pixelzoom","id":3046552,"avatar_url":"https://avatars.githubusercontent.com/u/3046552?v=3","gravatar_id":"","url":"https://api.github.com/users/pixelzoom","html_url":"https://github.com/pixelzoom","followers_url":"https://api.github.com/users/pixelzoom/followers","following_url":"https://api.github.com/users/pixelzoom/following{/other_user}","gists_url":"https://api.github.com/users/pixelzoom/gists{/gist_id}","starred_url":"https://api.github.com/users/pixelzoom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixelzoom/subscriptions","organizations_url":"https://api.github.com/users/pixelzoom/orgs","repos_url":"https://api.github.com/users/pixelzoom/repos","events_url":"https://api.github.com/users/pixelzoom/events{/privacy}","received_events_url":"https://api.github.com/users/pixelzoom/received_events","type":"User","site_admin":false},"created_at":"2016-09-23T19:24:01Z","updated_at":"2016-09-23T19:24:01Z","body":"Currently in FontAwesomeNode we have:\r\n\r\n```js\r\nreturn new Shape( ICONS[ iconName ] ).transformed( SHAPE_MATRIX );\r\n```\r\n\r\nSo add `.done()` to the end, like this?\r\n\r\n```\r\nreturn new Shape( ICONS[ iconName ] ).transformed( SHAPE_MATRIX ).done();\r\n```"}}
{"actor":{"display_login":"pixelzoom"}}