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
Javascript Binding Ready For Testing #480
Comments
Hi amaitland, I'm just going to test this, because I exactly need this functionality: Javascript Binding in a x64 Chromium. One little question: CefSharp3 now is multiprocess. When Javascript calls my C# function, in witch thread this will happen? In the main or in the worker (Render or Javascript) thread? What will I have to do, if this call happens in the worker thread and I need a call to the main thread from here? I'm new to threads. |
@tomtorell As for Threading it in itself is a broad and complex subject, so without knowing exactly what your trying to achieve I can't really provide to much detailed information. My suggestion would be to go through the |
@amaitland in the first start-up Javascript Binding was successful for me. I now can call my C# functions from Javascript e.g. in the form callbackhandler.myFunction(...). To answer my own question from above, yes myFunction is called in a worker thread, not in the main thread! So you have to be careful, if the task that should be done in myFunction can run in a worker thread. In some functions, I call a really big library and this is invalid in a worker thread. In these cases, I have to call my main thread first, otherwise my application crashes! This has changed compared to CefSharp1. So far Javascript is working now, but I found a serious problem: I have a function with this signature: void myFunction(double, double, double, double); It is called continuously. While it is called continuously the memory of Browser.Subprocess.exe is rising all the time (could this be a memory leak?) and approximately after 800 calls, Browser.Subprocess.exe dies and crashes one minute later! Did you try to call a function like above for 1000 times in a loop till yet? The result would be very helpful for me. |
Possibly a memory leak. What scenario requires a method to be called over 800 times? It'll be awhile before I get time to look at this so feel free to investigate further on your own. |
@tomtorell Thinking about your problem some more, and I'm not quite sure how to debug your issue, the fact that it's successful for at least a few hundred calls makes for a tricky debugging scenario. I had a quick check and the version of Are you able to modify one of the samples? If you can provide a close to real world example of your problem then that's a start. (Better than just calling a method in a loop, which is likely to cause a problem, though may not accurately reproduce your issue). As an alternate solution, are you able to batch up your calls to reduce the number? |
Cc #310, since that's the PR for the WIP branch. |
@perlun actually I'm debugging a little bit this issue. It persists for me even in the CefSharp.WinForms.Example: If I do 800 Javascript calls to "bound.repeat("hi ", 5)" in the BindingTest.html the CefSharp.BrowserSubprocess.exe crashes. |
@amaitland I'm using the Javascript Binding in an interactive Web-Application witch consumes user input. After some time, the user reaches the amount of 800 calls to my C# functions. Unfortunately it is quite difficult to provide a real world example. But I was able to reproduce the problem very easily: I modified the BindingTest.html of CefSharp.WinForms.Example of the WIP branch to call "bound.repeat("hi ", 5)" 800 times in a loop. After 800 calls the CefSharp.BrowserSubprocess.exe crashes. This is exactly the count of calls, I can do in my application. See the modified BindingTest.html in the attachment. I also debugged a little bit, but could not found the reason for the crash. (I'm absolutely new to this project.) I modified JavascriptMethodHandler.h of ...Subprocess.core a little bit, so I can count the number of calls coming in, setting a conditional breakpoint (ii = 799) to stop after 799 calls. The process crashes after the method Execute() returns. By the way: I think, directly before the "return true;" of method Execute() a "delete response;" is missing? The modified file JavascriptMethodHandler.h is attached also. |
@tomtorell Thanks for the feedback, I'm sure there are at least a few places that need some additional cleanup code added. |
@amaitland Could you reproduce the problem? Regards, Tom |
@tomtorell I can successfully reproduce your issue, unfortunately as it just crashes I've got no idea as to what's causing it. We're currently in the processing of upgrading to a newer version of Is there no way around this? Batch your calls together to reduce the number? Another option could be using a custom schema handler to implement
https://code.google.com/p/chromiumembedded/wiki/Architecture |
@tomtorell It may also be worth opening a separate issue for this bug so that it doesn't get lost |
@amaitland ok, I saw it crashing, when the method Execute() returns. Unfortunately I was not able to debug behind this point. I think it is the code of the cef library itself when you leave Execute(), and till yet I did not download the code of it. I think this problem should be caused by any resources (memory or handles ...), that are not freed. May be in two weeks, I can spend a little more time on this issue. |
FYI |
My tiny bit of first time user experience so far as posted to the Google Group 👯 |
The first https://www.nuget.org/packages/CefSharp.WinForms/33.1.0-pre01 If you do find any bugs please provide detailed feedback including:
|
Great work @amaitland! 👏 However, why 33.1.0-pre01, has there ever been a 33.0.0? 😄 Also, I think that Just my 0.02€ of course. 😛 |
Hey @perlun, As per #496 (comment) we decided to release a The tag is here https://github.com/cefsharp/CefSharp/releases/tag/v33.0.0
Correct 😄 I'm hopeful we won't have more than 9 pre release versions, though I figured adding an extra |
@perlun see https://github.com/cefsharp/CefSharp#nuget-packages for my meek attempt at a 10.000 foot picture. Hope it suits your benevolent taste 😉 For a few moments I started regretting that I had added those http://shields.io badges - they suddenly turned up with missing images - but when it failed response with a fix https://twitter.com/Shields_io/status/520581905084088320 turned out to be quick. |
Yep. I don't think it's an issue in |
Sure, that would be great, thanks! |
There you go :) #566 |
Awesome, thanks! 👍 |
@tomtorell If you check out #589 it should hopefully resolve your issue. |
@amaitland thank's a lot for that information! The last weeks I had a lot of work in an other project so actually I'm not up to date with the status of the java script binding. But this issue is still very importand to us, so I'll check out and test the #589. Was some of the CefSharp developers able to reproduce and correct the 800-call-problem? |
@tomtorell latest status is that JS Binding as of today has been merged into Back story: The good news is that it looks like @sylvain-hamel and you are getting bitten by the same issue, that it looks like he found the root cause AND already has a proposed fix 👍 which he just updated to apply to |
@jornh great! I'll download, compile and test the fixed JS-Binding tomorrow. Afterwards I'll report here about the result. |
Hi, I've downloaded the master branch form today, made the test I described in this thread above (09/23/2014) and it is stable now. I extended the test to the extreme number of half a million calls, witch consumes a CPU time of approximately three minutes, and even this heavy duty test is working fine! This amount of calls is pretty much more than I expect, any user will achieve in an interactive session. So, this issue is fixed. Thank you all for your help! |
Preeetty nice confirmation to get for #590 😄 and that we did right in merging JS-Binding to |
Hey @amaitland , |
@vivekcoer For the past few months my app has been using AJAX calls with custom schemes to talk to C#. I also use AJAX long-polling requests where the response callback is fired a long time later in another thread. No problems at all. |
Thanks @jankurianski ! What I am wondering is, if this was that easy, why did I everywhere see that asynchronous call backs along with JS closure are NOT possible using CEFSHARP? And that is why I am asking it here to make sure if I am doing everything right! What was the catch? Finally, I have a base JS application which has tons of JS resources - do I need to have a custom scheme handler for all of them (combined or individually)? Or else may be I can directly use ///file protocol - if yes, how? Especially without any crossdomain/crossapp issues. Thanks |
If you require I had a look at your code, I'd personally be using
What reference are you quoting?
Using |
Thanks a lot @amaitland ! Embedding the JS files as resources sounds good. One question, I should be able to debug the javascript in those files using chrome debugger tools - right? But for some reason in WPF example project I don't see the menu option to see the developer tools (however in WinForms example project I see that) - has that been omitted on purpose or is there a way to see dev tools in WPF example too? I am sorry but I am fairly new to Chromium/CEFSHARP. Thanks |
Nobody has got around to implementing it yet. Feature exists in both. All https://github.com/cefsharp/CefSharp/blob/master/CefSharp/IWebBrowser.cs#L296 |
Thanks @amaitland ! |
Hello @amaitland @jankurianski @perlun Suspecting that it might be a cross domain issue I added CORS headers as below too (as below) but that didnt help either. I added CORS headers - "Access-Control-Allow-Origin: https://***.com, Access-Control-Allow-Credentials: true" Everything works fine in chrome browser with the same local files (with an added command line switch --disable-web-security). please could you help me figuring out what is going wrong here? |
@vivekcoer As this is unrelated to |
For those of you interested in Javascript Binding, I'm fairly happy with the performance and stability of https://github.com/cefsharp/CefSharp/tree/JsBinding_WIP
If your at all interested in seeing this feature in
CefSharp3
please download and build theJsBinding_WIP
branch and test it with your application.Cef.RegisterJsObject
has been removed, for now you have to bind using the method directly onChromiumWebBrowser
, will look at re-adding that feature laterEvaluateScriptAsync
now returns aTask<JavascriptResponse>
so errors can be correctly returned from the render processbound.subObject.myFunction()
andbound.subObject.myProperty = 1
Feedback required!
P.S. I'm fairly new to
c++
so if you do happen to go through the code and see some mistakes, if you could provide constructive feedback that would also be welcome! 😄The text was updated successfully, but these errors were encountered: