Page 1 of 1

Chromium crashes after parent changes

Posted: Thu May 24, 2018 3:17 pm
by Albus
Hi,
I have a frame with a panel in it and a CEFWindowParent in the panel. At first I create a browser with Chromium.CreateBrowser, this works fine. But now I change the Parent of the Frame and in this moment this chromium crashes. I make just this:

Code: Select all

Form.Parent := newParent;
Form.Visible := True;
The content of the Form is this:

Code: Select all

TForm
 (|- TChromium)
  |- TPanel
      |- TCEFWindowParent
I don't think that's supposed to happen.

Re: Chromium crashes after parent changes

Posted: Thu May 24, 2018 5:58 pm
by salvadordf
Try creating a new CEFWindowParent (let's call it NewCEFWindowParent) and using TChromium.SetNewBrowserParent(NewCEFWindowParent.Handle);

Re: Chromium crashes after parent changes

Posted: Mon May 28, 2018 8:57 am
by Albus
Hi, this doesn't worked. The chromium process crashed anyway.

Re: Chromium crashes after parent changes

Posted: Mon May 28, 2018 10:21 am
by salvadordf
I did a quick test modifying the SimpleBrowser2 to include 2 frames, each with a panel and a CEFWindowParent.
The structure would be like this :
  • Frame1 -> Panel -> CEFWindowParent1
  • Frame2 -> Panel -> CEFWindowParent2
I also added 2 buttons :
  • Button1 : Calls SetNewBrowserParent to switch the browser parent between CEFWindowParent1 and CEFWindowParent2.
  • Button2 : Sets Frame1.parent to a different component.
If I click Button2 while CEFWindowParent1 is the browser parent causes problems. I'm not sure if Delphi destroys CEFWindowParent1 or recreates its handle.

SimpleBrowser2 still has the code to close the app correctly following the destruction sequence and the CEFWindowParent1 destruction triggers TChromium.BeforeClose, closing the application.

This can be avoided following these steps :
  • First click Button1 to set CEFWindowParent2 as the new browser parent.
  • Then click Button2 to set the new Frame1 parent.
  • Then click Button1 again to set CEFWindowParent1 as the browser parent.

Re: Chromium crashes after parent changes

Posted: Mon May 28, 2018 10:27 am
by Albus
This solution is quite complicated. We have now solved it in such a way that we recreate the browser after the parent change. Since the browser was invisible before, the user does not notice the difference afterwards.

Re: Chromium crashes after parent changes

Posted: Mon Oct 22, 2018 3:30 pm
by Albus
Hi, after we have rebuilt a bit, our previous workaround doesn't work anymore. So I've now implemented your solution and move the browser to another WindowParent during the parent change. Basically this works fine. Now, however, the WindowParent has different dimensions after the parent change. However, the browser does not render itself again directly when it is moved to a new WindowParent. Now we have grey bars on the right side and a part of the browser is cut off. As soon as you change the window size manually, the browser renders itself again and everything fits.
Is there a way to trigger new rendering by code?

Re: Chromium crashes after parent changes

Posted: Mon Oct 22, 2018 3:46 pm
by salvadordf
Use TCEFWindowParent.UpdateSize;