For the first time in its history and after years of redesigning large swathes of code, Gnash's core libraries are re-entrant!
Why is this interesting? Until we use it properly, it's not! But it allows Gnash to be used in more powerful and flexible ways.
So what is the excitement about? Re-entrancy here means the ability to use as many objects from Gnash's core library as you like without their interfering with each other, or even crashing.
When I started working on Gnash, it used static data for ActionScript object prototypes and had a singleton virtual machine (VM) and garbage collector (GC). These are killers for re-entrancy.
Static data is shared between all users of a function. If you tried to run two SWFs at the same time while Gnash implemented ActionScript objects like this, the ActionScript in one SWF would affect the way the other SWF ran.
Singleton objects are deliberately restricted to only one instance. This makes it very easy to access the object from all parts of the code, but if you want to run two SWFs, you need two VMs. Unfortunately, the ease of access meant that the codebase relied on the singleton design, and it becomes horribly time-consuming to rewrite.
I've gradually been removing static data for years and replacing it with properly tested alternatives. This had the added advantage of being more compatible with the Adobe Flashplayer. Last week I removed the final static objects: the prototype and constructor for ActionScript's Function class.
I also made the VM and GC into properly re-entrant classes - another process that has been moving slowly forwards for years - so that each new SWF can have its own VM and GC.
What can Gnash do now?
This means that a single instance of Gnash is now able to play more than one SWF, either simultaneously or one after the other.
The possibilities that this opens up include:
- A real, windowless browser plugin (that also consumes less memory).
- A browser plugin on Windows.
- Better integration with other projects such as Lightspark.
- GUIs that can open several SWFs successively.
- Useful Python or PHP modules for controlling SWF execution.
- More powerful utilities for producing screenshots, converting to video.
None of these improvements is yet implemented. The code is waiting for you to contribute!
Or if you would like to support the development of Gnash, please get in touch.