Browser not painted after removed once from Panel

Having problems with building or using the JCEF Java binding? Ask your questions here.

Browser not painted after removed once from Panel

Postby Phylanx » Wed May 09, 2018 8:12 am

Hi!

First of all:
The discussed behavior is the same with our current productive JCEF version (3.2704) but also with the version we're currently upgrading (3.3325).
I've tested on Windows 10 (64 bit), jcef/cef binaries (versions 3.2704, 3.3325, each 32 bit), jdk 1.8.0_40 (32 bit).

To our problem:
We now use JCEF in a rather stable state and our customers are mainly satisfied with our integration.
One topic left is performance.

We tried to reuse our wrapped implementation and came up with problems when we remove the BrowserComponent from the Frame and add it somewhere else later.
We could reduce the problem to the core JCEF implementation reproduced by a simply adapted detailed MainFrame example.

Just copy the attached files (compressed and attached in java.7z) to the java folder and start the adapted MainFrame instead of the default one (class: tests.detailed.adapted.MainFrame).
The adapted MainFrame has an additional MenuItem "Adapted" with "SwitchPanels".
If you use this SwitchPanels option, the whole contentPane is removed and replaced by an empty one.
If SwitchPanels is used again, the empty one is removed and the normal (previously removed) contentPane is added again.
The whole Code is implemented in tests.detailed.adapted.MainFrame.switchPanels()

What I expect should happen: The browser should be available again afterwards.
What really happens: The Java Components are added again (Adress bar, back, forward,...), including the Browser Component, but the Browser Component is not painted.

What I have found out with our additional Logging is that the renderer process is terminated after the Browser Component has been removed (sure, it is not visible, so I guess that's ok), but it is not started again after it was added to the component tree.

Is this a not supported use case?
Do we have to call something on the cefClient/cefFrame/cefBrowser Components that we have missed?
Is there a way we can avoid this problem otherwise?

Also added the output of the MainFrame application in the "jcef.log" attachment.

Maybe someone has a quick answer :-)

Phylanx

//EDIT:
I already tried creating a new cefBrowser and adding the new UIComponent.
//EDITEDIT:
Retried using a new cefBrowser instance and it worked. I had a bug in my test code.
Attachments
jcef.log
(338 Bytes) Downloaded 10 times
java.7z
(4.21 KiB) Downloaded 10 times
Last edited by Phylanx on Tue May 15, 2018 12:34 am, edited 1 time in total.
Phylanx
Mentor
 
Posts: 89
Joined: Thu Aug 11, 2016 8:17 am

Re: Browser not painted after removed once from Panel

Postby Phylanx » Tue May 15, 2018 12:30 am

After further analysis, we found out:

The renderer process is terminated when the Windows Canvas components peer is disposed.
The peer is not usable from that time on. This happens in java.awt.Component.removeNotify:
Code: Select all
 p.dispose();


This peer will be reinitialized in java.awt.Canvas.addNotify:
Code: Select all
peer = getToolkit().createCanvas(this);


Am I guessing right, that CEF/JCEF uses the window handle of this peer to draw the web content on the Java Canvas?
If the peer is disposed and reinitialized, there would be no functionality that gives CEF/JCEF the windows handle of the new peer.
Or have I missed something?

btw: Using a new Browser instance and its newly created UI would work.
I had a bug in my test code.

The question is:
Shouldn't it be possible to remove the JCEF Component from the component tree and add it somewhere else without going blank (shouldn't there be a update peer mechanism)?
Phylanx
Mentor
 
Posts: 89
Joined: Thu Aug 11, 2016 8:17 am

Re: Browser not painted after removed once from Panel

Postby Phylanx » Thu May 24, 2018 7:41 am

We still have following problem:
Creating a new cefBrowser instance would work.
But this new browser instance loses all session info of the previous one (eg JavaScripting, url, cookies, session info,...).

Is there a possibility to initialize the new cefBrowser with the context information of the old one?
I already know about the CookieManager, but what about the other stuff?
Phylanx
Mentor
 
Posts: 89
Joined: Thu Aug 11, 2016 8:17 am

Re: Browser not painted after removed once from Panel

Postby Phylanx » Wed Jun 13, 2018 2:22 am

Just for reference/link:

I guess this existing issue is exactly the usecase of this topic:
https://bitbucket.org/chromiumembedded/ ... t-16571763

We will try to use this patch in our versions (2704 currently productive at our customers, currently upgrading to 3325) and give feedback about our experience.
Phylanx
Mentor
 
Posts: 89
Joined: Thu Aug 11, 2016 8:17 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 3 guests