Running Flash in WebAssembly using CheerpX: an update

Alessandro Pignotti
Mar 10 · 7 min read

October 19 Update: CheerpX for Flash is now generally available. You can read the announcement here.

Note: We have recently announced CheerpX for Flash, a solution to extend the life of Flash applications post-2020. Find out more in this post

Extending the life of Flex, AS3 and AS2 Flash content with WebAssembly virtualization

Image for post
Image for post
The clouds are moving, is Flash Player installed though?

Back in August 2019, we published a blog post announcing CheerpX: a breakthrough technology that makes it possible to securely run unmodified binary code in the browser. This technology is based on a sophisticated JIT engine that generates WebAssembly code on the fly, and we plan to use this technology to execute Adobe’s Flash Player plugin. CheerpX has not yet been released, but we have given the first sneak peek into its internals just a few weeks ago.

While we did have a gut feeling that this use case was important (given that major browsers are going to remove Flash support in 2020), we were absolutely overwhelmed by the response to our post.

We can group the feedback we received into 3 main categories:

  • Flash gaming: A mind-blowing amount of Flash games have been created over time and all this content is going to be effectively lost after 2020. There is massive value, both commercial and historical in keeping all these titles accessible. Over the last months, we have been working very extensively to make CheerpX into a solution to run any AS3/AS2 Flash game with no modifications. Expect a dedicated announcement soon!
  • Education industry: Flash has been the technology of choice to deliver educational content, spanning the whole range from primary education to university exams and corporate education. Many players in this industry are being left without a practical option to operate their business after 2020, some of them literally told us that they may simply shut down. Hopefully, we will be able to help.
  • Flex/Spark (enterprise) UIs: This segment of the market was for a long time dominated by Java Swing applets, but Adobe Flex gained widespread adoption at some point due to a more modern UI styling and possibly a better plugin, to begin with. The Java plugin was indeed deprecated years ago already. We are working with several early adopters to provide a solution to extend the life of Flex applications without requiring any modification.

The level of interest we received confirmed our hunch that preserving Flash content was a great use case for CheerpX, which is by nature a very general-purpose technology. The technical capabilities of CheerpX have massively improved since our last post, both in terms of support for Flash content, performance, and rendering correctness.

In this post, we will provide an update on the technical status of this project, showing how AS3, AS2, and Flex content can run seamlessly in WebAssembly. Enjoy the show.

ActionScript 3.0 games

I am still surprised that this works, and I designed CheerpX myself.

The recently announced Ruffle project is making good progress in supporting ActionScript 2.0 games. Full support for ActionScript 3.0 is going to be a much more challenging and time-consuming problem though. I have some experience on the matter as I am the original author of Lightspark (a C++ FOSS implementation of Flash). Lightspark is, to this day, the most complete open-source implementation of the massive runtime library of Flash.

With CheerpX we can ignore the complexity of AS3 and its accompanying runtime library. We can “simply” let the whole plugin run in our virtualized environment.

AS3 games provide a very challenging environment to the performance of the CheerpX x86 to WebAssembly JIT compiler. We have been making very significant progress in achieving a level of runtime performance that is adequate for playing the vast majority of historical AS3 content.

We expect our solution, when released, to find very widespread use by the world’s largest video game distribution platforms.

AS2.0 games and older animations

TLDR; if it’s an SWF it will work.

Although there may be other viable solutions to run older Flash files, CheerpX can also run ActionScript 2.0 content as expected, which means we can run any Flash game or animation correctly with the same solution.

The Flex framework

Image for post
Image for post
How can you be sure that this is rendered by CheerpX? Well, you can’t and that’s sort of the point.

The Flex framework has seen quite some popularity in the enterprise software world, including for internal dashboards in private network or otherwise non-public websites.

We have been able to enlist several organizations in our Early Adopter Programme which has given us the opportunity to successfully test CheerpX on a few real-world Flex application. I cannot share images from these private applications, but you can see that the Tour-De-Flex showcase application from the Flex project (now managed by the Apache Foundation) renders correctly.

In a sense, this is not surprising, with our approach we are running a virtualized instance of the binary Flash plugin so, unless our VM/JIT compiler is buggy, we expect the results to be identical. This said Flex applications are a pretty brutal test case for our technology, for a number of reasons:

  • Flex applications are generally quite large and, since they are almost completely software-rendered, they need to execute large amounts of AS3 code. The Flash plugin itself includes a JIT compiler that converts AS3 code to x86 code on the fly, which is then JIT compiled by CheerpX into WebAssembly. Large applications mean that lots of code is generated (and invalidated), putting stress on the CheerpX JIT compiler and self-modifying-code detection logic. Our system appears to be stable and robust nevertheless, which is great.
  • The Flex framework is very sizeable and was designed to be distributed as loadable modules or libraries. The final SWF would include a small loader and its own payload, and it would download the required modules of Flex from Adobe’s servers dynamically. Such modules are immutable for a certain release of Flex (e.g. version 4.0) and cached by the plugin, so if multiple applications are accessed the total download time would be reduced. These Flex modules are distributed in an undocumented SWZ format, signed by Adobe and possibly encrypted. Even if we can’t inspect the contents of SWZ modules, CheerpX can still execute the code. It is just a matter of downloading the file as a binary blob and passing the blob as it is to the binary plugin. The plugin will then do whatever is necessary to decode the file internally.
  • As a side note, the mere fact that these cryptographic operations succeed in CheerpX is a good litmus test for our engine. Even a minor implementation mistake could cause crypto checks to fail.

Wait? All of this only for Flash?

Image for post
Image for post
A 32-bit build of Python 2.7 running in the browser. What have I done?

Actually no, CheerpX is a generic, robust and scalable technology to run X86 binaries in the browser. We are currently focusing on the Flash plugin due to the large demand we see for this specific use case. But CheerpX is much, much more than this.

Do you think you have an interesting use case for our tech? Get in touch with us at info@leaningtech.com.

What’s next?

The development of CheerpX has been proceeding at a very fast pace since the summer of 2019, and even more intensely from the beginning of 2020. The first builds of CheerpX for Flash will be distributed to our early adopters by the end of March / early April. Significant challenges lie ahead, especially on the performance side, but we are very proud of the results we achieved so far and confident that we can deliver on our promises.

CheerpX, similarly to the other tools we make, is possible thanks to the fast development and adoption of WebAssembly. Last month, we presented the core technology on which CheerpX is based at the WasmSF meetup in San Francisco. Yuri, a senior engineer here at Leaning Technologies, did a great talk. You can find the talk here if you want to know more about CheerpX works.

About the previously mentioned Early Adopter Programme for CheerpX, our main objective was to have access to a variety of Flash applications representing the whole spectrum of use cases. We think that we have reached this objective with the organizations we have currently signed up. This said, if you think your specific use case should be part of the Early Adopter Programme, or for any question, please get in touch at info@leaningtech.com.

Here at Leaning Technologies we also make:

  • Cheerp, a C++ to WebAssembly/JavaScript compiler
  • CheerpJ, a Java to WebAssembly/JavaScript/HTML5 compiler and runtime

Interested in what we do? Follow us on our website, Twitter and Medium!

Image for post
Image for post

leaningtech

Leaning Technologies' Blog - everything Cheerp, CheerpJ…

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store