Welcome to Inkbunny...
Allowed ratings
To view member-only content, create an account. ( Hide )
FallowWing

Initialization time problems

Paraphore Blog 9/27/16 - Initialization time problems

Short version: In Paraphore version 0.1.1 we're having some reports of users getting a black screen after pressing the play button. This has been fixed on both the live Inkbunny version of the game and the Patreon dev version of the game.

The issue is that I forgot about some of the first bits of code I wrote in the game, the passage parsing code, which even survived the the port to 0.1.0 mostly intact.

The error number being reported was #1502: A script has executed for longer than 15 seconds. Meaning I was doing something really really slow.

After pressing the play button, while the screen is white, each letter in each story file is processed; this is a total of 349,662 letters now. And they were being processed by an extremely inefficient string operation (citing line 72 specifically), simply changing this to an array based loop with unshift(citing line 60) instantly makes this twice as fast, this with other small caching changes, resolves the issue.

The although that by itself isn't that much faster of an operation, it's just much more memory optimal. The old method using substring() requires creating a new string for each character by repeatedly pulling the first character off like:
Hello
ello
llo
lo
o

And with over a quarter million characters this is extremely bad for memory, taking over 300mb of RAM at some points. This is temporary though and the memory is returned within one second, although it jostles memory around enough for you to feel it for a couple seconds afterwards if you don't have a lot of memory.

The real problem though is if you run out of memory, due to simply not having enough total, or having other applications using it. If so, Windows' default behaviour is to start to use random parts of the C drive called the pagefile. The drive is hundreds of times slower than RAM, so if this happens it's almost always going to take more than 15 seconds. This is no longer a problem, on any current version of the game with the simpler array loop. I've also raised the script timeout limit to 60 seconds in case such an issue gets away from me again. If you have an extremely low spec machine please let us know if the game has any other large problems like this, sometimes random parts of the code rot with out my notice and brutally punish random configurations.

Thank you everyone who left bug reports, you can play the current version on Inkbunny here. And Patreon supporters can play the debug version here.
Viewed: 19 times
Added: 7 years, 6 months ago
 
New Comment:
Move reply box to top
Log in or create an account to comment.