Hey there!
I'm developing an electron app, which will load shit tons of SVG files and play them as animations. The process of decoding SVG -> PIXI.Texture is pretty fast, however, with 1000 SVGs it takes some time to process... which makes sense.
What I'd like to do is to keep the decoding outside of main thread, so user can interact with the system while images are loaded.
Since I'm using electron my first attempt was to spawn/fork a sub process and it failed dramatically, because only JSON-encoded data can be exchanged between them. Bummer.
Another option is to use electron's protocol to communicate between browser windows (IPC), which doesn't work too, since for some reason IPC can exchange even binary data, but when it comes to built-in stuff like `new Image` it fails to do so. While, theoretically, I could encode images in something else and transfer them I understand that most likely I'll lose more on added overhead... and well, I'm trying to decode less on main thread, not add something more to do so.
By searching through this forum I found few threads which discuss possibility of using service workers and, specifically, `createImageBitmap`. Since I'm using electron I can use both, and, luckily, it even supports SVG decoding! A very nice example: https://svg-zoom-demo.glitch.me/
However... I'm not quite sure what am I doing. In my perfect world, I'd use a "loading stub" as a texture for AnimatedSprite, and then, after my promise resolves, swap textures by simply changing them `animatedSprite.textures = newTextures`.
How deep can I go there? Is it possible to prepare Pixi's `Texture` to do that off the main thread? Or if I rasterize SVGs with `createImageBitmap` (and scale it accordingly altogether) I will have a huge boost already? But if I do so, will it result in X2 VRAM usage (rasterized image + a new one created by PIXI)? The latter question may sound silly, but I'm concerned about VRAM since I load a lot of images into VRAM and have no ability to check its usage...
Maybe somebody has some thoughts? Help is highly appreciated!