Javascript blocking execution and shutdown #4496
Replies: 3 comments
-
If you are new to the project then please make sure to read the first few paragraphs of https://github.com/cefsharp/CefSharp/wiki/General-Usage
Try asking on https://www.magpcss.org/ceforum/index.php to see if there's a way for I suspect that |
Beta Was this translation helpful? Give feedback.
-
I have only done a simple test on this, but you can close the browsersubprocess, without having to shutdown CEF. |
Beta Was this translation helpful? Give feedback.
-
I was interested in this for our project, so did some work on it. You'll need to get the ProcessId from javascript, before the page loads: Private ProcessId As Integer
Private Sub Browser_FrameLoadStart(sender As Object, e As FrameLoadStartEventArgs) Handles Browser.FrameLoadStart
If e.Frame.IsMain Then
e.Frame.ExecuteScriptAsync("CefSharp.PostMessage(CefSharp.RenderProcessId)")
End If
End Sub
' Get the ProcessId
Sub Browser_JavascriptMessageReceived(sender As Object, e As JavascriptMessageReceivedEventArgs) Handles Browser.JavascriptMessageReceived
ProcessId = e.Message
End Sub
Sub TerminateRenderProcess()
If ProcessId Then
Process.GetProcessById(ProcessId).Kill()
End If
End Sub |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there an existing issue for this?
CefSharp Version
112.3.0
Operating System
Windows 10
Architecture
x64
.Net Version
.Net 4.7.2
Implementation
WinForms
Reproduction Steps
Go to Cefsharp.Offscreen.Example and replace TestUrlOne with "hxxps://meme-of-the-day-one[.]vercel[.]app/api/MemeOfTheDay" ("xx"s and brackets added so you don't accidentally navigate to this url). It's kind of malicious in that it tries to use up all your computer's memory.
Expected behavior
I would like to be able to navigate to this site, finish processing after some time (even if I had to set a timeout) and shut cef down.
Actual behavior
The javascript loop keeps running in the background, and in my application I end up calling
Cef.Shutdown()
and hanging bc that javascript is running. I have tried callingm_browser.Stop();
andvar browser = webBrowser.GetBrowser(); browser.StopLoad();
, but neither of those stops the javascript loop.Basically, I cannot find a way to programmatically shut cef down instead of hanging infinitely.
Regression?
I don't think so. My application is running on an older version, and that's where I discovered this problem. I tried using Cefsharp.Offscreen.Example (newest version) to repro and that succeeded; so I don't think it's unique to a recent version of CefSharp.
Known Workarounds
none
Does this problem also occur in the CEF Sample Application
Yes using WPF/OffScreen command line args
Other information
Sorry if this isn't the right place for this question. I have searched the internet and asked chatgpt and found no results. This is significantly hurting our cloud app so I figured I'd reach out. If it's not the right place please let me know where I should be asking this :)
Beta Was this translation helpful? Give feedback.
All reactions