Skip to content
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

Clearing the pixi texture cache breaks tagged-text #265

Open
wmike1987 opened this issue Jun 25, 2022 · 3 comments
Open

Clearing the pixi texture cache breaks tagged-text #265

wmike1987 opened this issue Jun 25, 2022 · 3 comments

Comments

@wmike1987
Copy link

Calling PIXI_UTILS.destroyTextureCache() seems to break tagged-text.

It's been difficult to troubleshoot in the browser, but it looks like when the tagged-text module is loaded, a texture gets created and cached, and this texture is very important. Since the module won't be reloaded until a page reload, there's no way to recover from having cleared this texture from the cache.

This is the stacktrace resulting from trying to create a new TaggedText object after having cleared the pixi texture cache

text.js:1626 Uncaught TypeError: Cannot set properties of null (setting 'width')
at push../node_modules/@pixi/text/dist/esm/text.js.Text.updateTexture (text.js:1626:1)
at push../node_modules/@pixi/text/dist/esm/text.js.Text.updateText (text.js:1549:1)
at P (pixi-tagged-text.m.js:1:4195)
at pixi-tagged-text.m.js:1:45114
at Array.map ()
at pixi-tagged-text.m.js:1:44777
at Array.flatMap ()
at pixi-tagged-text.m.js:1:46629
at Array.flatMap ()
at pixi-tagged-text.m.js:1:44214
push../node_modules/@pixi/text/dist/esm/text.js.Text.updateTexture @ text.js:1626
push../node_modules/@pixi/text/dist/esm/text.js.Text.updateText @ text.js:1549
P @ pixi-tagged-text.m.js:1
(anonymous) @ pixi-tagged-text.m.js:1
(anonymous) @ pixi-tagged-text.m.js:1
(anonymous) @ pixi-tagged-text.m.js:1
(anonymous) @ pixi-tagged-text.m.js:1
B.update @ pixi-tagged-text.m.js:1
B.updateIfShould @ pixi-tagged-text.m.js:1
B.setText @ pixi-tagged-text.m.js:1
set @ pixi-tagged-text.m.js:1
C @ pixi-tagged-text.m.js:1

@mimshwright
Copy link
Owner

mimshwright commented Jun 25, 2022 via email

@wmike1987
Copy link
Author

I'm on the latest version, thanks for checking.

I tried this in the tagged-text demo and was able to recreate it. In the index.html file, I added a line to the createPixiApp method:

        function createPixiApp(
          id,
          width = 600,
          height = 600,
          backgroundColor = 0x333333
        ) {
          PIXI.settings.RESOLUTION = 2;
          const app = new PIXI.Application({ width, height, backgroundColor });
          document.getElementById(id).appendChild(app.view);

          //*****added this line******
          PIXI.utils.destroyTextureCache();
          //*****************************

          return app;
        }

After this, the demo fails for the same reason I was seeing in my app.

@mimshwright
Copy link
Owner

mimshwright commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants