-
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
I can see the exported function in the mymodule.js however the await _jsRuntime.InvokeAsync cant find it #22580
Comments
when I combined all modules into one, compiled using -s MODULARIZE=1 -s EXPORT_ES6=1 the name of the function _xpower was present in the .js file. but, the webassembly still failing to fund it |
I add the following in the index.html: <script type="module"> import createModule from './mymodule.js'; // Adjust the path if necessary createModule().then((Module) => { if (typeof Module._xpower === 'function') { console.log("Function myfunction is accessible!"); Module._xpower(); } else { console.log("Function myfunction is NOT accessible."); } }).catch((error) => { console.error("Error loading module:", error); }); </script>and the console output is Function is accessible however with the following error after: when I still call the function then I get undefined: |
Can you share the full link command you are using? I general, if you want to export a function such as |
Oh I see you have managed to call the function, but its crashing. You can get more information from the backtrace if you build with |
Hi Sam,
many thanks for your email.
the -g options caused error, so not investigated it much further.
I've managed to build and see the functions after using this commandline:
emcc quadprog.cc -o quadprog.js -s NO_EXIT_RUNTIME=1 -s "EXPORTED_RUNTIME_METHODS=['ccall']" -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE='$cwrap'
whilst inside the code I used EXTERN EMSCRIPTEN_KEEPALIVE before the function and these
#ifdef __cplusplus
#define EXTERN extern "C"
#else
#define EXTERN
#endif
in the header.
so the call I am making is using invoke:
```
await _jsRuntime.InvokeAsync<double>("_xpower", GJagged, g0,
ConvertToJaggedArray(CE), ce0,
ConvertToJaggedArray(CI), ci0,
x,
d1G, d2G, dg0, d1CE, d2CE, dce0, d1CI, d2CI, dci0, dx);
```
I had G as a double[,], understood its something with webassembly or the serialisation process, but had issues with it so converted it into jaggedarray. GJagged is first parameter and meant to be passed to a c++ double[][].
My debugging messages show that the values didnt pass through or maybe I am assigning these to the c++ array which is defined as double* g in the c++ module.
am I doing something wrong? I am using d1G and d2G as the dimensions of the array of G to reconstruct.
any suggestion?
thanks. On Thursday 19 September 2024 at 00:20:21 BST, Sam Clegg ***@***.***> wrote:
Oh I see you have managed to call the function, but its crashing. You can get more information from the backtrace if you build with -g (or --profiling-functions). That might help you found out its crashing.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Passing arrays and non-trival data type to WebAssembly requires some kind of serialization layer yes. For more information on the various options here here https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html. I assume I would recommend starting something very simple and building up. For example, just export some simple function that take plain integers and make sure that is all working. I would also highly recommend |
thanks Sam, _xpower is a c++ function that I am trying to call from a webassembly host side .cs module. Sent from my Galaxy
-------- Original message --------From: Sam Clegg ***@***.***> Date: 19/09/2024 15:05 (GMT+01:00) To: emscripten-core/emscripten ***@***.***> Cc: brommadnaz929 ***@***.***>, Author ***@***.***> Subject: Re: [emscripten-core/emscripten] I can see the exported function in
the mymodule.js however the await _jsRuntime.InvokeAsync cant find it (Issue
#22580)
Passing arrays and non-trival data type to WebAssembly requires some kind of serialization layer yes.
For more information on the various options here here https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html.
I assume _jsRuntime.InvokeAsync is being called from the C/C++ code? But what does the code look like that is calling the native wasm function? Is it just using ccall? I'm a little confused about why you seem to be calling _xpower via InvokeAsync from the C/C++ when _xpower is already a C/C++ function? Am I correct that _xpower is a C/C++ function that you are trying to call from JS?
I would recommend starting something very simple and building up. For example, just export some simple function that take plain integers and make sure that is all working.
I would also highly recommend --profiling-funcs if -g doesn't work... although if -g is not working for you we would like to know why. That seems rather worrying.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Hi Sam,
I followed the docs and I am now using cwrap for the call. I am building my c++ project using the following command:
/c/github/polygon/netcore6libs/xpower/srcemscripten
$ emcc xpower.cc -o xpower.js -s NO_EXIT_RUNTIME=1 -s "EXPORTED_RUNTIME_METHODS=['ccall','cwrap']" -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE='$cwrap' -O0
my function in the c++ project is:
EXTERN EMSCRIPTEN_KEEPALIVE double xpower(double* csG, double* csg0,
double* csCE, double* csce0,
double* csCI, double* csci0,
double* csx,
int csD1G, int csD2G, int csg0D, int csD1CE, int csD2CE, int csce0D, int csD1CI, int csD2CI, int csci0D, int csxD)
for calling using cwrap from javascript I do the following:
I created a class for the params:
public class ParamsData()
{
public double[] flattenedG { get; set; }
public double[] g0 { get; set;}
public double[] flattenedCE {get; set;}
public double[] ce0 { get; set;}
public double[] flattenedCI {get; set;}
public double[] ci0 { get; set;}
public double[] x { get; set; }
public int d1G { get; set; }
public int d2G { get; set;}
public int dg0 { get; set;}
public int d1CE { get; set;}
public int d2CE { get; set;}
public int dce0 { get; set;}
public int d1CI { get; set;}
public int d2CI { get; set;}
public int dci0 { get; set;}
public int dx { get; set;}
}
and from same .cs module which sits on the front side of the webassembly project I populate the params class, serialize it then call a javascript function, which is defined in the index.html using InvokeAsync:
object paramsData = new ParamsData(){flattenedG=flattenedG, g0=g0,
flattenedCE= flattenedCE, ce0=ce0,
flattenedCI= flattenedCI, ci0=ci0,
x=x,
d1G=d1G, d2G=d2G, dg0=dg0, d1CE=d1CE, d2CE=d2CE, dce0=dce0, d1CI=d1CI, d2CI=d2CI,
dci0=dci0, dx=dx};
ret = await _jsRuntime.InvokeAsync<double>("callXPower", JsonConvert.SerializeObject(paramsData));
the function in the index.html is:
function callSolve(params) {
Module.cwrap('xpower', 'number',
'array',
'array',
'array',
'array',
'array',
'array',
'array',
'number',
'number',
'number',
'number',
'number',
'number',
'number',
'number',
'number',
'number',
params["flattenedG"], params["g0"],
params["flattenedCE"], params["ce0"],
params["flattenedCI"], params["ci0"],
params["x"],
params["d1G"], params["d2G"], params["dg0"], params["d1CE"],
params["d2CE"], params["dce0"],
params["d1CI"],
params["d2CI"],
params["dci0"],
params["dx"]);
}
and when the call is made I get the following error:
Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: argTypes.every is not a function
TypeError: argTypes.every is not a function
at Object.cwrap (https://localhost:7123/_framework/dotnet.native.8.0.8.93i67mqfmb.js:8:109691)
at callSolve (https://localhost:7123/:63:20)
at https://localhost:7123/_framework/blazor.webassembly.js:1:2878
at new Promise (<anonymous>)
at b.beginInvokeJSFromDotNet (https://localhost:7123/_framework/blazor.webassembly.js:1:2835)
at Object.vn [as invokeJSJson] (https://localhost:7123/_framework/blazor.webassembly.js:1:58849)
at https://localhost:7123/_framework/dotnet.runtime.8.0.8.80cvijctdx.js:3:178428
at Ll (https://localhost:7123/_framework/dotnet.runtime.8.0.8.80cvijctdx.js:3:179262)
at wasm://wasm/00b21c96:wasm-function[349]:0x1f99d
at wasm://wasm/00b21c96:wasm-function[245]:0x1be41
Microsoft.JSInterop.JSException: argTypes.every is not a function
TypeError: argTypes.every is not a function
at Object.cwrap (https://localhost:7123/_framework/dotnet.native.8.0.8.93i67mqfmb.js:8:109691)
at callSolve (https://localhost:7123/:63:20)
at https://localhost:7123/_framework/blazor.webassembly.js:1:2878
at new Promise (<anonymous>)
at b.beginInvokeJSFromDotNet (https://localhost:7123/_framework/blazor.webassembly.js:1:2835)
at Object.vn [as invokeJSJson] (https://localhost:7123/_framework/blazor.webassembly.js:1:58849)
at https://localhost:7123/_framework/dotnet.runtime.8.0.8.80cvijctdx.js:3:178428
at Ll (https://localhost:7123/_framework/dotnet.runtime.8.0.8.80cvijctdx.js:3:179262)
at wasm://wasm/00b21c96:wasm-function[349]:0x1f99d
at wasm://wasm/00b21c96:wasm-function[245]:0x1be41
at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__16`1[[System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
.
.
.
would you know whats causing this error? or is my cwrap call not correct? maybe a ismpler way to call cwrap.
Appreciate your feedback and help.
Regards
Reid. On Thursday 19 September 2024 at 14:05:17 BST, Sam Clegg ***@***.***> wrote:
Passing arrays and non-trival data type to WebAssembly requires some kind of serialization layer yes.
For more information on the various options here here https://emscripten.org/docs/porting/connecting_cpp_and_javascript/Interacting-with-code.html.
I assume _jsRuntime.InvokeAsync is being called from the C/C++ code? But what does the code look like that is calling the native wasm function? Is it just using ccall? I'm a little confused about why you seem to be calling _xpower via InvokeAsync from the C/C++ when _xpower is already a C/C++ function? Am I correct that _xpower is a C/C++ function that you are trying to call from JS?
I would recommend starting something very simple and building up. For example, just export some simple function that take plain integers and make sure that is all working.
I would also highly recommend --profiling-funcs if -g doesn't work... although if -g is not working for you we would like to know why. That seems rather worrying.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
also, note that the 'array' type supported by ccall/cwrap only supports byte arrays.. if you want the C code to receive an array of anyting by bytes I don't think you can use that. |
Hi Sam,
thanks for your help.
so I went for ccall, as it supports passing string as I understood for the documentation . I changed my function so that it takes input inform of: char* input . I am still stuck although fee getting closer :). I think would help many if theres a nice example how to work with a string being passed as a param also having the function returning a string.
so this is what I done:
the params I serialised into a string: (the consol.log)
{"flattenedG":[1.0000000149999999E-07,0.0,0.0,0.0017381669037459457],"g0":[-0.0,-0.0],"flattenedCE":[1.0,1.0],"ce0":[0.0],"flattenedCI":[0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,-1.0,0.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,0.0,1.0,0.0,-1.0],"ci0":[-0.0,1.0,-0.0,1.0,-0.0,1.0,1.0,-0.0,-1.0,1.0],"x":[0.0,0.0],"d1G":2,"d2G":2,"dg0":2,"d1CE":2,"d2CE":1,"dce0":1,"d1CI":2,"d2CI":10,"dci0":10,"dx":2}
then I call: var data = stringToNewUTF8(params). where stringToNewUTF8 I exported in the EMCC command line. when I do console.log(data) I get:
89768
the function call is:
var ptrF = Module.ccall('xpower, null, paramTypes,data);
throws the following error:
Invalid UTF-8 leading byte 0xfffffffe encountered when deserializing a UTF-8 string in wasm memory to a JS string!
inside xpower I am displaying to std::cout the the input (the param in the procedure): what I see is: emscgT��
EXTERN EMSCRIPTEN_KEEPALIVE void xpower(char* input)
{
std::cout << input << std::endl;
}
The full jvscript code:
function callXpower(params) {
var paramTypes = ['string'];
console.log(params);
var data = stringToNewUTF8(params);
console.log(data);
var ptrF = Module.ccall('xpower', null, paramTypes,data);
}
where params is the json serialised string.
the full log:
{"flattenedG":[1.0000000149999999E-07,0.0,0.0,0.0017381669037459457],"g0":[-0.0,-0.0],"flattenedCE":[1.0,1.0],"ce0":[0.0],"flattenedCI":[0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,-1.0,0.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,0.0,1.0,0.0,-1.0],"ci0":[-0.0,1.0,-0.0,1.0,-0.0,1.0,1.0,-0.0,-1.0,1.0],"x":[0.0,0.0],"d1G":2,"d2G":2,"dg0":2,"d1CE":2,"d2CE":1,"dce0":1,"d1CI":2,"d2CI":10,"dci0":10,"dx":2}
VM17:31 89768
VM11 xpower.js:1199 Invalid UTF-8 leading byte 0xfffffffe encountered when deserializing a UTF-8 string in wasm memory to a JS string!
warnOnce @ VM11 xpower.js:1199
UTF8ArrayToString @ VM11 xpower.js:1031
put_char @ VM11 xpower.js:1728
write @ VM11 xpower.js:1711
write @ VM11 xpower.js:3367
doWritev @ VM11 xpower.js:4083
_fd_write @ VM11 xpower.js:4101
$func197 @ xpower.wasm:0x10f20
$func217 @ xpower.wasm:0x1158e
$func218 @ xpower.wasm:0x115f3
$func626 @ xpower.wasm:0x1544b
$func625 @ xpower.wasm:0x15360
$func273 @ xpower.wasm:0x11ca0
$func301 @ xpower.wasm:0x1222e
$func303 @ xpower.wasm:0x12280
$func14 @ xpower.wasm:0x115b
$func15 @ xpower.wasm:0x11bd
$xpower @ xpower.wasm:0x1b2b
(anonymous) @ VM11 xpower.js:603
ccall @ dotnet.native.8.0.8.93i67mqfmb.js:8
callSolve @ VM17:35
(anonymous) @ blazor.webassembly.js:1
beginInvokeJSFromDotNet @ blazor.webassembly.js:1
vn @ blazor.webassembly.js:1
(anonymous) @ invoke-js.ts:233
Ll @ invoke-js.ts:276
$func349 @ 00b21c96:0x1f99d
$func245 @ 00b21c96:0x1be41
$func238 @ 00b21c96:0xf00e
$func272 @ 00b21c96:0x1d05f
$func3186 @ 00b21c96:0xe873e
$func2506 @ 00b21c96:0xbe4b2
$func2512 @ 00b21c96:0xbecd6
$func2536 @ 00b21c96:0xc132d
$mono_wasm_invoke_method_bound @ 00b21c96:0xa4fb
Module._mono_wasm_invoke_method_bound @ dotnet.native.8.0.8.93i67mqfmb.js:8
kr @ invoke-cs.ts:273
l.javaScriptExports.complete_task @ managed-exports.ts:142
(anonymous) @ marshal-to-cs.ts:335
Promise.then
mo @ marshal-to-cs.ts:329
(anonymous) @ marshal-to-cs.ts:83
(anonymous) @ invoke-js.ts:177
Ll @ invoke-js.ts:276
$func349 @ 00b21c96:0x1f99d
$func245 @ 00b21c96:0x1be41
$func238 @ 00b21c96:0xf00e
$func272 @ 00b21c96:0x1d05f
$func3186 @ 00b21c96:0xe873e
$func2506 @ 00b21c96:0xbe4b2
$func2512 @ 00b21c96:0xbecd6
$func2536 @ 00b21c96:0xc132d
$mono_wasm_invoke_method_bound @ 00b21c96:0xa4fb
Module._mono_wasm_invoke_method_bound @ dotnet.native.8.0.8.93i67mqfmb.js:8
kr @ invoke-cs.ts:273
l.javaScriptExports.complete_task @ managed-exports.ts:142
(anonymous) @ marshal-to-cs.ts:335
Promise.then
mo @ marshal-to-cs.ts:329
(anonymous) @ marshal-to-cs.ts:83
(anonymous) @ invoke-js.ts:236
Ll @ invoke-js.ts:276
$func349 @ 00b21c96:0x1f99d
$func245 @ 00b21c96:0x1be41
$func238 @ 00b21c96:0xf00e
$func272 @ 00b21c96:0x1d05f
$func3186 @ 00b21c96:0xe873e
$func2506 @ 00b21c96:0xbe4b2
$func2512 @ 00b21c96:0xbecd6
$func2536 @ 00b21c96:0xc132d
$mono_wasm_invoke_method_bound @ 00b21c96:0xa4fb
Module._mono_wasm_invoke_method_bound @ dotnet.native.8.0.8.93i67mqfmb.js:8
kr @ invoke-cs.ts:273
(anonymous) @ invoke-cs.ts:247
beginInvokeDotNetFromJS @ blazor.webassembly.js:1
invokeDotNetMethodAsync @ blazor.webassembly.js:1
invokeMethodAsync @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
N @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
invokeWhenHeapUnlocked @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
N @ blazor.webassembly.js:1
C @ blazor.webassembly.js:1
dispatchGlobalEventToAllElements @ blazor.webassembly.js:1
onGlobalEvent @ blazor.webassembly.js:1
VM11 xpower.js:1728 emscgT��
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: An exception occurred executing JS interop: The JSON value could not be converted to System.Double. Path: $ | LineNumber: 0 | BytePositionInLine: 4.. See InnerException for more details.
Microsoft.JSInterop.JSException: An exception occurred executing JS interop: The JSON value could not be converted to System.Double. Path: $ | LineNumber: 0 | BytePositionInLine: 4.. See InnerException for more details.
---> System.Text.Json.JsonException: The JSON value could not be converted to System.Double. Path: $ | LineNumber: 0 | BytePositionInLine: 4.
---> System.InvalidOperationException: Cannot get the value of a token type 'Null' as a number.
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedNumber(JsonTokenType tokenType)
at System.Text.Json.Utf8JsonReader.TryGetDouble(Double& value)
at System.Text.Json.Utf8JsonReader.GetDouble()
at System.Text.Json.Serialization.Converters.DoubleConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
at System.Text.Json.Serialization.JsonConverter`1[[System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, Double& value, Boolean& isPopulatedValue)
at System.Text.Json.Serialization.JsonConverter`1[[System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter`1[[System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1[[System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Deserialize(Utf8JsonReader& reader, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1[[System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].DeserializeAsObject(Utf8JsonReader& reader, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadAsObject(Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize(Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
at Microsoft.JSInterop.JSRuntime.EndInvokeJS(Int64 taskId, Boolean succeeded, Utf8JsonReader& jsonReader)
--- End of inner exception stack trace ---
Many thanks for your help.
Regards
Reid. On Friday 20 September 2024 at 19:54:53 BST, Sam Clegg ***@***.***> wrote:
cwrap works like call but it doesn't take the actual arguments, it just takes tree params: 1) Function name, 2) return type, 3) array of param types.
cwrap then returns a function pointr which you pass you arguments too.
also, note that the 'array' type supported by ccall/cwrap only supports byte arrays.. if you want the C code to receive an array of anyting by bytes I don't think you can use that.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
forgotten to include the emcc command line:
$ emcc xpower.cc -o xpower.js -s NO_EXIT_RUNTIME=1 -s "EXPORTED_RUNTIME_METHODS=['ccall','cwrap']" -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE='$cwrap,$ccall,$stringToNewUTF8' -O0
have a nice weekend.
regards
Reid. On Saturday 21 September 2024 at 12:38:07 BST, REID A. ***@***.***> wrote:
Hi Sam,
thanks for your help.
so I went for ccall, as it supports passing string as I understood for the documentation . I changed my function so that it takes input inform of: char* input . I am still stuck although fee getting closer :). I think would help many if theres a nice example how to work with a string being passed as a param also having the function returning a string.
so this is what I done:
the params I serialised into a string: (the consol.log)
{"flattenedG":[1.0000000149999999E-07,0.0,0.0,0.0017381669037459457],"g0":[-0.0,-0.0],"flattenedCE":[1.0,1.0],"ce0":[0.0],"flattenedCI":[0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,-1.0,0.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,0.0,1.0,0.0,-1.0],"ci0":[-0.0,1.0,-0.0,1.0,-0.0,1.0,1.0,-0.0,-1.0,1.0],"x":[0.0,0.0],"d1G":2,"d2G":2,"dg0":2,"d1CE":2,"d2CE":1,"dce0":1,"d1CI":2,"d2CI":10,"dci0":10,"dx":2}
then I call: var data = stringToNewUTF8(params). where stringToNewUTF8 I exported in the EMCC command line. when I do console.log(data) I get:
89768
the function call is:
var ptrF = Module.ccall('xpower, null, paramTypes,data);
throws the following error:
Invalid UTF-8 leading byte 0xfffffffe encountered when deserializing a UTF-8 string in wasm memory to a JS string!
inside xpower I am displaying to std::cout the the input (the param in the procedure): what I see is: emscgT��
EXTERN EMSCRIPTEN_KEEPALIVE void xpower(char* input)
{
std::cout << input << std::endl;
}
The full jvscript code:
function callXpower(params) {
var paramTypes = ['string'];
console.log(params);
var data = stringToNewUTF8(params);
console.log(data);
var ptrF = Module.ccall('xpower', null, paramTypes,data);
}
where params is the json serialised string.
the full log:
{"flattenedG":[1.0000000149999999E-07,0.0,0.0,0.0017381669037459457],"g0":[-0.0,-0.0],"flattenedCE":[1.0,1.0],"ce0":[0.0],"flattenedCI":[0.0,0.0,0.0,0.0,0.0,0.0,1.0,0.0,-1.0,0.0,1.0,-1.0,1.0,-1.0,1.0,-1.0,0.0,1.0,0.0,-1.0],"ci0":[-0.0,1.0,-0.0,1.0,-0.0,1.0,1.0,-0.0,-1.0,1.0],"x":[0.0,0.0],"d1G":2,"d2G":2,"dg0":2,"d1CE":2,"d2CE":1,"dce0":1,"d1CI":2,"d2CI":10,"dci0":10,"dx":2}
VM17:31 89768
VM11 xpower.js:1199 Invalid UTF-8 leading byte 0xfffffffe encountered when deserializing a UTF-8 string in wasm memory to a JS string!
warnOnce @ VM11 xpower.js:1199
UTF8ArrayToString @ VM11 xpower.js:1031
put_char @ VM11 xpower.js:1728
write @ VM11 xpower.js:1711
write @ VM11 xpower.js:3367
doWritev @ VM11 xpower.js:4083
_fd_write @ VM11 xpower.js:4101
$func197 @ xpower.wasm:0x10f20
$func217 @ xpower.wasm:0x1158e
$func218 @ xpower.wasm:0x115f3
$func626 @ xpower.wasm:0x1544b
$func625 @ xpower.wasm:0x15360
$func273 @ xpower.wasm:0x11ca0
$func301 @ xpower.wasm:0x1222e
$func303 @ xpower.wasm:0x12280
$func14 @ xpower.wasm:0x115b
$func15 @ xpower.wasm:0x11bd
$xpower @ xpower.wasm:0x1b2b
(anonymous) @ VM11 xpower.js:603
ccall @ dotnet.native.8.0.8.93i67mqfmb.js:8
callSolve @ VM17:35
(anonymous) @ blazor.webassembly.js:1
beginInvokeJSFromDotNet @ blazor.webassembly.js:1
vn @ blazor.webassembly.js:1
(anonymous) @ invoke-js.ts:233
Ll @ invoke-js.ts:276
$func349 @ 00b21c96:0x1f99d
$func245 @ 00b21c96:0x1be41
$func238 @ 00b21c96:0xf00e
$func272 @ 00b21c96:0x1d05f
$func3186 @ 00b21c96:0xe873e
$func2506 @ 00b21c96:0xbe4b2
$func2512 @ 00b21c96:0xbecd6
$func2536 @ 00b21c96:0xc132d
$mono_wasm_invoke_method_bound @ 00b21c96:0xa4fb
Module._mono_wasm_invoke_method_bound @ dotnet.native.8.0.8.93i67mqfmb.js:8
kr @ invoke-cs.ts:273
l.javaScriptExports.complete_task @ managed-exports.ts:142
(anonymous) @ marshal-to-cs.ts:335
Promise.then
mo @ marshal-to-cs.ts:329
(anonymous) @ marshal-to-cs.ts:83
(anonymous) @ invoke-js.ts:177
Ll @ invoke-js.ts:276
$func349 @ 00b21c96:0x1f99d
$func245 @ 00b21c96:0x1be41
$func238 @ 00b21c96:0xf00e
$func272 @ 00b21c96:0x1d05f
$func3186 @ 00b21c96:0xe873e
$func2506 @ 00b21c96:0xbe4b2
$func2512 @ 00b21c96:0xbecd6
$func2536 @ 00b21c96:0xc132d
$mono_wasm_invoke_method_bound @ 00b21c96:0xa4fb
Module._mono_wasm_invoke_method_bound @ dotnet.native.8.0.8.93i67mqfmb.js:8
kr @ invoke-cs.ts:273
l.javaScriptExports.complete_task @ managed-exports.ts:142
(anonymous) @ marshal-to-cs.ts:335
Promise.then
mo @ marshal-to-cs.ts:329
(anonymous) @ marshal-to-cs.ts:83
(anonymous) @ invoke-js.ts:236
Ll @ invoke-js.ts:276
$func349 @ 00b21c96:0x1f99d
$func245 @ 00b21c96:0x1be41
$func238 @ 00b21c96:0xf00e
$func272 @ 00b21c96:0x1d05f
$func3186 @ 00b21c96:0xe873e
$func2506 @ 00b21c96:0xbe4b2
$func2512 @ 00b21c96:0xbecd6
$func2536 @ 00b21c96:0xc132d
$mono_wasm_invoke_method_bound @ 00b21c96:0xa4fb
Module._mono_wasm_invoke_method_bound @ dotnet.native.8.0.8.93i67mqfmb.js:8
kr @ invoke-cs.ts:273
(anonymous) @ invoke-cs.ts:247
beginInvokeDotNetFromJS @ blazor.webassembly.js:1
invokeDotNetMethodAsync @ blazor.webassembly.js:1
invokeMethodAsync @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
N @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
invokeWhenHeapUnlocked @ blazor.webassembly.js:1
(anonymous) @ blazor.webassembly.js:1
N @ blazor.webassembly.js:1
C @ blazor.webassembly.js:1
dispatchGlobalEventToAllElements @ blazor.webassembly.js:1
onGlobalEvent @ blazor.webassembly.js:1
VM11 xpower.js:1728 emscgT��
blazor.webassembly.js:1 crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: An exception occurred executing JS interop: The JSON value could not be converted to System.Double. Path: $ | LineNumber: 0 | BytePositionInLine: 4.. See InnerException for more details.
Microsoft.JSInterop.JSException: An exception occurred executing JS interop: The JSON value could not be converted to System.Double. Path: $ | LineNumber: 0 | BytePositionInLine: 4.. See InnerException for more details.
---> System.Text.Json.JsonException: The JSON value could not be converted to System.Double. Path: $ | LineNumber: 0 | BytePositionInLine: 4.
---> System.InvalidOperationException: Cannot get the value of a token type 'Null' as a number.
at System.Text.Json.ThrowHelper.ThrowInvalidOperationException_ExpectedNumber(JsonTokenType tokenType)
at System.Text.Json.Utf8JsonReader.TryGetDouble(Double& value)
at System.Text.Json.Utf8JsonReader.GetDouble()
at System.Text.Json.Serialization.Converters.DoubleConverter.Read(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options)
at System.Text.Json.Serialization.JsonConverter`1[[System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].TryRead(Utf8JsonReader& reader, Type typeToConvert, JsonSerializerOptions options, ReadStack& state, Double& value, Boolean& isPopulatedValue)
at System.Text.Json.Serialization.JsonConverter`1[[System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
--- End of inner exception stack trace ---
at System.Text.Json.ThrowHelper.ReThrowWithPath(ReadStack& state, Utf8JsonReader& reader, Exception ex)
at System.Text.Json.Serialization.JsonConverter`1[[System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ReadCore(Utf8JsonReader& reader, JsonSerializerOptions options, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1[[System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].Deserialize(Utf8JsonReader& reader, ReadStack& state)
at System.Text.Json.Serialization.Metadata.JsonTypeInfo`1[[System.Double, System.Private.CoreLib, Version=8.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].DeserializeAsObject(Utf8JsonReader& reader, ReadStack& state)
at System.Text.Json.JsonSerializer.ReadAsObject(Utf8JsonReader& reader, JsonTypeInfo jsonTypeInfo)
at System.Text.Json.JsonSerializer.Deserialize(Utf8JsonReader& reader, Type returnType, JsonSerializerOptions options)
at Microsoft.JSInterop.JSRuntime.EndInvokeJS(Int64 taskId, Boolean succeeded, Utf8JsonReader& jsonReader)
--- End of inner exception stack trace ---
Many thanks for your help.
Regards
Reid. On Friday 20 September 2024 at 19:54:53 BST, Sam Clegg ***@***.***> wrote:
cwrap works like call but it doesn't take the actual arguments, it just takes tree params: 1) Function name, 2) return type, 3) array of param types.
cwrap then returns a function pointr which you pass you arguments too.
also, note that the 'array' type supported by ccall/cwrap only supports byte arrays.. if you want the C code to receive an array of anyting by bytes I don't think you can use that.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
I had a C++ project that I used to build using a makelist.txt file. The project has Array.hh MyLib++.hh MyLib++.cc . All three modules are defined within the same namespace. In blazor webassembly, in the server side c# dlls I want to call the function xpower which is found in MyLib.
I have tried with many options but no luck. The await _jsRuntime.InvokeAsync("_xpower",...) returns runtime error (visible in the console) with reason _xpower undefined. using Typeof Module._xpower returns undefined too.
thanks.
The text was updated successfully, but these errors were encountered: