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
larouchefrancois
@larouchefrancois
@amaitland To give more info to help. I saw that only on the initial request of the url the ChromiumWebBrowser contains the former loaded page URL. All subsequent requests it for resources contained in the main url (initial request) such as css, images, etc will have the proper Address in the ChromiumWebBrowser. And the Browser and its Frame as well (which I guess is really important as well)
What I wonder is when the ChromiumWebBrowser gets its Address set, and the Browser object set as well. I tried to first search in the CefSharp code and I didn't find it and then in Cef project and not quite find it. Problem with hooking and event type of solution it's really hard to debug or analyze. If I can find perhaps I can do it. Obviously in the normal flow it is set somewhere before OnResourceLoadComplete. I would be very curious when it happens and if I can change it.
pwilkowski
@pwilkowski
It appears to be I cannot call Cef.Initialize second time but there is something strange going on. I have created DLL plugin with cef that is suppose to shutdown properly when unloaded. Loading it second time crashes process. Is there any way to completely uninitialize CEF or at least grab the previous "initialization" ?
pwilkowski
@pwilkowski
do i need to dispose settings also?
pwilkowski
@pwilkowski
alternatively is there a way to "cache" existing cef handles?
larouchefrancois
@larouchefrancois
@amaitland Last observation that could be of interest. I noticed that the initial page I'm calling is not part of the Network requests in the devtool associated to my project. I tried to force the Url on the ChromiumWebBrowser and if it helps for the displaying of my data it does not work in there and it should be taken care of. I'm going to continue to investigating. I was hoping that you would say hey! It's an easy one just check this or set that since you know so much the solution :)
Angshuman Agarwal
@angshuman-agarwal
@amaitland : How do we enable permission api for clipboard access : https://googlechrome.github.io/samples/async-clipboard/. Is there a way please ? I tried in CefSharp (WPF) v92, it does not seem to work due to permission denied.
chacham2
@chacham2
How do you change the font size of the browser? I'm looking to start it as a browser preference, not page by page.
chacham2
@chacham2
So far, i have tried BrowserSettings.DefaultFontSize, BrowserSettings.DefaultFixedFontSize, CefSettings.CefCommandLineArgs.Add("minimum_font_size", "18"), CefSettings.CefCommandLineArgs.Add("minimum_logical_font_size", "18"),
chacham2
@chacham2
Wait a sec, i set BrowserSettings.DefaultFontSize, BrowserSettings.DefaultFixedFontSize but never told cef to use those settings. That is, when using CefSettings, the object must be passed via Cef.Initialize(Settings). Is there something similar for BrowserSettings?
To answer my own question, it's passed when starting the browser: New ChromiumWebBrowser("<url>") Though. it still seems not to b doing anything.
chacham2
@chacham2
Okay, it works if BrowserSettings is used to set MinimumFontSize. I think i will set all 4 just in case. Not sure the difference between them, necesarily.
Krishna Chaitanya M
@chaitanyajun12

@amaitland Is there an API in WinForms CefSharp for passing JSON string from JS to C# layer ?

I see that there is one in WPF CefSharp JavascriptMessageReceived. I see there is no equivalent in Winforms CefSharp. Is there one?

Krishna Chaitanya M
@chaitanyajun12
@chacham2 I see this event is present only in WPF CefSharp library and not in Winforms CefSharp. Is there any alternative for Winforms CefSharp?
chacham2
@chacham2
I'm using it in winforms
Actually I don't see the JavascriptMessageReceived in Winforms library..
chacham2
@chacham2
The link i sent is the ChromiumWebBrowser which is used in WinForms
I mean, i am using that right now in the current project i am working on.
Krishna Chaitanya M
@chaitanyajun12
image.png@chacham2 But the link which you sent is Wpf library only
Please correct me if I'm not understanding correctly.
So, basically in my project I'm using CefSharp.Winforms library only and not CefSharp.Wpf library.
chacham2
@chacham2
Okay, now i see, the link shows wpf. Sorry, i missed that. But, i am using it in WinForms
In VB: AddHandler Chromium.JavascriptMessageReceived, Sub(Sender As Object, Arguments As JavascriptMessageReceivedEventArgs) ...
jsoldi
@jsoldi
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 like document.querySelectorAll('iframe'), and another list on the C# site I get by calling browser.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.
Alex Maitland
@amaitland

that's how I know if it's the main request

@larouchefrancois You can use IRequest.ResoruceType to determine if the resource request is for the MainFrame.

It appears to be I cannot call Cef.Initialize second time

@pwilkowski That is correct, it's a limitation of Chromium. See https://github.com/cefsharp/CefSharp/wiki/General-Usage#initialize-and-shutdown

I have created DLL plugin with cef that is suppose to shutdown properly when unloaded. Loading it second time crashes process

Once Cef.Shutdown is called you cannot use the browser again. If you absolutely must support this then you would need to run the browser in a separate process.

or at least grab the previous "initialization"

What do you mean by this exactly?

do i need to dispose settings also?

What settings are you referring to?

alternatively is there a way to "cache" existing cef handles?

What is happening in your scenario? Are the dlls being unloaded? I need a clearer understanding of what's going on.

How do we enable permission api for clipboard access : https://googlechrome.github.io/samples/async-clipboard/.

@angshuman-agarwal CEF doesn't provide an API for handling those permissions requests. https://bitbucket.org/chromiumembedded/cef/issues/2921/add-support-for-asynchronous-clipboard-api

It's possible you might be able to use DevTools to set the permissions.

Alex Maitland
@amaitland

Okay, it works if BrowserSettings is used to set MinimumFontSize. I think i will set all 4 just in case. Not sure the difference between them, necesarily.

@chacham2 For reference there are also some preferences that can be used to change the min font size at runtime.

https://github.com/cefsharp/CefSharp/blob/4608924d5a0c676857720917550674b88bd7b701/CefSharp.Example/Handlers/RequestContextHandler.cs#L29

I see that there is one in WPF CefSharp JavascriptMessageReceived. I see there is no equivalent in Winforms CefSharp. Is there one?

@chaitanyajun12 The exact same event exists in WinForms.

https://cefsharp.github.io/api/51.0.0/html/T_CefSharp_WinForms_ChromiumWebBrowser.htm#!
http://cefsharp.github.io/api/75.1.x/html/E_CefSharp_Wpf_ChromiumWebBrowser_JavascriptMessageReceived.htm

Actually I don't see the JavascriptMessageReceived in Winforms library..

The API Doc is version specific. Here you are comparing version 51 to version 75. Both very very old outdated version

chacham2
@chacham2
@amaitland Thank you for the note!
Krishna Chaitanya M
@chaitanyajun12
Oh missed that @amaitland. Thank you for pointing it out. @chacham2 Thanks to you too. :)
jsoldi
@jsoldi

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 like document.querySelectorAll('iframe'), and another list on the C# site I get by calling browser.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;
}
kcwms
@kcwms
...using CefSharp.Winforms v92.0.260. Does CefSharp expose the amount of memory used by any specific instance ?
ukandrewc
@ukandrewc
@jsoldi I set the frameId in a variable then you can find it either side from that
Frame.EvaluateScriptAsync($"var __FrameID = {e.Frame.FrameId}") Frames.Add(e.Frame)
jsoldi
@jsoldi
@ukandrewc I do something similar to get the frame ID from inside the frame document, but what I also need is to identify the frame from outside the iframe, so I have an iframe HTML element (which may be in another domain) and then I need to get the frame ID of that iframe.
Alex Maitland
@amaitland

Does CefSharp expose the amount of memory used by any specific instance ?

@kcwms Short answer is no. There is no API for that. We are limited by the API exposed by the Chromium Embedded Framework(CEF).

What are you trying to do exactly?

bobodeveloper-anonymous
@bobodeveloper-anonymous
I use CefSharp 94.4.2 I found problem about black screen appear before webpage show on first-time initialize. Anyone encountered this problem?
1 reply
ukandrewc
@ukandrewc
@jsoldi Not sure if I've missed your point but you would then just search for the FrameId using "iframe.contentWindow.__FrameID"
Krishna Chaitanya M
@chaitanyajun12
@amaitland In the latest version of cef.redist.x64.94.4.5, we see there are two dlls which are not getting picked vk_swiftshader.dll and vulkan-1.dll when we are referencing CefSharp dlls in csproj file. We see these dlls in the downloaded nuget package. Are these two dlls required?
image.png

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.

They are required for software rendering.
Krishna Chaitanya M
@chaitanyajun12

So, if we use the configuration -use-gl=swiftshader, then these dlls will be required?

Explicitly these dlls have to be referenced in our csproj files?

jsoldi
@jsoldi
@ukandrewc Yes, that was exactly my point, and in principle that'd be a good solution, but some of these iframes have the src in another domain, so I'm not allowed to access the contents of the iframe since I get a cross-origin error when I try to do so. Unless there's a work around that but I haven't found one either.
Angshuman Agarwal
@angshuman-agarwal

How do we enable permission api for clipboard access : https://googlechrome.github.io/samples/async-clipboard/.

@angshuman-agarwal CEF doesn't provide an API for handling those permissions requests. https://bitbucket.org/chromiumembedded/cef/issues/2921/add-support-for-asynchronous-clipboard-api

It'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 ?

kcwms
@kcwms
@amaitland I need to gather some metrics. This is hosted inside a long lived VB6 app, that is being slowly replaced with Angular sites. In the meantime the NG sites are loaded in CefSharp inside VB6 via com interop. The end users consistently complain of huge memory consumption on their 4GB workstations. Surprise!!
Krishna Chaitanya M
@chaitanyajun12

@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

Alex Maitland
@amaitland