-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
wasm InvokeJS return value is broken #61192
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to 'arch-wasm': @lewing Issue DetailsDescriptionThe transition to using a custom closure instead of eval broke the return value of InvokeJS. Reproduction Steps var res = Interop.Runtime.InvokeJS(@"1 + 2", out int exceptionalResult);
if (exceptionalResult != 0)
throw new Exception("InvokeJS failed " + res);
else if (res != "3")
throw new Exception("InvokeJS returned invalid result " + res); Expected behaviorDoesn't throw Actual behaviorThrows, exception message indicates there was no return value Regression?Yes Known WorkaroundsIf you put 'return' in the JS expression it may work ConfigurationNo response Other informationNo response
|
cc @pavelsavara The ideal would be for us to figure out that we need to insert a 'return' keyword somehow, but I'm not sure there's any obviously correct way to do that. |
The new version of InvokeJS appears to also be considerably slower than the old one (~2x slower for a simple test), according to my benchmarks. While I would hope no one is relying on it to have high performance, it's worth trying to figure out whether we can accept the hit (and whether it's potentially much worse in Firefox or Safari, since I've only run these benchmarks in v8.) |
Is slower speed of micro-benchmark caused by the fact that I don't have any good idea how to make |
Interop.Runtime.InvokeJS("var a = 5;");
...
var a = Interop.Runtime.InvokeJS("a");
This is actually not true. It works this way only when the eval is executed from global scope (not within a function). |
The original implementation was essentially EM_ASM_INT
|
The api is still private so we can definitely still discuss what the right course of action is. |
Description
The transition to using a custom closure instead of eval broke the return value of InvokeJS.
Reproduction Steps
Expected behavior
Doesn't throw
Actual behavior
Throws, exception message indicates there was no return value
Regression?
Yes
Known Workarounds
If you put 'return' in the JS expression it may work
Configuration
No response
Other information
No response
The text was updated successfully, but these errors were encountered: