Toolwindow plugin with JCEF dose not closed when idea closed

Answered

II use the jcef framework to develop an idea  plugin. 

After installation, even if you don't click the plugin, all opened ideas and resource managers will have another jcef helper and openjdk platform binary.(see picture )

Even after the idea was turned off, jcef did not turn off. Causes the computer to slow down.

How can I end the jcef process when the idea is turned off?thank you!!

8 comments
Comment actions Permalink

Hi Heu,


Please do the following steps:
1) Provide the IDEA and JBR versions (from the About dialog)
2) Close all Chrome browsers, make sure no Chrome agents are on the task list (or reboot).
3) Open IDEA and JCEF component.
4) Close IDEA, make sure it's gone from the task list.
5) Provide the screenshot with Chrome agents.

0
Comment actions Permalink

Anton Tarasov Thank you for your answer, I will follow your order. But there is no way to solve the problem that jcef always appears in the task manager, the following is the relevant information

1、idea version:ic-203.5981.155 ,  jbr use idea defualt 11

2、when i install the plugin, open only one  idea, the resource manager will show 4 jcef helpers

3、when i open another idea ,will show 5 jcef helpers.And i close one idea ,the jcef does not reduce .when i close all ,it will reduce to 0.  I am very curious, why jcef does not decrease by one idea as it closes. As a result, I never close all ideas, jcef will never decrease. 

4、i dont know your the 5  what mean :Provide the screenshot with Chrome agents.  I guess if it is the following screenshot

first is in  idea plugin use   jcef  , the other is chrome browseri

 
0
Comment actions Permalink

Hi Heu,

Sorry for the delay. Please clarify, what do you mean by "open another idea"? What you're doing exactly?

Could you please try IDEA 211?

Please do the following experiment.
1. In IDEA menu: Help > Edit Custom VM Options, add -Didea.is.internal=true, restart IDEA.
2. Open Task Manager, start tracking the JCEF helpers.
3. Perform the action "Show Web Browser", the JCEF browser demo will pop up.
4. Close the JCEF browser - check if the JCEF helpers number decreases.

Please, show how you create the browser? Do you rely on default JBCefClient, or you create your own one?

0
Comment actions Permalink

Anton Tarasov

hi ,Anton . 

1、"open another idea" means "i open two projects in two idea windows"
2、 i new jbcefbrowser in toolwindow,the code :
public void createToolWindowContent(@NotNull Project project ,@NotNull ToolWindow toolwindow){
JBCefBrowser jbCefBrowser = new JBCefBrowser("http://www.xxx");

CefClient client = jbCefBrowser.getJBCefClient().getCefClient();

//Register to interact with front-end js
RegisterMessageRouterHandler messageRouter = new RegisterMessageRouterHandler(project, client, jbCefBrowser);
messageRouter.defaultMessageRouter();

//Add the display panel to the display area
ContentFactory contentFactory = ContentFactory.SERVICE.getInstance();
Content content = contentFactory.createContent(jbCefBrowser.getComponent(), "", false);
toolWindow.getContentManager().addContent(content);
}
3、i try your step,it does not resolve problem.I dont know this step function: add -Didea.is.internal=true. ????? The phenomenon is as follows:
(1)when i open one idea,task manager will appear jecf helper for 4 times.(see the first picture1).I debug the code find that when i new jcefBrowser in toolwindow ,it will appear jcef helper for two times.i do not know what happen .


(2)when i open another idea ,it will increase to 5 times(see the picture 2).I close this idea ,it will not reduce. It is 5 times totaly.when i close the first idea in step (1),it will reduce to 0 times. why one idea closed ,the
corresponding jbcef does not close.

How to reduce when toolwindow closed or idea closed.like register JCEF instance in DialogWrapper,register in toolwindow????

(3)why there are so many the openjdk platform binary cost many ram.(int the 3th picture).computer installed the plugin will slow down.

 

0
Comment actions Permalink

At least, you should avoid working with CefClient directly, unless you don't have proper JBCef* API. For interacting with JS please use JBCefJSQuery:

JBCefJSQuery jsQuery = JBCefJSQuery.create(browser);
jsQuery.addHandler(result -> {
System.out.println("result from JS: " + result);
return null;
});
browser.getCefBrowser().executeJavaScript(jsQuery.inject("'hello'"), browser.getCefBrowser().getURL(), 0);


Also, please confirm you reproduce the same with IDEA 211. I can not reproduce your problem following your steps, unfortunately. Is it possible that you reduce your plugin to minimum and share so that I can try it?


0
Comment actions Permalink

Anton Tarasov 

hi, i push my code here https://github.com/majing1128/ideaplugin.git. it can reproduce the problem above .can you try it ?

0
Comment actions Permalink

Anton Tarasov 

i have resolved the question .when use jbcef it should use dispose with component

0
Comment actions Permalink

Heu, thank you for the update. Automatic jbcef browser disposal is tied to IDE closing, and when you need to force it, you should call dispose manually, right. Glad you've resolved it.

0

Please sign in to leave a comment.