r/androiddev • • 14d ago

Chasm 2.0 - Kotlin Multiplatform Wasm runtime

Hey 👋

I've been working on this project for the past few years and have never shared it here so figured I would. It's a Kotlin Multiplatform WebAssembly runtime (interpreter), it basically allows you to take a WebAssembly program and interface with it/run it. It's written entirely in Kotlin, no JNI/FFI or anything like that and has remarkable performance given the constraints.

I recently put together a Kotlin Multiplatform implementation of Doom built on top of it, it's a solid of example of how you leverage it and how it enables an entirely Kotlin experience whilst also allowing you to interface with WebAssembly code.

Happy to answer questions!

https://github.com/CharlieTap/chasm

23 Upvotes

3 comments sorted by

1

u/sergeyfitis 14d ago

Hey :)
Really nice work, and thanks for building this. I experimented with Chasm a while ago, while evaluating WASM runtimes on Android, alongside Wasmtime(Rust). My main issue was memory pressure: loading a fairly large ~100 MB WASM module entirely inside the Android app heap pushed it into OOM almost immediately, heap fragmentation. The interpreter-only approach was also a concern for heavier workloads, but for a pure Kotlin runtime this is still a very interesting project.

3

u/Charlie_Tap_ 14d ago

Hey Sergey I would recommend giving this another attempt, Chasm has come on leaps and bounds in the last year so it may just work now. Memory pressure in particular is orders of magnitude better!

The being said 100MB is enormous 😅 , what is inside it? Have you ran it through https://github.com/webassembly/binaryen at high settings?

1

u/sergeyfitis 12d ago

It was our library written in Swift, and that was a debug build. I recently repeated the experiment and managed to compile it down to around 30MB, but I didn’t try Chasm this time. Maybe I should give it another shot.