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;
}
@jsoldi Hello, I did the test with my own solution and I do get the OK response. I get that response:
HTTP/1.1 200 OK
Accept-Ranges: bytes
Cache-Control: no-store, must-revalidate, max-age=0
Connection: keep-alive
Content-Length: 2
Content-Security-Policy: frame-ancestors 'none';
Content-Type: text/plain;charset=UTF-8
Date: Thu, 04 Nov 2021 14:19:10 GMT
Server: iccp-backend
Set-Cookie: BID=HE0lJVpvUyFA2YqAfp73OBvOQE_DP3b5dMTA-BsfC_144uocKqPFuecprug5WeDR0LvaZe0fRnLct8jc; Path=/; Domain=.ticketmaster.co.uk; Max-Age=31536000; Expires=Fri, 04 Nov 2022 14:19:09 GMT; Secure; HttpOnly; SameSite=None
Set-Cookie: SID=mBvo1ICwHIDHJ7ygTfmXZKo-pQhKBaN59DST8zQm-mMGguZh1uhGfWyWogc4tUQZtfLIRyA-GpfZXIsb; Path=/; Domain=.ticketmaster.co.uk; Secure; HttpOnly; SameSite=None
Set-Cookie: sticky=ABDC; Domain=.ticketmaster.co.uk; Path=/
Set-Cookie: ab-myacc=iccp; Domain=.ticketmaster.co.uk; Path=/
TMPS-Correlation-Id: 6acdc200-cfd3-4228-86b6-75baac67f432
Vary: Accept-Encoding
Via: 1.1 varnish, 1.1 varnish
X-Cache: MISS, MISS
X-Cache-Hits: 0, 0
X-Content-Type-Options: nosniff
X-Fastly: ICCP-GLOBAL-PROD
X-Frame-Options: Deny
X-Page-Type: api
X-Served-By: cache-yyz4551-YYZ, cache-yyz4551-YYZ
X-TM-BID: jP4ADlbUvBzV7CMrCi8sZZ0aTGYaq4/9T/PW0I/Pdg97zhmtuvdopHndJQpIBMt6/cqzy/49Ce8Hs6iomUsQbMSQIslXMpOSMuJTsb3L4DAyNdU9MXeDeRD8/v6XDPrQ
X-TM-SID: ggtQEQil+Z6ga0Q8OZmH33k7VbIw4COS/Nh2zKYji9j0vGNzVwUimQa3Vt2wifu2Gg8LBa71VvLqEwWLHc6Zq+qdJo9W0vmwbNXLiX6saTq4+z7Bs6GEfWrxQ55sI9W8
X-Timer: S1636035550.816619,VS0,VE226
X-XSS-Protection: 1
x-d-debug-state: SUCCESS
My theory is that along the many overrides and interception the code is not right. It happened to me many times as I use a lot of customized event handlers and overrides.
One thing I notice in your code is that you keep reusing the same custom request handler. In my case I create a new one each time to ensure that each request has its own context and is not overwrite by a concurrent request since it shares the same object. In the examples I saw it was always a new instance. I think you should start with that, let me know if it works.
OK done. I also mention there that this specific request looks "weird" on Chrome too, so I wonder if this is a Chromium bug.
@jsoldi Possibly a Chromium BUG
, it's also possible that CEF
ignores the response. You'd need to debug the source to find out for sure.
https://github.com/chromiumembedded/cef/blob/a7bbd8a62bfc91b0d53eeef8d07b64a5ed719a5f/libcef/browser/net_service/resource_request_handler_wrapper.cc#L975
What's changed on the CefSharp lifecycle or maybe I'm going smth wrong?
Here's the code - https://pastebin.com/EcZYssWD, hang on line 109.
@serhiy1994 Start by checking the log file. See https://github.com/cefsharp/CefSharp/wiki/Trouble-Shooting#log-file
I need more information before I can speculate as to what's going on.
OnResourceResponse
with a 200 response, but no call to OnResourceLoadComplete
. The reason is that the script calls fetch
but doesn't call text
or json
to get the response body, so the request hangs there forever. I'm not sure if this is the expected behavior thought, since I've noted that doing fetch
on HTML documents automatically pulls the content body regardless of whether you call text
or not, but it seems that it doesn't do that with JSON requests, so I'm still not sure if this is a bug or not. I don't think CEF is ignoring the request because the error code on OnResourceResponse
is None
and one of the conditions to ignore it is for the error code to be ERR_ABORTED
, unless it changes to aborted later? I'll see if I can debug that and report back.
@larouchefrancois I tried what you suggested:
public class MyRequestHandler : RequestHandler
{
protected override IResourceRequestHandler GetResourceRequestHandler(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling)
{
return new MyResourceHandler();
}
}
public class MyResourceHandler : ResourceRequestHandler
{
protected override bool OnResourceResponse(IWebBrowser chromiumWebBrowser, IBrowser browser, IFrame frame, IRequest request, IResponse response)
{
System.Diagnostics.Debug.WriteLine($"OnResourceResponse [{request.Identifier}]: {request.Url}");
return base.OnResourceResponse(chromiumWebBrowser, browser, frame, request, response);
}
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);
}
}
But only got these two:
OnBeforeResourceLoad [863083]: https://www.ticketmaster.co.uk/api/cookies
OnResourceResponse [863083]: https://www.ticketmaster.co.uk/api/cookies
No call to OnResourceLoadComplete
except after I navigated away again, I guess because CEF disposed the request:
OnResourceLoadComplete [863083]: https://www.ticketmaster.co.uk/api/cookies
So I wonder if you're doing something else that I'm not. I literally just downloaded the latest version of CefSharp and added the code. I originally thought it worked but it was because I added some code to ignore this specific request which then forgot to remove.
ticketmaster.co.uk
and that's when you got the call to OnResourceLoadComplete
?
CefSharp in a winforms C# application
@citylogic-au What version are you using?
Users are complaining of high CPU usage resulting in high fan noise
How does Chrome
at the same version behave on the same machine?
Does anyone have any suggestions on getting optimal performance for rendering SVG
Performance is largely tied to the Chromium
version. I'm not aware of any SVG
rendering specific options. Try searching in the Chromium
issue tracker.
As a general debugging step you can load chrome://gpu/
in both Chrome
and CefSharp
to compare the GPU Acceleration
.
is there a way to change the region / location to South Africa only in CefSharp
@JaredDrakeZA You can change the following:
How does the website determine region? IP Address? Accept-Language header? timezone?
Secondly, how to disable Cloudflare Security Check (CAPTCHA) when browsing the website.
If CloudFlare
has a server side component to it's captcha then it's unlikely you can disable it.
I'd search for something like headless chrome cloudflare
.