{"action":"created","issue":{"url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1669","labels_url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1669/labels{/name}","comments_url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1669/comments","events_url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1669/events","html_url":"https://github.com/GoodBoyDigital/pixi.js/issues/1669","id":68942584,"number":1669,"title":"Feature proposal : cached texts","user":{"login":"JiDW","id":581736,"avatar_url":"https://avatars.githubusercontent.com/u/581736?v=3","gravatar_id":"","url":"https://api.github.com/users/JiDW","html_url":"https://github.com/JiDW","followers_url":"https://api.github.com/users/JiDW/followers","following_url":"https://api.github.com/users/JiDW/following{/other_user}","gists_url":"https://api.github.com/users/JiDW/gists{/gist_id}","starred_url":"https://api.github.com/users/JiDW/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JiDW/subscriptions","organizations_url":"https://api.github.com/users/JiDW/orgs","repos_url":"https://api.github.com/users/JiDW/repos","events_url":"https://api.github.com/users/JiDW/events{/privacy}","received_events_url":"https://api.github.com/users/JiDW/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-16T14:59:49Z","updated_at":"2015-04-18T18:29:45Z","closed_at":null,"body":"Hello,\r\n\r\nThis is something we did for our game and I wonder if it should stay a home-made feature, a plugin, or if it could be merged into PIXI.\r\n\r\nPIXI.Text.updateText() is very slow because it needs to create a canvas and write something inside it in order to use the canvas as a base texture.\r\n\r\nBecause of this, it is not usable for an often modified text, like a score count for example. With PIXI, you can use BitmapText to do that efficiently, but you are limited by the number of BitmapFont you have generated because you want to have a bitmapfont for every font size you need, to avoid pixelated texts.\r\n\r\nSo PIXI.Text is still very useful, but PIXI.Text.updateText() is so slow that it can makes the render of a complex game UI laggy on smartphones. For example, our game have multiple page : http://www.serenity-ff.com/images/screenshots/screenshot173214001.png\r\n\r\nWhen you click to go to another page, we recreate the sprites and texts. On some smartphones (ex: nexus 4) it is enough to get a 1200ms-1600ms freeze. When you want to animate the transition between your pages, it is not acceptable.\r\n\r\nThe idea is to not generate a new texture when you try to create twice the same text with the same style. What we did it is to create every PIXI.Text base textures with a _pixiId generated from the text and the style of the PIXI.Text object.\r\n\r\nWe had to deal with setText and setStyle on an existing object but it was not a big deal.\r\n\r\nThis feature allowed us to preload the texts at the start of the game, making the creation of a PIXI.Text as fast as a PIXI.Sprite, while still being able to use setText, setStyle and other PIXI.Text related methods.\r\n\r\nIt even improve the performances of creating texts not directly related to each others but already displayed somewhere else in the game with the same style.\r\n\r\nAnother use case is when you have a menu with mouseover interactivity, like changing the fill color of the text. Once the two states (inactive/over) are generated and in the cache, the mouseover effect will be very fast. (You can of course preload the two styles)\r\n\r\nThe only drawback we didn't manage yet but can be done easily is to prevent this behavior from happening if you want to use PIXI.Text for a often modified text, even if it is not a good thing performance-wise, like a score because it will keep in memory every generated texture if you do not destroy them manually. We plan to add a parameter to make this behavior optional.\r\n\r\nWhat do you think of this feature ?\r\nAt this moment the code is not clean, meaning is has references to our game, but we are wondering if it could be interesting to share and if yes, how ?\r\nShould it be a plugin overloading PIXI.Text ? Should it be a pull request into the core component of PIXI.Text ?\r\n\r\nRegards."},"comment":{"url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/comments/94189870","html_url":"https://github.com/GoodBoyDigital/pixi.js/issues/1669#issuecomment-94189870","issue_url":"https://api.github.com/repos/GoodBoyDigital/pixi.js/issues/1669","id":94189870,"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-04-18T18:29:45Z","updated_at":"2015-04-18T18:29:45Z","body":"This sounds like "}}