Repository navigation
Hello! Popcorn reached another milestone, which is:
🥁🥁🥁
OTP/BEAM support!
The full blog post explaining why we did such a move and how it works now can be found here.
In the meantime...
Added features
- Popcorn now runs on OTP/BEAM (OTP 29.0.6, Elixir 1.20.4).
- You can pass custom environment variables, options, and flags.
- Use
schedulers()to set scheduler counts. We use one scheduler of each type by default.
async send()in JS sends messages to VM processes;trySend()returns a result object.Reqadapter using browserfetch()for HTTP requests from Elixir.- We now support interactive terminal I/O through
writeStdin()andresizeTty(). Popcorn.JS.available?/0was added to detect if we're running in the browser.- The bridge supports atoms, tuples, PID handles, binaries, BigInt, Date, Map, and Set.
Changed features
Popcorn.Wasmis nowPopcorn.JS;run_js()andrun_js!()are nowrun()andrun!(). JS functions receive(args, actions)and return values directly.async call()in JS has atryCall()variant.cast()in JS is now asynchronous and has atryCast()variant.call()andcast()are now forwarded throughPopcorn.Proxyto GenServers. The proxy starts automatically under the:popcornapplication.onMessage()in JS is nowonEvent(). Send events withPopcorn.JS.send/1; the callback receives a single value.PopcornInternalErrorand error codes are nowPopcornError. We use structured errors, witht(type) anddatafields.- JS
try*methods return result objects ({ok: true, data} | {ok: false, error}). Other fallible methods throw or reject on failure. %Popcorn.TrackedObject{}is replaced by handles fromnew TrackedValue(value, cleanup), with optional cleanup functions.- Applications now ship as tarballs instead of
.avmbundles. - The VM now runs in Web Workers instead of an iframe plus Web Workers. JS interop runs in the page.
Removed features
- AtomVM is now unsupported.
registerLogListener()andunregisterLogListener()were removed. Dispatch logs throughonStdoutandonStderrcallbacks.heartbeatTimeoutMsandonReloadwere removed. Use theonErrorcallback to observe VM failures.durationMsfield in responses.Wasm.ready/0,1. We now use the normal OTP application lifecycle.Wasm.get_tracked_values/1andWasm.get_tracked_values!/1. Pass handles intoPopcorn.JS.run/3to access their values.Wasm.register_event_listener/2andWasm.unregister_event_listener/1. UseaddEventListener()andremoveEventListener()insidePopcorn.JS.run/3.1
Others
- Popcorn's landing page was redesigned!
- Docs are much better now and contain tutorials for starting with Popcorn
See the migration guide and documentation.
-
Use a tracked value with a cleanup callback to remove the listener when its handle is released. Call cleanup explicitly when timing matters. ↩