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.

Javascript extensions fixed in the new update

Post Reply
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Javascript extensions fixed in the new update

Post by salvadordf »

Hi,

I just uploaded a new update with a set of fixes for the JSExtension demo.

The problem appeared in the commit made in Oct 26, 2017 with the title "Update to CEF 3.3202.1674.g2a991c4". That commit included the new Chromium version 62 and the CEF4Delphi code changes had nothing to do with JavaScript extensions.

For some reason, TCefRTTIExtension made the render process crash in this new version and the browser remained blank.

The TCefRTTIExtension class was created years ago when the CEF1 only used one process and it uses Run-Time Type Information (RTTI) to simplify the extension registration while the official CEF sample application, called cefclient, uses several CEF classes and JS code to do the same.

Cefclient follows the steps described in the CEF wiki about "Javascript integration" :
https://bitbucket.org/chromiumembedded/ ... gration.md

In addition to that, cefclient creates the RenderProcessHandler and ResourceBundleHandler class instances inside the equivalent to our TCEFApplication and only in some processes.

In this situation I decided to do all the Javascript integration and process handlers creation the same way the cefclient does to make it easier to maintain.

The new GlobalCEFApp has all the RenderProcessHandler and ResourceBundleHandler events and you only need to implement them and GlobalCEFApp will create RenderProcessHandler and ResourceBundleHandler in the right process and only if they are needed.

These are the changes :
  • TCefCustomRenderProcessHandler.OnRenderThreadCreatedEvent is now GlobalCEFApp.OnRenderThreadCreated
  • TCefCustomRenderProcessHandler.OnWebKitInitializedEvent is now GlobalCEFApp.OnWebKitInitialized
  • TCefCustomRenderProcessHandler.OnBrowserCreatedEvent is now GlobalCEFApp.OnBrowserCreated
  • TCefCustomRenderProcessHandler.OnBrowserDestroyedEvent is now GlobalCEFApp.OnBrowserDestroyed
  • TCefCustomRenderProcessHandler.OnBeforeNavigationEvent is now GlobalCEFApp.OnBeforeNavigation
  • TCefCustomRenderProcessHandler.OnContextCreatedEvent is now GlobalCEFApp.OnContextCreated
  • TCefCustomRenderProcessHandler.OnContextReleasedEvent is now GlobalCEFApp.OnContextReleased
  • TCefCustomRenderProcessHandler.OnUncaughtExceptionEvent is now GlobalCEFApp.OnUncaughtException
  • TCefCustomRenderProcessHandler.OnFocusedNodeChangedEvent is now GlobalCEFApp.OnFocusedNodeChanged
  • TCefCustomRenderProcessHandler.OnProcessMessageReceivedEvent is now GlobalCEFApp.OnProcessMessageReceived
I've also added several new Javascript demos with all the CEF wiki examples.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Javascript extensions fixed in the new update

Post by salvadordf »

I reopened the issue because there's still a bug when you compile in release mode :oops:
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Javascript extensions fixed in the new update

Post by salvadordf »

I uploaded a new update that fixes the compilation in release mode.

Please, download CEF4Delphi again.

Edit : I added more properties to GlobalCEFApp in case someone wants to use his/her own ResourceBundleHandler, BrowserProcessHandler or RenderProcessHandler. GlobalCEFApp creates those handlers inside the StartMainProcess and StartSubProcess calls unless you assign your own handler before those calls.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Javascript extensions fixed in the new update

Post by salvadordf »

Thank you very much! :D

I'll test it and add it to the demos.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Javascript extensions fixed in the new update

Post by salvadordf »

Hi Pier,

The latest update includes your code changes and now the TCefRTTIExtension works again! :D
I added a demo to test it called JSRTTIExtension.

Thank you very much!
Post Reply