Skip to content

onRuntimeInitialized called on Chrome but not Safari #18357

@stevedekorte

Description

@stevedekorte

This FAQ says Module.onRuntimeInitialized will be called when everything is ready:
https://emscripten.org/docs/getting_started/FAQ.html?highlight=onruntimeinitialized

This works for me on Chrome, but not on Safari.

My emscripten compiled&linked x.js file has the line:

if (Module["onRuntimeInitialized"]) Module["onRuntimeInitialized"]();

In Chrome, Module["onRuntimeInitialized"] returns the function I defined in the file that calls:

Module['onRuntimeInitialized'] = function () { console.log("got it!") }
import initModule from "./x.js";
initModule(Module)

But in Safari, Module["onRuntimeInitialized"] returns undefined.
I can manually edit the x.js file to call some other global function, but it would be nice if it worked as described in the FAQ.

My emcc version is:
% emcc -v
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.27 (afa75f3)
clang version 16.0.0 (https://github.com/llvm/llvm-project dee009d3b5c71a340eb4ebb3cfb49f6015a789cc)
Target: wasm32-unknown-emscripten
Thread model: posix

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