Skip to content

file picker crashes in the web client: HEAPU8 not exported #29

Description

@russiaman

Bug report — file picker crashes in the web client: HEAPU8 not exported

Found while: adding a new (unrelated) file-picker use case in a fork; not a regression we introduced —
this breaks every existing file-picker path in the web build (avatar model upload, animation upload),
they just don't appear to have been exercised end-to-end in the web client before.

Symptom

Any use of the browser file-picker widget (webclient/webclient.html's #file-picker-form) crashes the
WASM module on submit. Browser console:

Aborted('HEAPU8' was not exported. add it to EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ))
...
Uncaught (in promise) RuntimeError: unreachable

Root cause

webclient/webclient.html's form-submit handler writes the picked file's bytes directly into the wasm
heap before calling into C++:

const dataPtr = Module._malloc(uint8Array.length);
Module.HEAPU8.set(uint8Array, dataPtr);   // <-- Module.HEAPU8 is undefined
Module.ccall('processFilePickerFile', ...);

gui_client/CMakeLists.txt's Emscripten link flags only export ccall:

-sEXPORTED_RUNTIME_METHODS=ccall

Newer Emscripten versions no longer expose HEAPU8/HEAP8/etc. on Module by default — they must be
listed explicitly in EXPORTED_RUNTIME_METHODS (see the Emscripten FAQ entry the abort message points
at). This project's toolchain evidently predates that default, or was never actually run against this
code path, so the flag was never added.

Why it matters

This is the only file-picker mechanism the web client has (showFilePickerWidget() /
processFilePickerFile()), used for:

  • avatar model upload (UIInterface::PICK_AVATAR_MODEL)
  • gesture/animation upload (UIInterface::PICK_ANIMATION_FILE)
  • (new, from our fork) Gaussian splat file upload (UIInterface::PICK_GAUSSIAN_SPLAT)

Every one of these is broken in the web build today, unconditionally, on the very first attempt to
submit a file. Native/desktop (Qt) builds are unaffected — they don't go through this JS path.

Fix

One-line link-flag addition, gui_client/CMakeLists.txt:

- "-sEXPORTED_RUNTIME_METHODS=ccall"
+ "-sEXPORTED_RUNTIME_METHODS=ccall,HEAPU8"

Verified: rebuilding the web client with this flag and re-running the exact same file-picker flow
(browser file dialog → submit → processFilePickerFile()) succeeds with no console errors.

Repro steps (pre-fix)

  1. Build/run the web client (gui_client.js/.wasm via Emscripten).
  2. Trigger any file picker (e.g. avatar settings → "load model", or the animation-add button in Gesture
    Manager).
  3. Choose a file, click the form's submit button.
  4. Console shows the HEAPU8 was not exported abort; the WASM module is now dead (unreachable trap),
    requiring a page reload.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions