-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ReferenceError: asyncifyStubs is not defined #21104
Comments
What is in Do you have a backtrace for where the Can you try removing BTW, you can use simple list for |
Hi @sbc100, thanks for the lightning fast response,
mergeInto(LibraryManager.library, {
$func_map: "new Map()",
$func_idx: "0",
$registerJSCallback__deps: ['$func_map', '$func_idx'],
$registerJSCallback: function (fn) {
index = func_idx
func_map.set(index, fn)
func_idx++;
return index;
},
call_js_callback__proxy: 'sync',
call_js_callback__sig: 'ipi',
call_js_callback__deps: ['$func_map', '$func_idx'],
call_js_callback: function (id, value, ctx) {
var fn = func_map.get(id)
fn(value, ctx)
// if call_js_callback__proxy is `async` then after calling the fn we
// must check if it return a promise, in that case we should use the `.then(..)`
// and free the memory there.
},
remove_js_callback__proxy: 'sync',
remove_js_callback__sig: 'i',
remove_js_callback__deps: ['$func_map', '$func_idx'],
remove_js_callback: function (id) {
func_map.delete(id)
}
});
mergeInto(LibraryManager.library, {
test_call_js_callback__proxy: 'sync',
test_call_js_callback__sig: 'ipi',
test_call_js_callback__deps: ['$func_map', '$func_idx'],
test_call_js_callback: function () {
console.log("Hello world from Callback");
// if call_js_callback__proxy is `async` then after calling the fn we
// must check if it return a promise, in that case we should use the `.then(..)`
// and free the memory there.
},
}); Question 1: Will I still need this function wrapper with the
/** @type {function(...*):?} */
function __emval_await(
) {
abort('missing function: _emval_await');
}
__emval_await.sig = 'pp';
__emval_await.stub = true;
asyncifyStubs['_emval_await'] = undefined;
/** @type {function(...*):?} */
function __emval_call(
) {
abort('missing function: _emval_call');
}
__emval_call.sig = 'dpppp';
__emval_call.stub = true;
asyncifyStubs['_emval_call'] = undefined;
/** @type {function(...*):?} */
function __emval_decref(
) {
abort('missing function: _emval_decref');
}
__emval_decref.sig = 'vp';
__emval_decref.stub = true;
asyncifyStubs['_emval_decref'] = undefined;
/** @type {function(...*):?} */
function __emval_get_method_caller(
) {
abort('missing function: _emval_get_method_caller');
}
__emval_get_method_caller.sig = 'pipi';
__emval_get_method_caller.stub = true;
asyncifyStubs['_emval_get_method_caller'] = undefined;
/** @type {function(...*):?} */
function __emval_run_destructors(
) {
abort('missing function: _emval_run_destructors');
}
__emval_run_destructors.sig = 'vp';
__emval_run_destructors.stub = true;
asyncifyStubs['_emval_run_destructors'] = undefined;
Removing
instrumentWasmImports(imports) {
var importPattern = /^(invoke_.*|__asyncjs__.*)$/;
for (let [x, original] of Object.entries(imports)) {
let sig = original.sig;
if (typeof original == 'function') {
let isAsyncifyImport = original.isAsync || importPattern.test(x);
// Wrap async imports with a suspending WebAssembly function.
if (isAsyncifyImport) {
assert(sig, `Missing __sig for ${x}`);make
let type = sigToWasmTypes(sig);
// Add space for the suspender promise that will be used in the
// Wasm wrapper function.
type.parameters.unshift('externref');
imports[x] = original = new WebAssembly.Function(
type,
original,
{ suspending: 'first' }
);
}
}
}
}, Is there a flag that i need to be adding to let the codegen know that i want Further Context: I basically am looking for a way for the WASM to asynchronously send values to the TS, on some event. Any guidance is greatly appreciated. Thank you for your help, and your patience ! |
|
I'd still like to understand how you got the original issue with |
We don't currently have a nice warning. It got sidetracked on how to properly check if JSPI is supported with the possibility of suspender being removed. |
That discussion is taking awhile, so maybe we should just add the warning for how it currently works. |
Sounds like simply checking for |
That will check if type reflection is enabled (needed by JSPI), but won't tell us about JSPI. For now, we can check |
Could you add this check? Then I think we can close this issue |
I'm also getting this error: Unfortunately I don't think I can remove the My linker flags:
|
Have same error on 3.1.56 if -s ERROR_ON_UNDEFINED_SYMBOLS=0 |
@caiiiycuk is this a regression? If so it would be great if you could help by bisecting to find out what revision broke this behaviour: https://emscripten.org/docs/contributing/developers_guide.html#bisecting |
@sbc100, sure, here it is:
|
@caiiiycuk can you share the linker flags you are using to reproduce this? |
If you want, I can share project with you |
Thanks, I think I have enough info to make a repro case now. |
Version of emscripten/emsdk: using Docker image
FROM emscripten/emsdk:3.1.51
Failing command line in full:
This is a runtime failure for me, in the browser.
Context, compiling
CPP
->WASM
to run in the browser.Packaging with Webpack.
Fails in both Chrome and Firefox.
Full link command and output with
-v
appended:Building emscripten with
CMakeLists.txt
Exact error that i am getting:
Uncaught (in promise) ReferenceError: asyncifyStubs is not defined
Any pointers as to the correct incantation of Linker flags,
or if you require any other information, please let me know.
The text was updated successfully, but these errors were encountered: