It's complicated. I'll try and run down the basics of how this all works.
When a VN Scene is loaded, the script does go through the whole file and looks for any actor animations that could be called. It will load them, then unload them right after so we're sort of caching the file. Sort of
. A cold file load on an APNG for JAD is pretty noticable, it would cause a very noticeable spike of lag. Maybe 0.25 - 0.5 s? I never timed it, but its pretty lame. But by having the files loaded and unloaded, enough stuff is cached that the file can load again almost right away. So this is always done at VN start so you think its just part of the script loading.
Now, we've got the file loaded, but that doesn't necessarily mean you're out of the woods. All the APNGs are streamed in. This is so I don't have to load... well there's like 2GB of just APNGs in JAD. Obviously not everything would be used in one scene, but I think to draw it on the screen it needs to be decompressed to essentially a raw bitmap (think .bmp plus alpha!) and all of this needs to get thrown from your hard disk and into RAM. So it's going to steal all that RAM and take forever. This is all on top of already loaded assets inside FreeSpace as well!
Anyway, back to streaming. The APNGs are streamed in (eternal thanks to niffiwan for that), and how that works is each frame gets loaded as needed, then thrown away once I need another animation. So the first run through takes a little bit of time to actually get loaded up. So if an APNG has 90 frames, we're basically dividing up the load into 90 smaller bits in semi-real time, which is more seamless than loading all 90 together while waiting for a full second or something. And then the next time it loops, the animation is already in memory and is painlessly simple to play over again. I did my best to try and stagger animations so that initial load would just be done on one animation at a time. But sometimes I can't because the scene needs 4 people to be there at the start...
Things could be improved if the dark art of multi-threading was attainable, or perhaps some sort of movie codec with a reliable transparency feature. But I think for a silly mod like JAD, the system is as good as it needs to be. Maybe I can revisit when I go commercial.
Oh and by the way, if you are wondering "gee, if it was like that before, how did you improve performance?" Wings of Dawn is using the VN script too, and Spoon wanted a way to have characters have a frame around them, so I added that feature to the VN script. Problem is, if there is no base, the script still tries to load one. And if it doesn't see one, it will keep trying to find and load it every. single. frame.
That's a bit of a slowdown. So added some instructions to tell the script "don't bother looking if there is no base".
So I made things worse by accident, and I'm hoping they are better now.