Summary
Replace EM_ASM_ block in emscripten/ARimageFsetDisplay.cpp (lines 180–190) with idiomatic C++ / embind
Environment
- Product/Service: FeatureSET-Display — Emscripten/wasm native layer
- File:
emscripten/ARimageFsetDisplay.cpp lines 180–190, emscripten/bindings.cpp lines 46–55
Problem Description
The current block uses EM_ASM_ to write frameIbwpointer, frameimgBWsize, and frameFeaturePoints onto a JS-side arfset.frameMalloc object. This incurs an extra wasm→JS crossing on every frame and introduces hidden global state. The same three values are already exposed through the embind nftMarker value_object (pointer, imgBWsize, nftFeaturePoints in bindings.cpp:46-55), so JS can read them directly from the returned struct.
Expected Behavior
No EM_ASM_ blocks remain in the hot path. JS reads pointer, imgBWsize, and nftFeaturePoints directly from the nftMarker struct returned by embind, eliminating the side-channel global.
Actual Behavior
EM_ASM_ fires every frame, crossing the wasm↔JS boundary and mutating arfset.frameMalloc as a hidden side-channel.
Tasks
Impact
Medium — Performance: eliminates a per-frame wasm→JS crossing and removes hidden global state. No functional regression expected.
Additional Context
If a JS-visible global is genuinely required, prefer emscripten::val (pure C++, type-safe):
val::global("arfset")["frameMalloc"].set("frameIbwpointer", arc->imgBW);
Last resort: EM_JS(void, set_frame_malloc, (...), { ... }) — parsed once at build time.
See also: issue 1b (listener leak fix) should land first as it touches the same drawing path.
Summary
Replace
EM_ASM_block inemscripten/ARimageFsetDisplay.cpp(lines 180–190) with idiomatic C++ / embindEnvironment
emscripten/ARimageFsetDisplay.cpplines 180–190,emscripten/bindings.cpplines 46–55Problem Description
The current block uses
EM_ASM_to writeframeIbwpointer,frameimgBWsize, andframeFeaturePointsonto a JS-sidearfset.frameMallocobject. This incurs an extra wasm→JS crossing on every frame and introduces hidden global state. The same three values are already exposed through the embindnftMarkervalue_object (pointer,imgBWsize,nftFeaturePointsinbindings.cpp:46-55), so JS can read them directly from the returned struct.Expected Behavior
No
EM_ASM_blocks remain in the hot path. JS readspointer,imgBWsize, andnftFeaturePointsdirectly from thenftMarkerstruct returned by embind, eliminating the side-channel global.Actual Behavior
EM_ASM_fires every frame, crossing the wasm↔JS boundary and mutatingarfset.frameMallocas a hidden side-channel.Tasks
EM_ASM_and read fromnftMarker)EM_ASM_block fromARimageFsetDisplay.cpp:180-190js/arfset.api.jsandsrc/ARFset.jsto read from the returnednftMarkerstruct instead ofarfset.frameMallocImpact
Medium — Performance: eliminates a per-frame wasm→JS crossing and removes hidden global state. No functional regression expected.
Additional Context
If a JS-visible global is genuinely required, prefer
emscripten::val(pure C++, type-safe):Last resort:
EM_JS(void, set_frame_malloc, (...), { ... })— parsed once at build time.See also: issue 1b (listener leak fix) should land first as it touches the same drawing path.