cefsharp / CefSharp

.NET (WPF and Windows Forms) bindings for the Chromium Embedded Framework
http://cefsharp.github.io/
Other
9.87k stars 2.92k forks source link

CEF3: Detect subprocess crashing #207

Closed perlun closed 10 years ago

perlun commented 11 years ago

Right now, if the subprocess crashes early (on startup or similar), it is ignored and no error message is shown to the user. This is not so user friendly; we should really do something about it.

cztomczak commented 10 years ago

See the CefRequestHandler::OnRenderProcessTerminated():

  ///
  // Called on the browser process UI thread when the render process
  // terminates unexpectedly. |status| indicates how the process
  // terminated.
  ///
  /*--cef()--*/
  virtual void OnRenderProcessTerminated(CefRefPtr<CefBrowser> browser,
                                         TerminationStatus status) {}

In previous CEF versions this callback was in CefLoadHandler().

Though, this is only for the Renderer process. I don't know a way for other subprocesses.

perlun commented 10 years ago

Thanks! If I would just have some more time... :smile:

Would you be willing to contribute (patches) to CefSharp3, btw? They would be highly appreciated; you seem to have a high level of knowledge regarding the CEF3 internals already.

cztomczak commented 10 years ago

@Per I don't do programming in C#, though who knows, that might change. At the moment I am thinking on creating CEF bindings for the Go language. Although I already have lots of open tickets in cefpython (https://code.google.com/p/cefpython/issues/list), so I probably should take care of these first :)

perlun commented 10 years ago

:smile: I think the real challenge is to find time to work on the open source stuff, when both work & AFK matters take a lot of your time and energy... + that you might not even want to do the "must" stuff when you finally have a spare moment. That's why CefSharp3 has been proceeding more slowly than I had first hoped. So, we would need all the extra "hands" we could get actually, but it's unfortunately harder to get people who submit code than to ask questions, for whatever reason... :wink:

cztomczak commented 10 years ago

Yes, and the work :) I had a few patches sent by users, by that's only a drop in the bucket. Recently I spent a week working on an another OS project called PHP Desktop (https://code.google.com/p/phpdesktop/) and released a version with Chrome browser embedded. There are so many projects I would like to do :-) Who knows maybe I will try cefsharp too in some future. I've done once application in C#. But I abandoned it, I didn't like the garbage collector, it was causing a simple application to freeze for a few seconds.

cztomczak commented 10 years ago

A bit offtopic, but I have to. Regarding the garbage collector, I see that this is still kind of a major problem in .NET. Recently saw this talk about stackoverflow architecture: http://www.dev-metal.com/architecture-stackoverflow/ . In a nutshell: They don't use OOP, most of the code consists of static classes and static methods(!). The reason they don't use OOP and do no TDD, is because dot net GC (garbage collection) sucks. Instantiating classes will result in these classses being GC'ed later and that will hang their server for a few seconds. No OOP makes their code hard to test, so the GC is also responsible for not having unit tests.

That seems like a bad promotion of C# and .NET.

perlun commented 10 years ago

It sounds, yes. I wouldn't say that the GC has been a major problem for me (and I've done quite a bit of .NET coding during the last 5 years). More so in terms of memory leaks then, but the GC being slow has not really been an issue, ever.

Of course it depends on what you compare it with, but I so, so much prefer C# over more low-level languages (like C++); you get the job done much faster, with less lines of code, which equals less bugs.

For more dynamic, scripting-related stuff i use Ruby (quite a lot) and CoffeeScript (for client code that should run in a browser).

jornh commented 10 years ago

A bit more info on the topic: http://www.magpcss.org/ceforum/viewtopic.php?f=6&t=11788 answering the question: "what happens if user explicitly kills one of those processes using task manager? Will CEF find out the process termination and restart the process? "

Might be useful some day

jornh commented 10 years ago

@jothousand not that I know of. You are more than welcome to have a go at it.

Without having looked much at it I suspect it would be similar to #372.

amaitland commented 10 years ago

@jothousand Any interest in contributing a PR to implement OnRenderProcessTerminated? I had a quick look at the Cef documentation, it's only slightly more complicated than implementing #372 OnPluginCrashed in that you have to add an enum to support TerminationStatus. It should still be very straight forward :smile:

amaitland commented 10 years ago

@jothousand Awesome!

I wrote some very rough notes about forking CefSharp, it might be of some help! https://github.com/cefsharp/CefSharp/issues/362#issuecomment-44475243

amaitland commented 10 years ago

Use IRequestHandler.OnRenderProcessTerminated to detect process termination.

Going to close this now as the PR resolving this was merged into master a while ago.