Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2017-09

fpCEF3 questions

6 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Torsten Bonde Christiansen

Hi List.

I am trying to work with the Chromium Embedded Framework from (https://github.com/dliw/fpCEF3) and (http://wiki.freepascal.org/fpCEF3) but parts of working with the framework is causing headaches... :)

1) I need to hook into the scrollbars such that i manually can position the view.
2) Parts of the focus handling seems to be either broken or my understanding of it is broken.
3) Using the TChromium component does not paint the view correctly when a main menu is used. There seems to be an offset problem.

Kind regards
Torsten.

Reply by email

Unknown author
to Torsten Bonde Christiansen

Hi Torsten,

working with the framework is causing headaches

being the author of fpCEF, I can confirm that ;)

Is it correct, that you are using one of the latest versions of fpCEF on Linux?

1) I need to hook into the scrollbars such that i manually can position the view.

There is no API for that, but you can write JavaScript to do the job. See the JavaScript example...

2) Parts of the focus handling seems to be either broken or my understanding of it is broken.

If you are on Linux, this is a known problem (for me; I need create an issue on Github).

I myself use fpCEF for showing html pages (no interaction), so I only realized it was broken, when doing the latest update.

The problem seems to be within CEF:
https://bitbucket.org/chromiumembedded/cef/issues/2026/multiple-major-keyboard-focus-issues-on

For GTK I think I found a way to work around the problem in fpCEF, but QT is totally broken.
I'm trying to improve the current situation, but it will take some time.

3) Using the TChromium component does not paint the view correctly when a main menu is used. There seems to be an offset problem.

Could you send a screenshot?

On Linux there are many ways to break TChromium. The reason is the way how CEF is embedded into LCL. Currently CEF always is embedded directly into the XWindow of the Form and positioned / resized via X events. For simple use cases it usually works ok, but can break easily for more complex setups (like the tabbed browser).

I already tried to embed CEF into the XWindow of the parent control of TChromium, but then event handling breaks for CEF and the client LCL application, if the parent is not a form.

CEF at the moment also does not support Xembed, which IMO could solve many issues:
https://bitbucket.org/chromiumembedded/cef/issues/1417/linux-improve-cef-x11-window-behavior-in

The more robust solution on Linux ATM is the offscreen browser TChromiumOSR.

Btw. I would be very happy if anyone could tell me, how to reliably embed a XWindow into any LCL widgetset on Linux.

Kind regards,
dliw

Reply by email

Torsten Bonde Christiansen
to Unknown author
Show quoted text 8 lines
Hi Torsten, > working with the framework is causing headaches being the author of fpCEF, I can confirm that ;) Is it correct, that you are using one of the latest versions of fpCEF on Linux?

Absolutely correct. I'm using the currently available 3.3029 on Linux (64bit) GTK2

> 1) I need to hook into the scrollbars such that i manually can position > the view. There is no API for that, but you can write JavaScript to do the job. See the JavaScript example...

Okay - thanks.

Show quoted text 14 lines
> 2) Parts of the focus handling seems to be either broken or my > understanding of it is broken. If you are on Linux, this is a known problem (for me; I need create an issue on Github). I myself use fpCEF for showing html pages (no interaction), so I only realized it was broken, when doing the latest update. The problem seems to be within CEF: https://bitbucket.org/chromiumembedded/cef/issues/2026/multiple-major-keyboard-focus-issues-on For GTK I think I found a way to work around the problem in fpCEF, but QT is totally broken. I'm trying to improve the current situation, but it will take some time.

In my project i create an HTML output for a statistical analysis program and the code itself is very simple - tables and paragraph, and only very little CSS.

> 3) Using the TChromium component does not paint the view correctly when > a main menu is used. There seems to be an offset problem. Could you send a screenshot?

Without Main menu:

With main menu:
- notice the lacking tabs, this is more prominent if not using a pagecontrol, but
any other wincontrol to host the browser.

Show quoted text 15 lines
On Linux there are many ways to break TChromium. The reason is the way how CEF is embedded into LCL. Currently CEF always is embedded directly into the XWindow of the Form and positioned / resized via X events. For simple use cases it usually works ok, but can break easily for more complex setups (like the tabbed browser). I already tried to embed CEF into the XWindow of the parent control of TChromium, but then event handling breaks for CEF and the client LCL application, if the parent is not a form. CEF at the moment also does not support Xembed, which IMO could solve many issues: https://bitbucket.org/chromiumembedded/cef/issues/1417/linux-improve-cef-x11-window-behavior-in The more robust solution on Linux ATM is the offscreen browser TChromiumOSR.

In the OSR example the painting is tied to OpenGL IIRC, but can it be tied to something else? and how?

Another issue with all the versions of CEF i have tried so far is that I get a SIGSEGV when closing any application that uses fpCEF. I have tried many combinations when trying to shutdown, but it seems to boil down to calling "CefCloseLibrary" that causes the SIGSEGV.

Regards,
Torsten.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170914/7401765c/attachment-0001.html> -------------- next part --------------
A non-text attachment was scrubbed...
Name: imiclgppjonjndfh.png
Type: image/png
Size: 26534 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170914/7401765c/attachment-0002.png> -------------- next part --------------
A non-text attachment was scrubbed...
Name: fcofgbfkmbanhfio.png
Type: image/png
Size: 25125 bytes
Desc: not available
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20170914/7401765c/attachment-0003.png>

Reply by email

Unknown author
to Torsten Bonde Christiansen
With main menu: - notice the lacking tabs, this is more prominent if not using a pagecontrol, but any other wincontrol to host the browser.

I see.
The problem is, that the menu does not change the position of the controls on the form.
E.g. if you out a button with Top=0 on an empty form and then add a menu, Top the offset of TChromium is wrong.

As a workaround you could change the position of the TChromium component (if on Linux).
As I said, fpCEF on Linux embeds CEF into the XWindow of the main form, which is more or less a borderless window manually positioned over the LCL form.

In my project i create an HTML output for a statistical analysis program and the code itself is very simple - tables and paragraph, and only very little CSS.

It doesn't really matter what you show via TChromium, but how you use TChromium.
And the tabbed browser is probably the most complex case and unfortunately rather broken on Linux right now.

However, if you really only want to show very simple HTML, then https://github.com/BerndGabriel/HtmlViewer
may possibly be the better choice for you.

In the OSR example the painting is tied to OpenGL IIRC, but can it be tied to something else? and how?

Actually not. CEF only provides an array of pixel values, it is up to you to do whatever you want.
Older versions of the OSRDemo used BGRABitmap:
https://github.com/dliw/fpCEF3/blob/5335a5ba437d469eb6f933e47ae0e0cd3d6e8968/Examples/OSRDemo/main.pas#L113

Another issue with all the versions of CEF i have tried so far is that I get a SIGSEGV when closing any application that uses fpCEF. I have tried many combinations when trying to shutdown, but it seems to boil down to calling "CefCloseLibrary" that causes the SIGSEGV.

See the last part of my answer in this issue:
https://github.com/dliw/fpCEF3/issues/47#issuecomment-281333395

In the meantime I have a version which implements the correct CEF shutdown process. It works fine if there is only a single TChromium instance, but has side effects when used in the tabbed browser. Focus get lost for all other instances and there is no way to get it back, browser content turns black, etc.
-> headaches...

So no good nows - sorry. It very much depends on CEF to improve the usage on Linux.

Regards,
dliw

Reply by email

Torsten Bonde Christiansen
to Unknown author
dev.dliw--- wrote 14 lines
> With main menu: > - notice the lacking tabs, this is more prominent if not using a > pagecontrol, but > any other wincontrol to host the browser. I see. The problem is, that the menu does not change the position of the controls on the form. E.g. if you out a button with Top=0 on an empty form and then add a menu, Top the offset of TChromium is wrong. As a workaround you could change the position of the TChromium component (if on Linux). As I said, fpCEF on Linux embeds CEF into the XWindow of the main form, which is more or less a borderless window manually positioned over the LCL form.

I tried with applying the height of the TMenu, but the GTK implementation seems to have a generic
value witch not truely corresponds to active DE and the style/font used...

I guess I will have to live with it the way it is for now.

Show quoted text 13 lines
> In my project i create an HTML output for a statistical analysis program > and the code itself is very simple - tables and paragraph, and only very > little CSS. It doesn't really matter what you show via TChromium, but how you use TChromium. And the tabbed browser is probably the most complex case and unfortunately rather broken on Linux right now. However, if you really only want to show very simple HTML, then https://github.com/BerndGabriel/HtmlViewer may possibly be the better choice for you.

The whole reason for using CEF was because the THhtmlViewer component is too slow! Especially in my case since I often work with many and large tables (100 / 1000+ rows) which causes significal slowdows in that component.

Show quoted text 7 lines
> In the OSR example the painting is tied to OpenGL IIRC, but can it be > tied to something else? and how? Actually not. CEF only provides an array of pixel values, it is up to you to do whatever you want. Older versions of the OSRDemo used BGRABitmap: https://github.com/dliw/fpCEF3/blob/5335a5ba437d469eb6f933e47ae0e0cd3d6e8968/Examples/OSRDemo/main.pas#L113

I will check that link out later and see if I can make the switch.

Show quoted text 8 lines
> Another issue with all the versions of CEF i have tried so far is that I > get a SIGSEGV when closing any application that uses fpCEF. I have tried > many combinations when trying to shutdown, but it seems to boil down to > calling "CefCloseLibrary" that causes the SIGSEGV. See the last part of my answer in this issue: https://github.com/dliw/fpCEF3/issues/47#issuecomment-281333395

I have already made sure to sync both the fpCEF and the CEF-minimal i can download, but i still get the problem.

For now i can make the call in a try .. except block and catch the error when closing down. That way the problem is only
visible during debugging. :)

Show quoted text 11 lines
In the meantime I have a version which implements the correct CEF shutdown process. It works fine if there is only a single TChromium instance, but has side effects when used in the tabbed browser. Focus get lost for all other instances and there is no way to get it back, browser content turns black, etc. -> headaches... So no good nows - sorry. It very much depends on CEF to improve the usage on Linux.

If my testing can help you in anyway just say so. I'm no hardcore GTK coder, but i have a little experience so
I will try to see if I can assist you whenever possible.

Kind regards
Torsten.

Reply by email

Unknown author
to Torsten Bonde Christiansen
The whole reason for using CEF was because the THhtmlViewer component is too slow!

Well ok, bad advice then...

I will check that link out later and see if I can make the switch.

Please note:
When using OSR chromium one needs to handle all events and pass them to CEF "manually". OSRDemo at the moment only handles mouse events, so keyboard input does *not* work and needs to be implemented.

I have already made sure to sync both the fpCEF and the CEF-minimal i can download, but i still get the problem.

Sorry, I meant I have a version *locally*, but it creates more problems right now, than it solves.
try .. except is the only "solution" now.

I will try to see if I can assist you whenever possible.

Thanks for the offer. However, most of the problem really is on the CEF side and there is not much I can do to work around it.

Even the official cefclient application has similar problems on Linux. https://bitbucket.org/chromiumembedded/cef/src/c95b92f1e8702ad4a74c4251d5d698f417a21717/tests/cefclient/?at=master

Kind regards,
dliw

Reply by email