Skip to content

Use base64 encoding in embedded files in file packager #14482

Closed
@crudelios

Description

@crudelios

Hi,

I'm attempting to creating an emscripten build of a game. I want to embeed the game's assets to the html file as I want everything to load from a single file.

However, when I try to embed the assets directory (which contains about 1.000 files totalling 15 MB), the script uses an awful lot of memory and eventually fails with Allocation failed - JavaScript heap out of memory. This happens even if I set node.js's max memory size to 8GB.

Using --preload-file works fine but I do want to add the assets to the html file.

I'm building with cmake using the following flags:

set_target_properties(${SHORT_NAME} PROPERTIES LINK_FLAGS "-lidbfs.js -s SINGLE_FILE=1 -s DEMANGLE_SUPPORT=1 -s DYNCALLS=1 --shell-file ${PROJECT_SOURCE_DIR}/res/shell.html --embed-file ${PROJECT_SOURCE_DIR}/assets@/assets -s INITIAL_MEMORY=268435456 -s ALLOW_MEMORY_GROWTH=1 -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 -s SAFE_HEAP=1 -s INVOKE_RUN=0 -s EXPORTED_FUNCTIONS=[\"_main\"] -s EXPORTED_RUNTIME_METHODS=[\"callMain\",\"FS\"]  --bind")

An example build with the failure is available here: https://github.com/crudelios/julius/runs/2858867432

Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions