{"action":"created","issue":{"url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1968","labels_url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1968/labels{/name}","comments_url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1968/comments","events_url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1968/events","html_url":"https://github.com/GoodBoyDigital/pixi.js/issues/1968","id":94140849,"number":1968,"title":"Destroyed WebGLRenderer still listens to dispose events of base textures","user":{"login":"aschampion","id":460206,"avatar_url":"https://avatars.githubusercontent.com/u/460206?v=3","gravatar_id":"","url":"https://api.github.com/users/aschampion","html_url":"https://github.com/aschampion","followers_url":"https://api.github.com/users/aschampion/followers","following_url":"https://api.github.com/users/aschampion/following{/other_user}","gists_url":"https://api.github.com/users/aschampion/gists{/gist_id}","starred_url":"https://api.github.com/users/aschampion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschampion/subscriptions","organizations_url":"https://api.github.com/users/aschampion/orgs","repos_url":"https://api.github.com/users/aschampion/repos","events_url":"https://api.github.com/users/aschampion/events{/privacy}","received_events_url":"https://api.github.com/users/aschampion/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-09T20:06:28Z","updated_at":"2015-07-09T21:27:14Z","closed_at":null,"body":"Currently, multiple renderers/contexts may make use of the same `BaseTexture` because they each manage their own GL textures in `updateTexture`. However, if a renderer is destroyed it does not unregister its listeners to textures' `dispose` events. If the texture is later destroyed because it is no longer needed, the listener for the destroyed renderer is called, which excepts [here](https://github.com/GoodBoyDigital/pixi.js/blob/master/src/core/renderers/webgl/WebGLRenderer.js#L426) because `this.gl` is null in the destroyed renderer.\r\n\r\n[Contrived JSFiddle with v3.0.7, which excepts](http://jsfiddle.net/jckw77qd/). A fixed version would not throw and the canvas would be blank rather than show the bunny.\r\n\r\nThis can occur even with one renderer, if the code managing texture destruction outside of Pixi destroys a texture after a renderer has been destroyed. The single renderer case could reasonably be viewed as not Pixi's responsibility, though.\r\n\r\nEither the renderer should unregister its texture listeners, or `destroyTexture` should check that the renderer has a context (i.e., `gl` is not null). The former's advantage is it also allows the renderer to be GC'd, but would require the destroyed renderer checking every texture in the base texture cache for its context in `_glTextures`, even textures it has never used. The latter is easy but does not help clean up references in listeners that may keep the destroyed renderer from being GC'd."},"comment":{"url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/comments/120148851","html_url":"https://github.com/GoodBoyDigital/pixi.js/issues/1968#issuecomment-120148851","issue_url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1968","id":120148851,"user":{"login":"englercj","id":944497,"avatar_url":"https://avatars.githubusercontent.com/u/944497?v=3","gravatar_id":"","url":"https://api.github.com/users/englercj","html_url":"https://github.com/englercj","followers_url":"https://api.github.com/users/englercj/followers","following_url":"https://api.github.com/users/englercj/following{/other_user}","gists_url":"https://api.github.com/users/englercj/gists{/gist_id}","starred_url":"https://api.github.com/users/englercj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/englercj/subscriptions","organizations_url":"https://api.github.com/users/englercj/orgs","repos_url":"https://api.github.com/users/englercj/repos","events_url":"https://api.github.com/users/englercj/events{/privacy}","received_events_url":"https://api.github.com/users/englercj/received_events","type":"User","site_admin":false},"created_at":"2015-07-09T21:27:14Z","updated_at":"2015-07-09T21:27:14Z","body":"Good catch! Will have to think about the best way to clean this up."}}