Replies: 2 comments 2 replies
-
It depends on how the chromium process model allocated render processes. CEF only a has a single thread per render process that we can evaluate JavaScript on. https://github.com/chromiumembedded/cef/blob/77466e7b6d4de25c534dd3b2ccfcd663b64b6879/include/internal/cef_types.h#L1481
How many render processes are actually running? A new RequestContext per ChromiumWebBrowser instance should ensure a new render process is allocated regardless of the websites origin.
Specifying a timeout doesn't actually cancel execution on the running JavaScript. It just cancels the .Net task. CEF doesn't provide a direct means to cancel a running script. You'll need to switch over to using the DevTools protocol for an actual timeout. https://chromedevtools.github.io/devtools-protocol/tot/Runtime/#method-evaluate Timeout is listed as experimental from a chromium point of view and I've not tested to see how it behaves. |
Beta Was this translation helpful? Give feedback.
-
Thanks @amaitland, for detailed answer, something become more clear :) But the mentioned on Wiki-GeneralUsage page methods still don't help to catch the point where I can start executing javascript without crahishing. I try to explain. As mentioned earlier, in some cases running javaScript in the cefSharp offScreen browser causes the execution to hang on EvaluateScriptAsync.
Apparently this happens because when you click on a link on the html page with a timeout of about 2.5 seconds, the loop starts checking that the page with a different URL has successfully loaded. This is checked precisely by executing javaScript. The timeout interruption in this method prevents the javaScript from being executed again after a period of time. Initially, there was another condition:
But as we found, There are also the events Is there some universal method that would allow you to be sure javaScript executes without the CefSharp browser's offScreen instance freezing and coming to naught? P.S. We use CefShearp OffScreen v. 75.1.140-CI{build}. Oldschool, do not laugh)) |
Beta Was this translation helpful? Give feedback.
-
Hi, Everyone!
Can anyone enlighten the following question?
How is javaScript executed in multiple instances of the offScreen browser, sequentially or in parallel(asynchronously)?
The story is not about how different javascripts are executed in one browser instance, it's about whether CefSharp javaScript can be executed in different offScreen browser instances independently of other scripts executed in other browser instances in the same running C# application instance at all.
We have faced the fact that in our application, when the number of browser instances increases to 70-100 and javaScript is executed quite intensively without timeout auto-completion, scripts start to run for minutes, as if they were in some queue. If you put timeout for execution of one javascript, in our case it is 5 seconds, then at some point they start to run in bulk, which causes the number of simultaneously working browser instances to drop, after which the execution of javascript starts to fit into the allotted timeout of 5 seconds.
For example, I can't figure out where the synchronous action is and how to avoid it. I perform this action in separate browser threads
But it seems to queue up somethere inside EvaluateScriptAsync.
Beta Was this translation helpful? Give feedback.
All reactions