Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Oct 10 2016 09:45
    User @amaitland unbanned @aolko
  • Oct 10 2016 09:36
    @amaitland banned @aolko
  • Feb 11 2016 05:56
    User @amaitland unbanned @miyakedev from this room
  • Feb 10 2016 19:59
    @amaitland banned @miyakedev
Alex Maitland
@amaitland

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.

Krishna Chaitanya M
@chaitanyajun12

@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,

image.png

I was thinking just referencing these dlls like above, the vulkan-1 ad vk_swiftshader dlls will as well get picked. But, that is not happening.

Do we need to explicitly reference them in csproj? Would there be any issues if we do so?

Alex Maitland
@amaitland
@chaitanyajun12 You cannot add these files as references in your csproj file as they are unmanaged dlls. They should be copied automatically to your projects bin directory.
Krishna Chaitanya M
@chaitanyajun12

@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.

Krishna Chaitanya M
@chaitanyajun12
@amaitland Are chrome extensions supported in CefSharp?
Krishna Chaitanya M
@chaitanyajun12

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?

galerts
@galerts
изображение.png
изображение.png
Hello, 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?
logerlink
@logerlink
image.png
Hi.Can I set LogFile through RequestContextSettings instead of CefSettings just like setting CachePath?I just want to write logs in different files.
using Cefsharp.wpf v94.4.110
C2MSIS Sistemas de Informação
@c2msis:matrix.org
[m]
Hello!
Can someone help me?
Alex Maitland
@amaitland

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.

Alex Maitland
@amaitland

Can I set LogFile through RequestContextSettings instead of CefSettings just like setting CachePath?I just want to write logs in different files.

@logerlink Unfortunately no.

Can someone help me?

@c2msis:matrix.org What is your question?

jsoldi
@jsoldi

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).

I also noted (in another test) that 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.
hawke0777
@hawke0777
hello what i would like to do is add a chrome extension to a cefsharp window is that possible?
Alex Maitland
@amaitland

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.

jsoldi
@jsoldi
@amaitland Never used that forum before, should I post it on the CefSharp Forum?
Alex Maitland
@amaitland
@jsoldi Support Forum would be where I'd post as it's unlikely CefSharp specific
jsoldi
@jsoldi
@amaitland OK done. I also mention there that this specific request looks "weird" on Chrome too, so I wonder if this is a Chromium bug.
Serhiy Mashkovskyi
@serhiy1994
Hello, I have a task: make a tool which would launch some (>1) browser instances at once (in parellel) with their own BrowserCachePath etc. I made it via WCF. All goes well on the 77th version of the framework, but now there is the 94th version. And my code got hang when I try to synchronize all the instances. 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.
blitzmax01
@blitzmax01
Greetings folks, at the moment I try to get a RequestHandler working for CefSharp. I want that if you have to login on a page the login windows is accessable for the user. I want to see it on the screen and that you can type in your login credentials.

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;
    }
ukandrewc
@ukandrewc
image.png
@blitzmax01 You need to show your own credentials dialog, the callback just gives you the method to enter them
blitzmax01
@blitzmax01
Okay, thanks for the answer. How can I create one?
Peter "Shawty" Shaw
@shawty
@blitzmax01 that depends entirely on how your application is written, if your using winforms, then you'll need to build the dialog using a windows form and associated controls, if it's in WPF, you'll need to do similar but using WPF controls, and if your UI is HTML based then you'll need to set up the appropriate hooks in your app to allow you to input the data in your html UI and submit it back to the app.
Francois Larouche
@larouchefrancois

@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.

Francois Larouche
@larouchefrancois
I meant you keep reusing the same IResourceRequestHandler not RequestHandler :)
Alex Maitland
@amaitland

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.

9 replies
jsoldi
@jsoldi
@larouchefrancois @amaitland Actually I'm pretty sure I know what's happening (I also mention this on the CEF forum post ). You will get a 200 response, but no response body, so you'll get a call to 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.
Francois Larouche
@larouchefrancois
@jsoldi when I test the url I do get a response body of 2 characters that is OK (see my response). So it's not a bug in the code. unless you do some handling somewhere else that I didn't see from your snippet code. I believe that your issue might be because you don't get a new instance of the ResourceRequestHandler, but I might be mistaken. It cost nothing to change the code with new to test. Beyond that I cannot and it was only my 2c. good luck
jsoldi
@jsoldi
@larouchefrancois so you do get a call to OnResourceLoadComplete? Are you directly visiting the cookie URL or ticketmaster.co.uk?
5 replies
Francois Larouche
@larouchefrancois
@jsoldi see pic below (don't know why but cannot paste that pic in the thread). I go inside the OnResourceLoadComplete with the url https://www.ticketmaster.co.uk/api/cookies (in my watch list below circled in red) and when I look at the response content length it gives 2. Also you can see the response is OK with my args.ResponseBody (it's a custom argument that was taken from the initial OnResourceLoadComplete. The code you see is the event I invoked from there
image.png
jsoldi
@jsoldi

@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.

Maybe you also navigated away from ticketmaster.co.uk and that's when you got the call to OnResourceLoadComplete?
12 replies
citylogic-au
@citylogic-au
Hi, I'm using CefSharp in a winforms C# application, showing a SVG animation on 3 monitors. Users are complaining of high CPU usage resulting in high fan noise. Does anyone have any suggestions on getting optimal performance for rendering SVG; eg Settings etc Any help appreciated.
Alex Maitland
@amaitland

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.

4 replies
JaredDrakeZA
@JaredDrakeZA
Hi all, is there a way to change the region / location to South Africa only in CefSharp ? Some webpages jumped to CZech location which isn't supposed to happen. Secondly, how to disable Cloudflare Security Check (CAPTCHA) when browsing the website.
Alex Maitland
@amaitland

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.

1 reply
buhtig0815
@buhtig0815
RequestHandler.OnSelectClientCertificate () is not being called after CefSharp.Wpf.NETCore 89.0.170. Create a NET5 WPF project. Add a reference to CefSharp.Wpf.NETCore version 89.0.170 or lower. Add a ChromiumWebBrowser to the MainWindow.xaml. In the code behind set the address of a site that uses client certificates, a custom RequestHandler and the LoadError eventhandler. Build and run. Up until 89.0.170 the OnSelectClientCertificate() will be called. Change the PackageReference to version 90.5.70-pre or higher. Clean, Build and Run. Now the error eventhandler will hit with: ERR_SSL_CLIENT_AUTH_CERT_NEEDED. But only if the visiting website ask for a certificate after a redirect. Testsites like https://certauth.idrix.fr/ always work. I looked at all the changes in CEFSharp/CEF/Chromium starting in version 90/4430/90.0.4430.30. I can't find any clues on why it behaves differently. Any suggestions on where to look?