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 » Wed Oct 03, 2012 4:55 pm

Perhaps there's a better way to control out-of-control render processes. Chromium implements this dialog for unresponsive pages:
Image

This implies that Chromium lets you kill a page/render process. On a side note: An infinite JS loop does not trigger this dialog. What would be useful would be a way to expose the API from Chromium that enables the killing of the render process at any time from the main UI thread / browser process. Do you think this would be a more elegant solution to this problem, than exposing an API to gather render process IDs and manually kill them with TerminateProcess afterwards?
bioncube
Techie
 
Posts: 43
Joined: Wed Oct 03, 2012 7:03 am

Re: Programmatically stop the rendering process

Postby fddima » Wed Oct 03, 2012 5:05 pm

@bioncube, personally - i think, that CEF it is first emebeddable browser with fine-grained control - but it is not chromium/chrome itself. I.e. if you want execute unknown code - yes, may be you think about infinite loops. But, i'm believe, that most of peoples uses CEF to host own html applications in own process (not browser), and what about speak you - it is negative. So in general - yes, it is will be cool have this control. But as Marshal say above - giving association between browser and PID - it is enough to make about same dialog. You case, as i'm think - it is very rare. No want's execute unknown code, and unknown infinite loops at own application. Think better - try avoid infinite-loop problem at root, and then solve consequences like 100% burning. If you host OWN pages - it is MUST not be a problem at all. If you host unknown code - then yes, it is real problem, but already all sayed before. If it will be issue about givind PID<>Browser - i'm star it. But note, that one renderer can host many browsers.
In last year i'm got many questions about CefGlue and CEF - and most of them - peoples doesn't know what want. This question, looks as same. Sorry. :) Just my imho.
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: Programmatically stop the rendering process

Postby bioncube » Wed Oct 03, 2012 5:11 pm

fddima wrote:@bioncube, personally - i think, that CEF it is first emebeddable browser with fine-grained control - but it is not chromium/chrome itself. I.e. if you want execute unknown code - yes, may be you think about infinite loops. But, i'm believe, that most of peoples uses CEF to host own html applications in own process (not browser), and what about speak you - it is negative. So in general - yes, it is will be cool have this control. But as Marshal say above - giving association between browser and PID - it is enough to make about same dialog. You case, as i'm think - it is very rare. No want's execute unknown code, and unknown infinite loops at own application. Think better.


I understand that it's a very rare case. Since unknown code is a given in my case, I can't overlook the possibility of this problem occurring sooner or later. Now I realize that CEF probably has more important issues to investigate and take care of than this rare case of out of control render processes, and I understand that development time is limited. So, what do you think would be the most useful: the API to gather the render process IDs, or the API used to kill render processes at will (getting better control over the processes, should they cause any problems)? I will create an Issue in the tracker afterwards.
bioncube
Techie
 
Posts: 43
Joined: Wed Oct 03, 2012 7:03 am

Re: Programmatically stop the rendering process

Postby fddima » Wed Oct 03, 2012 5:18 pm

bioncube wrote:I understand that it's a very rare case. Since unknown code is a given in my case, I can't overlook the possibility of this problem occurring sooner or later. Now I realize that CEF probably has more important issues to investigate and take care of than this rare case of out of control render processes, and I understand that development time is limited. So, what do you think would be the most useful: the API to gather the render process IDs, or the API used to kill render processes at will (getting better control over the processes, should they cause any problems)? I will create an Issue in the tracker afterwards.

I think, that it is will be good choice to get associated PID from CefBrowser. It will allow you kill process whenever you want.
I no have see any sense in something like KillXXX method, 'cause CEF in any case too platform dependend. Process can be killed in different ways, which really depends from which concrete child will be runned (if it is my process - i can have own IPC with my process with appropriate command).
So, it wiill be really cool get PID from CefBrowser. Also will be really cool have url to issue. :)
fddima
Master
 
Posts: 788
Joined: Tue Dec 07, 2010 6:10 am

Re: Programmatically stop the rendering process

Postby bioncube » Wed Oct 03, 2012 5:33 pm

fddima wrote:I think, that it is will be good choice to get associated PID from CefBrowser. It will allow you kill process whenever you want.
I no have see any sense in something like KillXXX method, 'cause CEF in any case too platform dependend. Process can be killed in different ways, which really depends from which concrete child will be runned (if it is my process - i can have own IPC with my process with appropriate command).
So, it wiill be really cool get PID from CefBrowser. Also will be really cool have url to issue. :)


Yes, getting the render process IDs would be a more useful solution. I have opened an Issue on this:
http://code.google.com/p/chromiumembedd ... ail?id=738

I hope someone has time to look into this. Would implement this myself, but I don't even understand the CEF well enough yet.
Please comment on the Issue if you find a better wording for the problem - I might have made an unclear statement in the eyes of people who understand CEF better than me.

Thank you so much for the quick answers and discussion on this issue! This framework is really cool :ugeek: :)
bioncube
Techie
 
Posts: 43
Joined: Wed Oct 03, 2012 7:03 am

Re: Programmatically stop the rendering process

Postby JRub » Fri Oct 05, 2012 11:33 am

Hello,

I managed killing the renderer process and then execute a new one by loading a request.

As a single renderer can be used by several browsers (but not the opposite), I made my renderer keep the identifier of all the browsers that use it.
Also, when the renderer meets an unknown browser, it sends its PID to it so that the browser can kill it if needed.

However, the first renderer (that will be killed) gets the browser id = 1, the second renderer (executed thanks to request loading) gets the browser id = -1.
The problem is that the browser is the same in both cases.
Though It's not a problem in my case (I use only one browser at a time), I think it could be a problem for someone that uses several browsers.

Is it a bug? Should I add an issue?
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 Oct 05, 2012 2:04 pm

JRub wrote:As a single renderer can be used by several browsers (but not the opposite), I made my renderer keep the identifier of all the browsers that use it.
Also, when the renderer meets an unknown browser, it sends its PID to it so that the browser can kill it if needed.


I use a single browser as well. Care to share your method of keeping track of the renderer IDs by messaging the browser? Actual code would be much appreciated! Thanks!
bioncube
Techie
 
Posts: 43
Joined: Wed Oct 03, 2012 7:03 am

Re: Programmatically stop the rendering process

Postby JRub » Mon Oct 08, 2012 10:25 am

Unfortunately, I can't post any code from my application, but the approach is quite simple anyway.

In the renderer process:
Whenever a method is called with a browser as parameter (other than OnBrowserDestroyed, of course), check if the browser is known.
If it isn't, add it to the renderer list of browsers and send a message to the browser (something like "onNewRenderer" using SendProcessMessage) with the renderer PID as a parameter.

In the browser process:
Whenever the message "onNewRenderer" is received (by OnProcessMessageReceived), update the current renderer PID.
Whenever the renderer is unresponsive (you can detect that by periodically sending a ping to the renderer), kill it and load a new request so that a new renderer is started.

Nothing too complex.
However, as for now this method probably doesn't work for multiple browsers because the browser IDs cannot be retrieved by the new renderers.
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 » Mon Oct 08, 2012 10:27 am

JRub wrote:Hello,

I managed killing the renderer process and then execute a new one by loading a request.

As a single renderer can be used by several browsers (but not the opposite), I made my renderer keep the identifier of all the browsers that use it.
Also, when the renderer meets an unknown browser, it sends its PID to it so that the browser can kill it if needed.

However, the first renderer (that will be killed) gets the browser id = 1, the second renderer (executed thanks to request loading) gets the browser id = -1.
The problem is that the browser is the same in both cases.
Though It's not a problem in my case (I use only one browser at a time), I think it could be a problem for someone that uses several browsers.

Is it a bug? Should I add an issue?

I've noticed this problem as well. Go ahead and add an issue.
magreenblatt
Site Admin
 
Posts: 12382
Joined: Fri May 29, 2009 6:57 pm

Re: Programmatically stop the rendering process

Postby JRub » Mon Oct 08, 2012 11:19 am

magreenblatt wrote:
JRub wrote:Hello,

I managed killing the renderer process and then execute a new one by loading a request.

As a single renderer can be used by several browsers (but not the opposite), I made my renderer keep the identifier of all the browsers that use it.
Also, when the renderer meets an unknown browser, it sends its PID to it so that the browser can kill it if needed.

However, the first renderer (that will be killed) gets the browser id = 1, the second renderer (executed thanks to request loading) gets the browser id = -1.
The problem is that the browser is the same in both cases.
Though It's not a problem in my case (I use only one browser at a time), I think it could be a problem for someone that uses several browsers.

Is it a bug? Should I add an issue?

I've noticed this problem as well. Go ahead and add an issue.

The issue is created: http://code.google.com/p/chromiumembedd ... ail?id=744
CEF 3.1453.1255 on Windows 7 32bits
JRub
Mentor
 
Posts: 92
Joined: Wed Sep 19, 2012 8:32 am
Location: Paris, France

PreviousNext

Return to Support Forum

Who is online

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