they dont show up if using EvaluateScriptAsync - but they do show up if explicitly calling from devtools console - can i do something there?
@holger-prause Already asked at https://github.com/cefsharp/CefSharp/discussions/3900
Please just ask your question once and wait for a reply, thanks.
if anyone else ran into an issue, where opening dev tools and then closing the main window makes the dev tools freeze and never close
good thing is it's only happening while debugging
@chylex MinimalExample
looks fine to me. Are you using WinForms
or WPF
? What do you mean by
What do you mean by debugging? VS
has a breakpoint hit and your stepping through code?
can not work for the autofocused text input
@will8372 What exactly is autofocused text input
? In WPF
you can control the focus using https://docs.microsoft.com/en-us/dotnet/api/system.windows.input.focusmanager.focusedelement?view=windowsdesktop-6.0
The MinimalExample
has been updated so the browser now has focus by default. cefsharp/CefSharp.MinimalExample@d752b58
do you have any tips for debugging the subprocess libraries?
@chylex Same as Chromium
. See https://www.chromium.org/developers/how-tos/debugging-on-windows#TOC-Manually-attaching-to-a-child-process
You can uncomment https://github.com/cefsharp/CefSharp/blob/master/CefSharp.Example/CefExample.cs#L85
seems like extraInfo is null for some reason
Do you have an actual stack trace?
What do you mean by debugging?
Literally just running with a debugger attached, opening dev tools, and closing the main app window. No breakpoints. I guess some CEF/CefSharp configuration in my app is causing both this and the extension issue.
Do you have an actual stack trace?
Exception stack trace:
at CefSharp.BrowserSubprocess.CefAppUnmanagedWrapper.OnBrowserCreated(CefAppUnmanagedWrapper* , scoped_refptr<CefBrowser>* browser, scoped_refptr<CefDictionaryValue>* extraInfo) in C:\projects\cefsharp\CefSharp.BrowserSubprocess.Core\CefAppUnmanagedWrapper.cpp:line 69
at CefExecuteProcess(CefMainArgs* , scoped_refptr<CefApp>* , Void* )
at CefSharp.BrowserSubprocess.SubProcess.Run() in C:\projects\cefsharp\CefSharp.BrowserSubprocess.Core\SubProcess.h:line 57
at CefSharp.BrowserSubprocess.BrowserSubprocessExecutable.Main(IEnumerable`1 args, IRenderProcessHandler handler) in C:\projects\cefsharp\CefSharp.BrowserSubprocess.Core\BrowserSubprocessExecutable.h:line 150
at CefSharp.BrowserSubprocess.Program.Main(String[] args) in C:\projects\cefsharp\CefSharp.BrowserSubprocess\Program.cs:line 33
Call stack when attaching a debugger during the exception:
> CefSharp.BrowserSubprocess.Core.dll!CefSharp::BrowserSubprocess::CefAppUnmanagedWrapper::OnBrowserCreated(scoped_refptr<CefBrowser>* browser, scoped_refptr<CefDictionaryValue>* extraInfo) Line 69 C++
[Native to Managed Transition]
[Managed to Native Transition]
CefSharp.BrowserSubprocess.Core.dll!CefSharp::BrowserSubprocess::SubProcess::Run() Line 57 C++
CefSharp.BrowserSubprocess.Core.dll!CefSharp::BrowserSubprocess::BrowserSubprocessExecutable::Main(System::Collections::Generic::IEnumerable<System::String^>^ args, CefSharp::RenderProcess::IRenderProcessHandler^ handler) Line 150 C++
CefSharp.BrowserSubprocess.exe!CefSharp.BrowserSubprocess.Program.Main(string[] args) Line 37 C#
Literally just running with a debugger attached, opening dev tools, and closing the main app window.
@chylex Are you blocking devtools from closing using a LifeSpanHandler
?
But I got VS to show this, which is a bit more clear, but I still don't know where extraInfo came from in the call stack.
An NRE
makes me wonder if the stack trace is correct, extraInfo
isn't a managed object. I'd be expecting an access violation or similar.
If you add the following to before if (!browser->IsPopup())
does the problem go away?
if(!extraInfo.get())
{
return;
}
Are you blocking devtools from closing using a LifeSpanHandler?
My LifeSpanHandler returns false from DoClose for default behavior, but even then the method is never called. Gets stuck somewhere during Shutdown, might try to debug it later, it's not really a major issue since I can just kill the process.
If you add the following to before if (!browser->IsPopup()) does the problem go away?
It stopped the crash; the test extensions might not be fully compatible with implemented apis and they didn't do anything immediately visible on the website, but they seem to at least be calling some methods on the ExtensionHandler, so it might be ok
Happy new year!
I have a weird issue. I've been working like crazy to have some control on the redirection which Chromium doesn't handle that well. So now I can have full control of the response body of the redirection by cheating in requesting manually with HttpWebRequest upon detection of a redirection. And then repopulate the real body content with Browser.FocusedFrame.LoadHtml. The weird thing is that when I use GetResponseAsync() (async version) it states that the Browser has been already disposed when I reach that part.
However, if I do a synchronous call with GetResponse() it does work as intended.
When I did some troubleshooting it's really when the GetResponseAsync is called that Browser is disposed. It's kind of weird considering that both object should be completely independent...
@amaitland Why would it work when using HttpWebResponse.GetResponse() and don't when using HttpWebResponse.GetResponseAsync(). By working and not working, I mean that at the moment HttpWebResponse.GetResponseAsync() is executed it disposes the Browser object.
If that can help here's a subset of code:
1 var sendHttpRequestFromSpiRequestAction = new SendHttpRequestFromSpiRequestAction(_logger);
2 // TODO include timeout, referer and maximumredirection from settings
3 var responseRedirect = await sendHttpRequestFromSpiRequestAction.ExecuteAsync(new SendHttpRequestFromSpiRequestActionArgs(request, new TimeSpan(0, 0, 2).Milliseconds, doesFollowRedirection: false, MyParentInjectorForm.UseCookie, GetUserAgentValue(_logger), RefererTypes.NoOverwrite));
4
5 if (responseRedirect.Content is not null)
6 response.Content = responseRedirect.Content;
7 else
8 response.Content = $"<html><head><title>SQL Power Injector customized response redirection</title></head><body><h1>Page has been redirected</h1><h2>Original response didn't have response body so SQL Power Injector provided this one</h2><p>Request Url: {requestUrl}</p><p>Redirect to: {response.ResponseHeaderList.Headers.First(h => h.Name.Equals("Location", StringComparison.OrdinalIgnoreCase)).Value}</p></body></html>";
10
11 args.Browser.FocusedFrame.LoadHtml(response.Content);
On line 3 I call Action that will make the HttpWebResponse.GetResponse() (see below) and once I reach the line 11 I get an exception stating that Browser has been already disposed.
```using (var httpWebResponse = httpWebRequest.GetResponseAsync() as HttpWebResponse)```