-
Notifications
You must be signed in to change notification settings - Fork 154
Pass JavaScript functions to C# #38
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
Conversation
|
Looks good, though there are conflicts that prevent it being merged. Have you been working form the latest source? Also, regarding the crash in debugging, did that affect you before your changes, or only afterwards? |
|
Hm, I initially merged with the latest master...I went ahead and rebased onto master cleaning up the initial commits, so the merge should hopefully work now. |
| { | ||
| if(mFuncHandle) | ||
| { | ||
| JavascriptScope scope(mContext); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regarding the access violation exception: It only occurs if the new JavascriptFunction object is used, either in the Fiddling project, or in the new unit tests - though there you only see the exception when debugging. We suspect that the GC calls the finalizer after the JavascriptContext has been destructed leading to a crash here. Is the JavascriptScope necessary? What does it do exactly? I just took it from the old branch.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should not be calling or otherwise accessing any v8 object after the context has been destroyed, because they will probably have been disposed by v8 and their memory freed. I think you have these options:
- Don't do anything in the JavascriptFunction destructor, and allow mFuncHandle to be cleaned up when v8 is cleaned up. (And document the memory leak somewhere.)
- Set a flag in JavascriptContext when it is disposed, which prevent JavascriptFunction from doing anything in its destructor when that flag is set. This is obviously better because it won't leak memory, but is more complicated.
|
I added a flag as you suggested and the exceptions are gone now. Let me know if this is OK with you! Thanks! |
|
Looks good to me. Thanks. |
Hi,
we need to pass references to JavaScript functions to C# and call them from there. So I went ahead and merged the branch
jsfuncwith the currentmaster, replaced deprecated V8 API calls and added some more tests.I'm totally new to the V8 API, so could you please review my changes? Also, while debugging the tests I found that I get an
Access violationexception while disposing the context. The tests are green though. Any advice on that?The exception is raised in line 8913 of
v8.hthe callstack being
I don't think I can change the existing pull request so I opened a new one.
Thanks!