Anyone knows if it's possible to identify which iframe elements in the main frame correspond to which CEF frame? These are sites which I have no control over, so I cannot set a name on the iframe HTML, and calling
setAttribute('name', 'something')
on the iframe seems to have no effect on CEF's frame name. So basically I have a list of iframes on the main frame's javascript site I get likedocument.querySelectorAll('iframe')
, and another list on the C# site I get by callingbrowser.GetFrameIdentifiers().Select(id => browser.GetFrame(id))
, and they both have the same number of frames, but I have no idea which one correspond to which one on the other side.
In case anyone else has this question, here is what I'm doing now. If someone has a better solution that'd be awesome since this feels a little hacky:
public static async Task<IFrame> GetFrame(this IFrame parent, string getFrameScript)
{
string prevName = "___e2XuTklANdkaRTav";
await parent.EvaluateScriptAsync($"window.{prevName} = document.activeElement; ({getFrameScript})?.focus();");
await Task.Delay(1); // This is needed to wait for the frame to actually gain focus
var frame = parent.Browser?.FocusedFrame ?? parent;
await parent.EvaluateScriptAsync($"document.activeElement instanceof HTMLElement && document.activeElement.blur(); window.{prevName} instanceof HTMLElement && window.{prevName}.focus(); delete window.{prevName}");
return frame;
}
We are referencing CefSharp dlls as shown above in csproj.
Moreover, we don't see these two dlls in the previous version 94.4.2.
How do we enable permission api for clipboard access : https://googlechrome.github.io/samples/async-clipboard/.
@angshuman-agarwal
CEF
doesn't provide anAPI
for handling those permissions requests. https://bitbucket.org/chromiumembedded/cef/issues/2921/add-support-for-asynchronous-clipboard-apiIt's possible you might be able to use
DevTools
to set the permissions.
Hi,
Thanks. IS it possible to point to some sample / documentation around this please ?
@amaitland If I use the CefSharp data parameter -use-gl=angle and GL content is being rendered on the web pages in that case these vulkan-1.dll and vk_swiftshaer.dll will be required right? Please correct me on this.
This is how I understood based on the explanation at https://bitbucket.org/chromiumembedded/cef/issues/3176/win-linux-ship-vk_swiftshaderdll-vulkan
I need to gather some metrics.
@kcwms You can use DevTools to profile the website, fix any javascript memory leaks etc.
https://developer.chrome.com/docs/devtools/memory-problems/#visualize_memory_leaks_with_timeline_recordings
https://developer.chrome.com/docs/devtools/memory-problems/#discover_detached_dom_tree_memory_leaks_with_heap_snapshots
Generally speaking I'd suggest that all 32bit
applications are made LargeAddressAware, you can probably do this as a post build step for your VB6
application.
https://github.com/cefsharp/CefSharp/wiki/General-Usage#win32-out-of-memory
https://codekabinett.com/rdumps.php?Lang=2&targetDoc=largeaddressaware-msaccess-exe
If I use the CefSharp data parameter -use-gl=angle and GL content is being rendered on the web pages
@chaitanyajun12 Under normal circumstances Chromium
will fallback to using SwANGLE
when hardware acceleration is unavailable. It's rare that you would manually need to force rendering to SwANGLE
. The older Swiftshader
implementation is being deprecated and at some point we'll stop shipping the dlls in the Swiftshader
folder.
SwANGLE support
Support for software rendering of HTML5 content like 2D canvas, 3D CSS and WebGL
For low end hardware/blacklisted GPUs etc you'll need SwANGLE
to render the HTML5
content.
I've updated https://github.com/cefsharp/CefSharp/wiki/Output-files-description-table-(Redistribution) to list the new files.
If you are deploying your application to a very specific set of hardware, e.g. only runs in a company laptop and they'll all the same model with support for hardware acceleration then you can probably skip deploying the files (after testing to confirm). If you are deploying to the general public then I'd recommend shipping the three files.
@amaitland, thanks for the explanation :)
One doubt I have is, when these dlls (vulkan-1 and vk_swiftshader) can be used during the fallback by CefSharp, why these dlls are not getting picked automatically in our final built folder.
Basically, we are referencing dlls as below,
@amaitland Got it. One more doubt I have is, how these dlls will be picked by Chromium Engine? Is this based on the flags we specify? --use-gl=angle?
As in internally, when the dependency is not there with CefSharp dlls, but still how will it use those dlls is something I dint understand. Could you elaborate on this? Thanks in advance.
I saw this link cefsharp/CefSharp#2497 and I see that they are supported. But, the Chrome extension which we want to open in CefSharp, it has to be loaded via code or just placing the extension specific files in some path will help us load the extension in our CefSharp app.
Could you share any documentation around this?
One more doubt I have is, how these dlls will be picked by Chromium Engine?
@chaitanyajun12 They are loaded by Chromium
at runtime. If your GPU
appears on the Blocklist for instance or if you are running a Virtual Machine
or Server
with poor GPU
specifications.
Is this based on the flags we specify? --use-gl=angle?
You can force Chromium
to use software rendering, this is not generally required and only if you are experiencing problems with a specific hardware/software configuration.
when the dependency is not there with CefSharp dlls
They are unmanaged
dlls which are runtime dependencies, they're not compile time dependencies, they're loaded dynamically if required. Most of the dependencies are runtime only, there are only typically three dlls required at compile time.
Are chrome extensions supported in CefSharp?
Support is very limited. Please make sure you've confirmed your extension only uses supported Extension API's
, it won't work otherwise.
But, the Chrome extension which we want to open in CefSharp, it has to be loaded via code or just placing the extension specific files in some path will help us load the extension in our CefSharp app.
Could you share any documentation around this?
The only documentation currently are as follows
I think CefSharf in my project not load favicon.ico. I loaded google.com in my WinForm project and I don't see favicon in Developer Tools. Why?
@galerts Have you implemented OnFaviconUrlChange and downloaded the favicon
? It's upto each application to implement favicon
support as you control the parent window.
Can someone help me?
@c2msis:matrix.org What is your question?
Hi guys, I've noted that on some pages ResourceRequestHandler.OnResourceLoadComplete
is never called for some requests. I tried this with the winforms example:
public class MyRequestHandler : RequestHandler
{
private readonly MyResourceHandler reqHandler = new MyResourceHandler();
protected override IResourceRequestHandler GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling)
{
return reqHandler;
}
}
public class MyResourceHandler : ResourceRequestHandler
{
protected override CefReturnValue OnBeforeResourceLoad(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback)
{
System.Diagnostics.Debug.WriteLine($"OnBeforeResourceLoad [{request.Identifier}]: {request.Url}");
return base.OnBeforeResourceLoad(chromiumWebBrowser, browser, frame, request, callback);
}
protected override void OnResourceLoadComplete(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response, UrlRequestStatus status, long receivedContentLength)
{
System.Diagnostics.Debug.WriteLine($"OnResourceLoadComplete [{request.Identifier}]: {request.Url}");
base.OnResourceLoadComplete(chromiumWebBrowser, browser, frame, request, response, status, receivedContentLength);
}
}
Then set it like this on BrowserTabUserControl.cs:
browser.RequestHandler = new MyRequestHandler();
And then I loaded this page: https://www.ticketmaster.co.uk/
I get a call to OnBeforeResourceLoad
with the URL https://www.ticketmaster.co.uk/api/cookies
and identifier 902363
, but never got a call to OnResourceLoadComplete
with the same identifier (nor the same URL). I understand OnResourceLoadComplete
should be called for all requests, so I wonder if this is a bug (probably unrelated to the one I mentioned before about browsers not being fully created sometimes).
OnResourceResponse
does get called. In fact, if you load the URL on a browser it's just an "OK" response on the body, so it should complete very quickly. If you look at the request on devtools, you see status 200 which means it completed, but the weird thing is that the Preview and Response tabs are empty, so it seems that Chrome did something strange with the response.
I get a call to OnBeforeResourceLoad with the URL https://www.ticketmaster.co.uk/api/cookies and identifier 902363, but never got a call to OnResourceLoadComplete with the same identifier (nor the same URL). I understand OnResourceLoadComplete should be called for all requests, so I wonder if this is a bug (probably unrelated to the one I mentioned before about browsers not being fully created sometimes).
@jsoldi I'd suggest moving the conversation over to https://magpcss.org/ceforum/index.php as the behaviour is entirely implemented in CEF/Chromium
.
It sounds like a bug to me, though the CEF
maintainer will hopefully be able to confirm.
hello what i would like to do is add a chrome extension to a cefsharp window is that possible?
@hawke0777 Already asked at https://github.com/cefsharp/CefSharp/discussions/3869
Please just ask your question once and wait for a reply, thanks.
It tried it with this example in a seperated class. But the problem is it just enters the credentials by itself and the login window never shows. I really searched the internet for hours and can't find anything that helped me right now.
I use this code on a WindowsForms Application at Visual Studio Express 2012
protected override bool GetAuthCredentials(IWebBrowser chromiumWebBrowser, IBrowser browser, string originUrl, bool isProxy, string host, int port, string realm, string scheme, IAuthCallback callback)
{
//NOTE: We also suggest you explicitly Dispose of the callback as it wraps an unmanaged resource.
//Example #1
//Spawn a Task to execute our callback and return true;
//Typical usage would see you invoke onto the UI thread to open a username/password dialog
//Then execute the callback with the response username/password
//You can cast the IWebBrowser param to ChromiumWebBrowser to easily access
//control, from there you can invoke onto the UI thread, should be in an async fashion
//Load https://httpbin.org/basic-auth/cefsharp/passwd in the browser to test
Task.Run(() =>
{
using (callback)
{
if (originUrl.Contains("https://httpbin.org/basic-auth/"))
{
var parts = originUrl.Split('/');
var username = parts[parts.Length - 2];
var password = parts[parts.Length - 1];
callback.Continue(username, password);
}
}
});
return true;
//Example #2
//Return false to cancel the request
//callback.Dispose();
//return false;
}