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.

How to terminate application on libcef exception?

andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

How to terminate application on libcef exception?

Post by andreykrasnodar »

Sometimes there are libcef exceptions and program hangs with message "libcef exception...".
How to terminate application on that exception?
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to terminate application on libcef exception?

Post by salvadordf »

If you find a bug in CEF4Delphi, please report it and provide all the details you can.

If that issue can be reproduced with any of the demos then show the steps to reproduce it.
In some cases it's necessary to provide a minimal demo in order to reproduce that error.

In any case, please share your findings with the community to fix it as soon as possible.

libcef exceptions and programs hanging shouldn't happen but if your application can't avoid them you can use a "watchdog" process that checks if the main application has problems and close all their processes if it hangs.
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: How to terminate application on libcef exception?

Post by andreykrasnodar »

I made the bot that visits search engines and checks thousands positions of thousands websites. It works on my notebook but once or twice a day it hangs on my zero client (Via Eden 1Ghz, 2gb RAM, 2GB SSD, WindowsXP SP3) with message "libcef exception". I don't know the reason and just want to terminate all the processes and start program again.
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to terminate application on libcef exception?

Post by salvadordf »

Using Windows XP means that you use the OldCEF4Delphi component which includes a very old CEF verison.
Many of the old CEF issues are now fixed and your application should be much more stable if you upgrade.

Chromium is known to use a lot of RAM and that PC only has 2Gb. This issue could also be caused by running out of memory.

Use the CEF log functions to add some custom information about the code that may give problems.
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: How to terminate application on libcef exception?

Post by andreykrasnodar »

Use the CEF log functions
Please tell me how to do that
User avatar
salvadordf
Posts: 4016
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to terminate application on libcef exception?

Post by salvadordf »

Add these lines before the GlobalCEFApp.StartMainProcess call in the DPR file :

Code: Select all

  GlobalCEFApp.LogFile             := 'debug.log';
  GlobalCEFApp.LogSeverity         := LOGSEVERITY_INFO;
Then call CefDebugLog with a text message every time you need to add some information to the debug.log file.

If the application crashes you can open the debug.log file to see what was the last text message.

If you want extra information in the log set GlobalCEFApp.LogSeverity to LOGSEVERITY_VERBOSE.

LOGSEVERITY_INFO and LOGSEVERITY_VERBOSE are defined in uCEFConstants.pas
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: How to terminate application on libcef exception?

Post by andreykrasnodar »

I started to use ChromiumOSR and ... no exceptions now.

P.S. Also hangs with exceptions...
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: How to terminate application on libcef exception?

Post by andreykrasnodar »

But I found out that application does not close correctly.
When I run my program, open new windows and close them, and repeat it few times, suddenly"libcef exception" begin on opening new window. And it will continue on the next cycle of running my program. But if I restart computer, libcef exception does not occur.
So I think there is a problem when I terminate my program. Maybe I should close browser, free memory or something like this and after this terminate program...
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: How to terminate application on libcef exception?

Post by andreykrasnodar »

When I try to terminate my program clicking X button, I see the message
APPCRASH gdi32.dll 6.3.9600.17246
53dc6153 c0000005 000266a4
andreykrasnodar
Posts: 112
Joined: Wed Jul 01, 2020 10:22 am

Re: How to terminate application on libcef exception?

Post by andreykrasnodar »

I am trying to close my program with this procedure

Code: Select all

procedure TForm1.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
  if CefSingleProcess then
  begin
    Chromium1.Load('about:blank');
    Chromium2.Load('about:blank');
  end;
  CanClose := True;
end;
But now on close program I see message Access violation
Post Reply