A Flash Player emulator written in Rust
Go to file
Aaron Hill b56eace008
avm2: Implement property type coercions
Properties can be declared with a type
(e.g. `var foo:MyClass = new MyClass();`). When
`set_property`/`init_property` is invoked for that property,
the VM will attempt to coerce the value to the provided type,
throwing an error if this fails. This can have observable behavior
consequences - if a property has type `integer`, for example, then
storing a floating point `Number` to that property will cause the
value to be coerced to an integer. Some SWFs (e.g. 'Solarmax') rely
on this behavior in order to implicitly coerce a floating point value
that's later used for array indexing.

This PR implements property type coercions in Ruffle. There are several
important considerations:

* The class lookup for property types needs to be done lazily, since
we can have a cycle between two classes (e.g. `var prop1:Class2;`
and `var prop2:Class1` in two different classes).
* The class lookup uses special rules (different from
  `resolve_definition`), and does *not* use `ScopeStack/`ScopeTree`
This means that a private class can specified as a property name -
the lookup will succeed without using a scope, even though
`flash.utils.getDefinitionByName` would fail with the same name
* The specialized 'Vector' classes (e.g "Vector$int") can be used
as property types, even though they cannot be lookup up normally.

Some Ruffle class definitions were previously using nonexistent
classes as property types (e.g. "BareObject") - these are fixed
in this PR.
2022-06-30 21:34:26 -07:00
.cargo chore: Add a note to cargo config about RUSTFLAGS in the web build 2022-05-17 13:07:40 -07:00
.github web: Run tests on Node.js 18 2022-06-15 22:02:25 +03:00
core avm2: Implement property type coercions 2022-06-30 21:34:26 -07:00
desktop build(deps): bump clap from 3.2.1 to 3.2.2 2022-06-21 09:54:39 +03:00
exporter build(deps): bump clap from 3.2.1 to 3.2.2 2022-06-21 09:54:39 +03:00
render core: Free render backend resources on `BitmapData.dispose` 2022-06-29 15:16:43 -07:00
scanner build(deps): bump clap from 3.2.1 to 3.2.2 2022-06-21 09:54:39 +03:00
swf swf: Extract `Twips` to a separate file 2022-06-22 09:49:32 +03:00
tests avm2: Implement property type coercions 2022-06-30 21:34:26 -07:00
web build(deps): bump got from 11.8.3 to 11.8.5 in /web 2022-06-23 12:01:14 +03:00
wstr wstr: Allow creating `Pattern` from `FnMut` 2022-06-21 08:02:40 +03:00
.gitattributes chore: Cleanup .gitattributes 2021-02-19 16:28:09 -08:00
.gitignore chore: Cleanup .gitignore 2021-02-19 16:28:09 -08:00
CODE_OF_CONDUCT.md chore: Update CODE_OF_CONDUCT.md 2021-02-27 16:58:32 -08:00
CONTRIBUTING.md docs: Minor updates (#7264) 2022-06-22 08:45:22 +03:00
Cargo.lock core: Free render backend resources on `BitmapData.dispose` 2022-06-29 15:16:43 -07:00
Cargo.toml avm2: Allow implementing classes in ActionScript in custom `playerglobal` 2022-06-15 22:00:17 +03:00
LICENSE.md chore: Update copyright 2022-03-26 18:13:14 -07:00
PKGBUILD ci: Update PKGBUILD for AUR package 2021-04-25 11:47:58 -07:00
README.md docs: Minor updates (#7264) 2022-06-22 08:45:22 +03:00
rustfmt.toml chore: Add rustfmt.toml and rustfmt pass 2019-08-26 16:38:48 -07:00

README.md

Ruffle

Rust Build Status Web Build Status Ruffle npm Ruffle AUR Ruffle Discord
website | demo | nightly builds | wiki

Ruffle

Ruffle is an Adobe Flash Player emulator written in the Rust programming language. Ruffle targets both the desktop and the web using WebAssembly.

Project status

Ruffle is in the proof-of-concept stage and can currently run early Flash animations and games. Basic ActionScript 1.0/2.0 support is in place and improving; ActionScript 3.0 support is forthcoming. For more info, read the project roadmap.

Using Ruffle

The easiest way to try out Ruffle is to visit the web demo page, then click the "Browse..." button to load an SWF file of your choice.

Nightly builds of Ruffle are available for desktop and web platforms including the browser extension.

For more detailed instructions, see our wiki page.

Building from source

Follow the official guide to install Rust for your platform.

You must also have Java installed, and available on your PATH as java.

Desktop

If you are building for a Linux platform, make sure that the GTK 3 development packages are installed on your system. (Ubuntu: libgtk-3-dev, Fedora: gtk3-devel)

Use the following command to build and run the desktop app:

cargo run --release --package=ruffle_desktop

To run a specific SWF file, pass the SWF path as an argument:

cargo run --release --package=ruffle_desktop -- test.swf

To build in debug mode, simply omit --release from the command.

Homebrew

Ruffle Desktop can be built from our Homebrew Tap:

brew install --HEAD ruffle-rs/ruffle/ruffle

Note: because it is HEAD-only, you'll need to run brew upgrade --fetch-HEAD ruffle each time you want to update.

Web or Extension

Follow the instructions in the web directory for building either the web or browser extension version of Ruffle.

Scanner

If you have a collection of "real world" SWFs to test against, the scanner may be used to benchmark ruffle's parsing capabilities. Provided with a folder and an output filename, it will attempt to read all of the flash files and report on the success of such a task.

cargo run --release --package=ruffle_scanner -- folder/with/swfs/ results.csv

Exporter

If you have a swf and would like to capture an image of it, you may use the exporter tool. This currently requires hardware acceleration, but can be run headless (with no window).

  • cargo run --release --package=exporter -- path/to/file.swf
  • cargo run --release --package=exporter -- path/to/file.swf path/to/screenshots --frames 5

Structure

  • core contains the core emulator and common code
  • desktop contains the desktop client (uses wgpu-rs)
  • web contains the web client and browser extension (uses wasm-bindgen)
  • scanner contains a utility to bulk parse swf files
  • exporter contains a utility to generate PNG screenshots of a swf file

Sponsors

You can support the development of Ruffle via GitHub Sponsors. Your sponsorship will help to ensure the accessibility of Flash content for the future. Thank you!

Sincere thanks to the diamond level sponsors of Ruffle:

Newgrounds.com CPMStar Sébastien Bénard Crazy Games Cool Math Games The New York Times Armor Games Onda Educa TwoPlayerGames.org wowgame.jp Matt Roszak Doll Divine Movavi

License

Ruffle is licensed under either of

at your option.

Ruffle depends on third-party libraries under compatible licenses. See LICENSE.md for full information.

Contribution

Ruffle welcomes contribution from everyone. See CONTRIBUTING.md for help getting started.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be dual licensed as above, without any additional terms or conditions.

The entire Ruffle community, including the chat room and GitHub project, is expected to abide by the Code of Conduct that the Rust project itself follows.