Programmatically stop the rendering process

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Re: Programmatically stop the rendering process

Postby bioncube » Sat Oct 20, 2012 7:09 am

magreenblatt wrote:
bioncube wrote:I see, that's good to know that terminating the renderer is the correct approach. I can try to get the child process IDs of the current process (cefclient application) and simply terminate them. Or is there perhaps an API that can be used to gather the currently active Render Process IDs?

We can expose this API. Killing all child processes may have unintended consequences (for example, you may kill the GPU process or the render process for some other window). Please add an issue to the CEF issue tracker.


Provided that I only use one browser, killing something that belongs to some other window/browser would not be a problem/question. I would assume that Chromium is built to handle the sudden termination/killing of the GPU, Plugin and Render Processes and any other child processes. Is that correct? Or would there be any special case where killing the child processes would result in a crash of the whole browser or any other bad thing?
bioncube
Techie
 
Posts: 43
Joined: Wed Oct 03, 2012 7:03 am

Re: Programmatically stop the rendering process

Postby JRub » Thu Nov 08, 2012 1:18 pm

bioncube wrote:I would assume that Chromium is built to handle the sudden termination/killing of the GPU, Plugin and Render Processes and any other child processes. Is that correct? Or would there be any special case where killing the child processes would result in a crash of the whole browser or any other bad thing?


So, finally, is it safe to kill the GPU process without stopping CEF?
CEF 3.1453.1255 on Windows 7 32bits
JRub
Mentor
 
Posts: 92
Joined: Wed Sep 19, 2012 8:32 am
Location: Paris, France

Re: Programmatically stop the rendering process

Postby magreenblatt » Thu Nov 08, 2012 1:20 pm

JRub wrote:
bioncube wrote:I would assume that Chromium is built to handle the sudden termination/killing of the GPU, Plugin and Render Processes and any other child processes. Is that correct? Or would there be any special case where killing the child processes would result in a crash of the whole browser or any other bad thing?


So, finally, is it safe to kill the GPU process without stopping CEF?

The browser shouldn't crash if that's what you're asking.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Programmatically stop the rendering process

Postby bioncube » Thu Nov 08, 2012 1:58 pm

JRub wrote:
bioncube wrote:I would assume that Chromium is built to handle the sudden termination/killing of the GPU, Plugin and Render Processes and any other child processes. Is that correct? Or would there be any special case where killing the child processes would result in a crash of the whole browser or any other bad thing?


So, finally, is it safe to kill the GPU process without stopping CEF?


I have successfully implemented a thread that periodically kills all the child processes of the browser process. This has never resulted in a crash of the browser process.
bioncube
Techie
 
Posts: 43
Joined: Wed Oct 03, 2012 7:03 am

Re: Programmatically stop the rendering process

Postby JRub » Fri Nov 09, 2012 7:10 am

bioncube wrote:I have successfully implemented a thread that periodically kills all the child processes of the browser process. This has never resulted in a crash of the browser process.


Thanks.
I suppose that you did that in order to decrease the long-term memory usage?
Did you observe a significant change?
On what period do you kill the child processes?
CEF 3.1453.1255 on Windows 7 32bits
JRub
Mentor
 
Posts: 92
Joined: Wed Sep 19, 2012 8:32 am
Location: Paris, France

Re: Programmatically stop the rendering process

Postby bioncube » Fri Nov 09, 2012 7:32 am

JRub wrote:
bioncube wrote:I have successfully implemented a thread that periodically kills all the child processes of the browser process. This has never resulted in a crash of the browser process.


Thanks.
I suppose that you did that in order to decrease the long-term memory usage?
Did you observe a significant change?
On what period do you kill the child processes?


I did not do it because I wanted to reduce the memory usage. I do it to make sure I can create a robust container that displays websites consecutively, like you would see in advertisement installations on the street.

Even with the killing of all the child processes at regular intervals ( every couple of minutes ), you can witness an increase in the browser process' memory usage over time. It starts out at maybe 30K at reaches 70K in a few hours. This worries me a bit. I am not sure if the browser process is leaking memory or accumulating some information, or is my own application somehow leaking memory.

Have you observed that the browser process accumulates (leaked) memory over a period of time, when different websites are shown?
bioncube
Techie
 
Posts: 43
Joined: Wed Oct 03, 2012 7:03 am

Re: Programmatically stop the rendering process

Postby JRub » Fri Nov 09, 2012 8:31 am

I haven't tested memory and CPU usage for my application yet.
In the ideal, CEF is stable enough to be able to run for several month without needing a full restart.
I'll post my conclusions as soon as my tests are done.
CEF 3.1453.1255 on Windows 7 32bits
JRub
Mentor
 
Posts: 92
Joined: Wed Sep 19, 2012 8:32 am
Location: Paris, France

Re: Programmatically stop the rendering process

Postby ztcef » Sat Nov 10, 2012 7:53 pm

Hi, I'm new here and to CEF. I've implemented killing the renderer process (winapi, OpenProcess followed by TerminateProcess), but it does not respawn. I tried loading a URL and loading a request, but I don't see a new renderer process spawning. What am I doing wrong? I'm using a slightly modified cefclient app with CEF3 (branch 1271, revision 889) on Windows 7 x64.
ztcef
Newbie
 
Posts: 3
Joined: Sat Nov 10, 2012 7:43 pm

Re: Programmatically stop the rendering process

Postby bioncube » Sun Nov 11, 2012 3:18 pm

ztcef wrote:Hi, I'm new here and to CEF. I've implemented killing the renderer process (winapi, OpenProcess followed by TerminateProcess), but it does not respawn. I tried loading a URL and loading a request, but I don't see a new renderer process spawning. What am I doing wrong? I'm using a slightly modified cefclient app with CEF3 (branch 1271, revision 889) on Windows 7 x64.


That is strange. If you kill the renderer process manually (through Task Manager for example) of the example cefclient application, automatically a new renderer process is started that displays google.com (the default URL). Don't you get this behavior?

I am using 1271 rev 906. You should try updating to the latest revision, perhaps there's a bugfix for your issue.
bioncube
Techie
 
Posts: 43
Joined: Wed Oct 03, 2012 7:03 am

Re: Programmatically stop the rendering process

Postby bioncube » Sun Nov 11, 2012 4:15 pm

ztcef wrote:Hi, I'm new here and to CEF. I've implemented killing the renderer process (winapi, OpenProcess followed by TerminateProcess), but it does not respawn. I tried loading a URL and loading a request, but I don't see a new renderer process spawning. What am I doing wrong? I'm using a slightly modified cefclient app with CEF3 (branch 1271, revision 889) on Windows 7 x64.


Well, it turns out that if the render process exits with the Exit Code of 0, then the process is considered as terminated successfully and without problems - a new renderer process will not be spawned in this case. You'd have to
Code: Select all
TerminateProcess(renderProcessHandle, -1);
to have a renderer process re-spawn after killing it. But brace yourself, under CEF3 1180, when killing the renderer like this, in 1% of cases, the renderer was still not re-spawned.

Also, a cleaner way to kill the renderer process would be to:
In the browser process:
Code: Select all
CefRefPtr<CefProcessMessage> kill_yourself = CefProcessMessage::Create("kill-yourself");
g_handler.get()->GetBrowser()->SendProcessMessage(PID_RENDERER, kill_yourself);


In the renderer process:
In ClientApp::OnProcessMessageReceived():
Code: Select all
if (message.get()->GetName() == "kill-yourself") exit(-1);


However, this does not work in the case that the renderer process is running an infinite JS loop, because the IPC message is never processed and manual killing is still necessary.
bioncube
Techie
 
Posts: 43
Joined: Wed Oct 03, 2012 7:03 am

PreviousNext

Return to Support Forum

Who is online

Users browsing this forum: Google [Bot] and 194 guests