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.
Dynamic Creating TChromium
- salvadordf
- Posts: 4052
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Dynamic Creating TChromium
Hi,
The TChromium and TFMXChromium components are created asynchronously.
It's necessary to wait until the TChromium.OnAfterCreated event is triggered before handling the browser. Take a look at the SimpleBrowser2 demo and you will see that it sends a CEF_AFTERCREATED message from the TChromium.OnAfterCreated event to enable the GUI and load the first website.
You can also set TChromium.DefaultUrl before calling TChromium.CreateBrowser to load the default URL as soon as the browser is initialized.
Also remember that you can't call TChromium.CreateBrowser before GlobalCEFApp.GlobalContextInitialized is set to TRUE. The demos have a TTimer to retry TChromium.CreateBrowser until GlobalCEFApp.GlobalContextInitialized is TRUE.
Please read the code comments in the SimpleBrowser2 demo for more information.
The TChromium and TFMXChromium components are created asynchronously.
It's necessary to wait until the TChromium.OnAfterCreated event is triggered before handling the browser. Take a look at the SimpleBrowser2 demo and you will see that it sends a CEF_AFTERCREATED message from the TChromium.OnAfterCreated event to enable the GUI and load the first website.
You can also set TChromium.DefaultUrl before calling TChromium.CreateBrowser to load the default URL as soon as the browser is initialized.
Also remember that you can't call TChromium.CreateBrowser before GlobalCEFApp.GlobalContextInitialized is set to TRUE. The demos have a TTimer to retry TChromium.CreateBrowser until GlobalCEFApp.GlobalContextInitialized is TRUE.
Please read the code comments in the SimpleBrowser2 demo for more information.
Re: Dynamic Creating TChromium
Hi,
I create the TChromium in OSR mode dynamically, but the browser crashed in libcef.dll.
I debug the code above and see that CreateBrowser fuction return true and InitializeDragAndDrop is executed.
But after that the program halt in libcef.dll and crash.
At this time, the OnAfterCreated isn't triggered because the break point in chrmosrAfterCreated is not executed.
I use Win7 & Delphi 10.3 communication edition.
I create the TChromium in OSR mode dynamically, but the browser crashed in libcef.dll.
Code: Select all
var
FChrmosr: TChromium;
procedure TForm1.FormCreate(Sender: TObject);
begin
FChrmosr:=TChromium.Create(Self);
FChrmosr.DefaultUrl:='about:blank';
FChrmosr.OnAfterCreated:=chrmosrAfterCreated;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
if FChrmosr.Initialized then
begin
FChrmosr.WasHidden(False);
FChrmosr.SendFocusEvent(True);
end
else
begin
// opaque white background color
FChrmosr.Options.BackgroundColor := CefColorSetARGB($FF, $FF, $FF, $FF);
if FChrmosr.CreateBrowser(nil, '') then
FChrmosr.InitializeDragAndDrop(Panel1)
else
Timer1.Enabled := True;
end;
//
end;
But after that the program halt in libcef.dll and crash.
At this time, the OnAfterCreated isn't triggered because the break point in chrmosrAfterCreated is not executed.
I use Win7 & Delphi 10.3 communication edition.
- salvadordf
- Posts: 4052
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Dynamic Creating TChromium
Please, make sure you are using the CEF binaries from the "Release" and "Resources" directories. Never use the binaries from the "Debug" directory.
If there is no problem with the CEF binaries then create an screenshot of this crash showing the "Call Stack" window.
The PopupBrowser demo creates browsers in OSR mode at run time. It's a complex demo because it has to create popup windows but perhaps you can compare it to your app.
Edit : I just checked the PopupBrowser demo and it crashes too. I'll take a look this weekend.
If there is no problem with the CEF binaries then create an screenshot of this crash showing the "Call Stack" window.
The PopupBrowser demo creates browsers in OSR mode at run time. It's a complex demo because it has to create popup windows but perhaps you can compare it to your app.
Edit : I just checked the PopupBrowser demo and it crashes too. I'll take a look this weekend.
Re: Dynamic Creating TChromium
I do use the wrong CEF binaries which come from "debug" directory. But after I change to "release" directory, The program crashes too.
The screenshot of the crash is attached, which has already used the correct "release" directory CEF binaries.
My way of creating Tchromium is different from PopupBrowser. The PopupBrowser create a dynamic window in which there is an OSR TChromium. It's placed in the window at design time. My program creates OSR TChromium in the running time.
The screenshot of the crash is attached, which has already used the correct "release" directory CEF binaries.
My way of creating Tchromium is different from PopupBrowser. The PopupBrowser create a dynamic window in which there is an OSR TChromium. It's placed in the window at design time. My program creates OSR TChromium in the running time.
You do not have the required permissions to view the files attached to this post.
- salvadordf
- Posts: 4052
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Dynamic Creating TChromium
I just updated CEF4Delphi and removed an obsolete parameter in all OSR demos that caused a crash.
I tried all the OSR demos and they work correctly.
Please, check that the TChromium.OnGetViewRect event in your application doesn't have a "Result" parameter.
I tried all the OSR demos and they work correctly.
Please, check that the TChromium.OnGetViewRect event in your application doesn't have a "Result" parameter.
Re: Dynamic Creating TChromium
I test the new CEF4Delphi in my dynamic creating TChromium program.
It works now, the crash issue is fixed.
But the TChromium.OnGetViewRect event in my application always doesn't have a "Result" parameter in both crash version and non-crash version.
It works now, the crash issue is fixed.
But the TChromium.OnGetViewRect event in my application always doesn't have a "Result" parameter in both crash version and non-crash version.
- salvadordf
- Posts: 4052
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Dynamic Creating TChromium
That's estrange...
Perhaps there was an old BPL or DCU file with a different OnGetViewRect declaration and the last CEF4Delphi update overwrote it.
Perhaps there was an old BPL or DCU file with a different OnGetViewRect declaration and the last CEF4Delphi update overwrote it.
- salvadordf
- Posts: 4052
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Dynamic Creating TChromium
Thanks for reporting this issue!
Please, download CEF4Delphi again.
Now there's a default view rect size (800x600) when the app doesn't provide a valid size in TChromium.OnGetViewRect
Please, download CEF4Delphi again.
Now there's a default view rect size (800x600) when the app doesn't provide a valid size in TChromium.OnGetViewRect
Re: Dynamic Creating TChromium
salvadordf,
These issues fixes including this and IME have applied to oldCEF4Delphi? Now many people still use XP.
These issues fixes including this and IME have applied to oldCEF4Delphi? Now many people still use XP.
- salvadordf
- Posts: 4052
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: Dynamic Creating TChromium
I'm sorry but it's not possible to fix the IME issue in the 2623 branch used by OldCEF4Delphi because CEF3 fixed this issue in the 2883 branch.
https://bitbucket.org/chromiumembedded/ ... rotocol-in
They added several API calls that are not available in the 2623 branch.
The crash creating TChromium dynamically was caused by a recent change in the TChromium.OnGetViewRect event and it doesn't affect OldCEF4Delphi.
https://bitbucket.org/chromiumembedded/ ... rotocol-in
They added several API calls that are not available in the 2623 branch.
The crash creating TChromium dynamically was caused by a recent change in the TChromium.OnGetViewRect event and it doesn't affect OldCEF4Delphi.