Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

Tuning external message pump performance

petko
Posts: 52
Joined: Sun Jul 02, 2017 9:58 am

Re: Tuning external message pump performance

Post by petko »

salvadordf wrote: Sat Jan 27, 2018 8:04 am If you can't find a way to load all of your web pages correctly at the same time you can also delay some of them.
For example, load 2 at a time and then the next 2 pages.

Also check that the code in the BeforeResourceLoad and GetResourceHandler events can work correctly under heavy load.
Probably I will just check if a page was loaded correctly (all resources were loaded) and if not, I will reload it.
petko
Posts: 52
Joined: Sun Jul 02, 2017 9:58 am

Re: Tuning external message pump performance

Post by petko »

petko wrote: Fri Jan 26, 2018 8:08 pm The problem was that I was setting Chromium events after calling CreateBrowser (I use ChromiumWindow and not CEFWindowParent) and for some reason none of these events was fired. I now set the events before creating the browser and the events work.
What could be the reason for this behavior? I am now having trouble with some events that I need to assign after creating the TChromium component.. Could it be the CEF scheduler thread?
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Tuning external message pump performance

Post by salvadordf »

Hi,
petko wrote: Sun Jan 28, 2018 3:20 pm
petko wrote: Fri Jan 26, 2018 8:08 pm The problem was that I was setting Chromium events after calling CreateBrowser (I use ChromiumWindow and not CEFWindowParent) and for some reason none of these events was fired. I now set the events before creating the browser and the events work.
What could be the reason for this behavior? I am now having trouble with some events that I need to assign after creating the TChromium component.. Could it be the CEF scheduler thread?
TChromium only creates the handlers that you're going to use and the handlers execute the events only if they are created.

That feature was introduced in this update as a workaround for a CEF3 bug and because it's an efficient use of resources :
https://www.briskbard.com/forum/viewtopic.php?f=8&t=234

TChromium checks what events where assigned to know which handlers have to be created in the CreateBrowser function.

In case you need to use an event after the CreateBrowser call you can do this :
  • Implement the event and assign it to TChromium before you call CreateBrowser.
  • Use a boolean variable with an if..then clause inside that event to execute your code only when you set that boolean variable to True outside that event.
On Friday 26th I updated CEF4Delphi to always create a couple of handlers in all cases : Request handler and Life Span handler.

Those handlers generate these events :
  • OnBeforePopup
  • OnAfterCreated
  • OnBeforeClose
  • OnClose
  • OnBeforeBrowse
  • OnOpenUrlFromTab
  • OnBeforeResourceLoad
  • OnGetResourceHandler
  • OnResourceRedirect
  • OnResourceResponse
  • OnGetResourceResponseFilter
  • OnResourceLoadComplete
  • OnGetAuthCredentials
  • OnQuotaRequest
  • OnProtocolExecution
  • OnCertificateError
  • OnSelectClientCertificate
  • OnPluginCrashed
  • OnRenderViewReady
  • OnRenderProcessTerminated
If you were having difficulties with any of these events download the latest version of CEF4Delphi. You can assign any of those events at any time because the handlers are always created.
petko
Posts: 52
Joined: Sun Jul 02, 2017 9:58 am

Post by petko »

OK, I will create dummy events before using CreateBrowser and later set the proper event handlers.

P.S.: I guess it is not possible to create and assign handlers after CreateBrowser is called? If it was, it would've been much more convenient to create them on the fly - when you try to assign an event handler for a non-existing handler..
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Tuning external message pump performance

Post by salvadordf »

It's not possible to create the handlers after the CreateBrowser call.

CEF3 uses the default handler implementation if no custom handler is provided in the CreateBrowser function.
Post Reply