Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with the Component in Load event #69

Open
adilsonpazzini opened this issue Aug 17, 2018 · 7 comments
Open

Problems with the Component in Load event #69

adilsonpazzini opened this issue Aug 17, 2018 · 7 comments

Comments

@adilsonpazzini
Copy link

adilsonpazzini commented Aug 17, 2018

When I use the component in a form only, and ask to load any site, it works normal, but when I try to use it with a secondary form, it gets looped, calling the executable itself several times and does not load anything into the component.

Example: I made a small project, where an initial form opens and it contains a button that calls another form that contains the Chromium component and I ask to open it, to load some website, at that moment, instead of loading the site, it is calling the itself executable, non-stop.

If anyone can help me thank you

Environment - LAZARUS 1.8.4 with CEF4 version - 3.3029.1619 of 05/12/2017.
System Operation - Windows7 32Bits.

since ha gradeço

Adilson Pazzini

@adilsonpazzini
Copy link
Author

Print from a simple example screen with just a form1 in the design.

image

@adilsonpazzini
Copy link
Author

Now the example with a project with 2 forms, and one as main form calling the second

image

@adilsonpazzini
Copy link
Author

teste.zip

Follow example for test

@dliw
Copy link
Owner

dliw commented Aug 18, 2018

By default CEF is initialized by the TChromium component. This works fine as long as the browser component is loaded when the program is started (i.e. is on the main form) or if a subprocess executable is used.

You do not use a subprocess executable. In this case CEF uses the main application as subprocess (see the section SubProcess in the readme for more information). However, in your case this fails, because CEF is not initialized on program startup - and the application gets fully loaded.

There are two possible solutions:

  1. use a subprocess executable (this is the preferred way)
  2. quick fix: call CefInitialize as early as possible, e.g. in the Initialization section of your main form. The downside to this is, that CEF always gets initialized even if it is never used.

@adilsonpazzini
Copy link
Author

Thank you very much, it worked.

You say that if using with the CefInitialize option would not be very good, why? Well, I'll have to use it this way, because the other one by external call, aesthetically, it will not be good for me.

@dliw
Copy link
Owner

dliw commented Aug 21, 2018

A seperate subprocess is how CEF is supposed to be used. One of the reasons is memory consuption. The subprocess usually is much smaller in size than the main application. Startup time of the subprocess may be another reason.

Also as I said, calling CefInitialize early means that CEF is initialized, no matter if it is used later or not and increases startup time.

@adilsonpazzini
Copy link
Author

Okay, thank you so much for returning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants