feat: WASM build for browser replay#89
Merged
Merged
Conversation
New Emscripten build under wasm/ and src/wasm/. Playback pre-extracts
ULog events into flat per-type arrays at init time, frees the raw file
bytes, and iterates cursors over the arrays. Target per-drone memory
~5 MB for a 1000 s flight, keeping multi-drone swarms within
mobile-browser budgets.
Per-message state updates are shared with native via
src/ulog_replay_apply.{c,h} (ulog_apply_attitude/gpos/lpos/aspd/vstatus/
home, ulog_local_to_global, ulog_nav_state_name). Native process_message
now decodes into event structs and dispatches to the same helpers;
existing ulog_replay tests pass unchanged (byte-identical output on
fixture logs).
ulog_replay_ctx_t gains timeline + cursor fields under
#ifdef __EMSCRIPTEN__ (zero bytes on native); parser / cache / sub_*
fields are gated out under #ifndef __EMSCRIPTEN__ so WASM avoids
~1.3 MB of unused format tables per drone.
Dev harness blocks space-bar page scroll while the canvas is focused
so play/pause works without also scrolling the page.
Build:
emcmake cmake -S wasm -B wasm/build -DCMAKE_BUILD_TYPE=Release
cmake --build wasm/build -j
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an Emscripten build target so the replay path runs in the browser. Per-message state updates are shared between native and WASM to prevent drift between the two implementations.
Changes
wasm/build target (CMake, shell.html dev harness, entry point, JS API)src/wasm/ULog extractor + flat-timeline replay pathsrc/ulog_replay_apply.{c,h}and called from both targetsprocess_messagerefactored into decode + apply dispatch (byte-identical output per existing tests)ulog_replay_ctx_tgains timeline/cursor fields under#ifdef __EMSCRIPTEN__(zero bytes on native);parser/cache/sub_*fields gated under#ifndef __EMSCRIPTEN__so WASM avoids ~1.3 MB of unused format tables per droneImpact
ulog_replaytest suite passes unchanged.hawkeye.wasm~568 KB.Test plan
make testpasses (7/7)emcmake cmake -S wasm -B wasm/build && cmake --build wasm/build