Sounds great!Out of the curiosity, when is the shutdown sequence used? Is it primarily for Android WebView (our only shipping configuration in single-process mode)?
On Tue, Mar 22, 2016 at 4:23 AM, Kentaro Hara <har...@chromium.org> wrote:HiBlink's initialization/shutdown sequence was a kind of spaghetti and a source of various crashes. So I cleaned up the sequence (*) and guaranteed the following things:- initialize() and shutdown() are balanced; i.e., shutdown() shuts down things in the reverse order in which they are initialized.- The main thread joins all other threads before shutting down (**).- blink::initialize/shutdown initializes/shuts down all the blink components (web/, core/, modules/, platform/ and wtf/).- Platform::initialize/shutdown initializes/shuts down only platform/ and wtf/. You can use Platform::initialize/shutdown in tests that only need platform/ and wtf/.Thanks!(*) Thanks Sigbjorn for reviewing a bunch of patches that handle many subtle scenarios.(**) This doesn't mean that I regressed the performance of the shutdown sequence. It was already guaranteed that the main thread is the last thread to shut down except some edge cases that happen only in testing code. I just changed the shutdown sequence of the edge cases. (Also I don't think that the performance of the shutdown sequence really matters because in common cases Chrome forcibly kills the renderer process rather than shutting down Blink gracefully.)--Kentaro Hara, Tokyo, Japan
Sounds great!Out of the curiosity, when is the shutdown sequence used? Is it primarily for Android WebView (our only shipping configuration in single-process mode)?
On Wed, Mar 23, 2016 at 7:47 AM, Alexandre Elias <ael...@chromium.org> wrote:Sounds great!Out of the curiosity, when is the shutdown sequence used? Is it primarily for Android WebView (our only shipping configuration in single-process mode)?Ojan: I vaguely remember you know when the shutdown sequence is used in production builds...?
On Tue, Mar 22, 2016 at 4:44 PM Kentaro Hara <har...@chromium.org> wrote:On Wed, Mar 23, 2016 at 7:47 AM, Alexandre Elias <ael...@chromium.org> wrote:Sounds great!Out of the curiosity, when is the shutdown sequence used? Is it primarily for Android WebView (our only shipping configuration in single-process mode)?Ojan: I vaguely remember you know when the shutdown sequence is used in production builds...?We fast kill processes that have only the tab being closed in that process as long as the tab doesn't have beforeunload/unload handlers. For tabs that have unload handlers, we shutdown that tab more gracefully, but I don't think blink::shutdown is that code. As best I can tell, blink::shutdown is what we call when we we've already run all the unload handlers and decided to terminate the process.I'm not really sure why we ever need a clean termination of a render process. Maybe someone else knows?
On Tue, Mar 22, 2016 at 4:23 AM, Kentaro Hara <har...@chromium.org> wrote:HiBlink's initialization/shutdown sequence was a kind of spaghetti and a source of various crashes. So I cleaned up the sequence (*) and guaranteed the following things:- initialize() and shutdown() are balanced; i.e., shutdown() shuts down things in the reverse order in which they are initialized.- The main thread joins all other threads before shutting down (**).- blink::initialize/shutdown initializes/shuts down all the blink components (web/, core/, modules/, platform/ and wtf/).- Platform::initialize/shutdown initializes/shuts down only platform/ and wtf/. You can use Platform::initialize/shutdown in tests that only need platform/ and wtf/.Thanks!(*) Thanks Sigbjorn for reviewing a bunch of patches that handle many subtle scenarios.(**) This doesn't mean that I regressed the performance of the shutdown sequence. It was already guaranteed that the main thread is the last thread to shut down except some edge cases that happen only in testing code. I just changed the shutdown sequence of the edge cases. (Also I don't think that the performance of the shutdown sequence really matters because in common cases Chrome forcibly kills the renderer process rather than shutting down Blink gracefully.)--Kentaro Hara, Tokyo, Japan--Kentaro Hara, Tokyo, Japan
On Fri, Mar 25, 2016 at 3:15 AM, Ojan Vafai <oj...@chromium.org> wrote:On Tue, Mar 22, 2016 at 4:44 PM Kentaro Hara <har...@chromium.org> wrote:On Wed, Mar 23, 2016 at 7:47 AM, Alexandre Elias <ael...@chromium.org> wrote:Sounds great!Out of the curiosity, when is the shutdown sequence used? Is it primarily for Android WebView (our only shipping configuration in single-process mode)?Ojan: I vaguely remember you know when the shutdown sequence is used in production builds...?We fast kill processes that have only the tab being closed in that process as long as the tab doesn't have beforeunload/unload handlers. For tabs that have unload handlers, we shutdown that tab more gracefully, but I don't think blink::shutdown is that code. As best I can tell, blink::shutdown is what we call when we we've already run all the unload handlers and decided to terminate the process.I'm not really sure why we ever need a clean termination of a render process. Maybe someone else knows?We need to shut down various things when finishing a renderer process (e.g., shut down discardable memory used by the renderer, close gpu channels etc). To shut down those things safely, we need to shut down all Blink threads (which may touch the things). Then we need a clean termination.Also it is important to have a clean termination for memory leak detectors.
On Thu, Mar 24, 2016 at 8:47 PM Kentaro Hara <har...@chromium.org> wrote:On Fri, Mar 25, 2016 at 3:15 AM, Ojan Vafai <oj...@chromium.org> wrote:On Tue, Mar 22, 2016 at 4:44 PM Kentaro Hara <har...@chromium.org> wrote:On Wed, Mar 23, 2016 at 7:47 AM, Alexandre Elias <ael...@chromium.org> wrote:Sounds great!Out of the curiosity, when is the shutdown sequence used? Is it primarily for Android WebView (our only shipping configuration in single-process mode)?Ojan: I vaguely remember you know when the shutdown sequence is used in production builds...?We fast kill processes that have only the tab being closed in that process as long as the tab doesn't have beforeunload/unload handlers. For tabs that have unload handlers, we shutdown that tab more gracefully, but I don't think blink::shutdown is that code. As best I can tell, blink::shutdown is what we call when we we've already run all the unload handlers and decided to terminate the process.I'm not really sure why we ever need a clean termination of a render process. Maybe someone else knows?We need to shut down various things when finishing a renderer process (e.g., shut down discardable memory used by the renderer, close gpu channels etc). To shut down those things safely, we need to shut down all Blink threads (which may touch the things). Then we need a clean termination.Also it is important to have a clean termination for memory leak detectors.I don't understand how fast process killing works in that case.
On Tue, Mar 22, 2016 at 4:23 AM, Kentaro Hara <har...@chromium.org> wrote:HiBlink's initialization/shutdown sequence was a kind of spaghetti and a source of various crashes. So I cleaned up the sequence (*) and guaranteed the following things:- initialize() and shutdown() are balanced; i.e., shutdown() shuts down things in the reverse order in which they are initialized.- The main thread joins all other threads before shutting down (**).- blink::initialize/shutdown initializes/shuts down all the blink components (web/, core/, modules/, platform/ and wtf/).- Platform::initialize/shutdown initializes/shuts down only platform/ and wtf/. You can use Platform::initialize/shutdown in tests that only need platform/ and wtf/.Thanks!(*) Thanks Sigbjorn for reviewing a bunch of patches that handle many subtle scenarios.(**) This doesn't mean that I regressed the performance of the shutdown sequence. It was already guaranteed that the main thread is the last thread to shut down except some edge cases that happen only in testing code. I just changed the shutdown sequence of the edge cases. (Also I don't think that the performance of the shutdown sequence really matters because in common cases Chrome forcibly kills the renderer process rather than shutting down Blink gracefully.)--Kentaro Hara, Tokyo, Japan--Kentaro Hara, Tokyo, Japan--Kentaro Hara, Tokyo, Japan
We used to have a clean shutdown mode for testing, but that never really worked, so it was removed. Right now, there's a race between the renderer's shutdown code and the renderer process dying. Note that this might still result in unexpected crashes. For shared workers, we added another code path where the renderer blocks in a sync IPC until it is killed to avoid the shutdown code path all together.
The big problems with shutdown are that we don't fully destruct blink and v8, there's just an implicit contract that you mustn't call into blink anymore after calling shutdown. On the content/ side that repeatedly led to problems where an async task wasn't notified that blink went away and tries to call into it, or some destructor trying to send signals, or deregister something in blink.
So tl;Dr: shutdown == sadness
We used to have a clean shutdown mode for testing, but that never really worked, so it was removed.
Right now, there's a race between the renderer's shutdown code and the renderer process dying. Note that this might still result in unexpected crashes. For shared workers, we added another code path where the renderer blocks in a sync IPC until it is killed to avoid the shutdown code path all together.
The big problems with shutdown are that we don't fully destruct blink and v8, there's just an implicit contract that you mustn't call into blink anymore after calling shutdown. On the content/ side that repeatedly led to problems where an async task wasn't notified that blink went away and tries to call into it, or some destructor trying to send signals, or deregister something in blink.
So tl;Dr: shutdown == sadness
On Wed, Mar 30, 2016 at 1:10 AM, Jochen Eisinger <joc...@chromium.org> wrote:We used to have a clean shutdown mode for testing, but that never really worked, so it was removed.
A bunch of *_unit_tests and *_browser_tests are still calling blink::shutdown.Right now, there's a race between the renderer's shutdown code and the renderer process dying. Note that this might still result in unexpected crashes. For shared workers, we added another code path where the renderer blocks in a sync IPC until it is killed to avoid the shutdown code path all together.
The big problems with shutdown are that we don't fully destruct blink and v8, there's just an implicit contract that you mustn't call into blink anymore after calling shutdown. On the content/ side that repeatedly led to problems where an async task wasn't notified that blink went away and tries to call into it, or some destructor trying to send signals, or deregister something in blink.
So tl;Dr: shutdown == sadness
Yeah, there were a lot of bugs like that. Since blink::shutdown shuts down Oilpan, PartitionAlloc and V8, it's highly likely that any call into Blink after blink::shutdown crashes.BTW, if that is the case, we'll get back to Ojan's original question -- why do we need a graceful shutdown for renderers in the first place (because the graceful shutdown is causing the above issues)? If we always forcibly kill the renderers, will the issues be gone?
On Tue, Mar 29, 2016 at 5:30 PM Kentaro Hara <har...@chromium.org> wrote:On Wed, Mar 30, 2016 at 1:10 AM, Jochen Eisinger <joc...@chromium.org> wrote:We used to have a clean shutdown mode for testing, but that never really worked, so it was removed.
A bunch of *_unit_tests and *_browser_tests are still calling blink::shutdown.Right now, there's a race between the renderer's shutdown code and the renderer process dying. Note that this might still result in unexpected crashes. For shared workers, we added another code path where the renderer blocks in a sync IPC until it is killed to avoid the shutdown code path all together.
The big problems with shutdown are that we don't fully destruct blink and v8, there's just an implicit contract that you mustn't call into blink anymore after calling shutdown. On the content/ side that repeatedly led to problems where an async task wasn't notified that blink went away and tries to call into it, or some destructor trying to send signals, or deregister something in blink.
So tl;Dr: shutdown == sadness
Yeah, there were a lot of bugs like that. Since blink::shutdown shuts down Oilpan, PartitionAlloc and V8, it's highly likely that any call into Blink after blink::shutdown crashes.BTW, if that is the case, we'll get back to Ojan's original question -- why do we need a graceful shutdown for renderers in the first place (because the graceful shutdown is causing the above issues)? If we always forcibly kill the renderers, will the issues be gone?Seems like figuring out this question and making sense of our shutdown would be a good project for the architecture team. Is this already on the backlog?
On Wed, Mar 30, 2016 at 1:45 PM, Ojan Vafai <oj...@chromium.org> wrote:On Tue, Mar 29, 2016 at 5:30 PM Kentaro Hara <har...@chromium.org> wrote:On Wed, Mar 30, 2016 at 1:10 AM, Jochen Eisinger <joc...@chromium.org> wrote:We used to have a clean shutdown mode for testing, but that never really worked, so it was removed.
A bunch of *_unit_tests and *_browser_tests are still calling blink::shutdown.Right now, there's a race between the renderer's shutdown code and the renderer process dying. Note that this might still result in unexpected crashes. For shared workers, we added another code path where the renderer blocks in a sync IPC until it is killed to avoid the shutdown code path all together.
The big problems with shutdown are that we don't fully destruct blink and v8, there's just an implicit contract that you mustn't call into blink anymore after calling shutdown. On the content/ side that repeatedly led to problems where an async task wasn't notified that blink went away and tries to call into it, or some destructor trying to send signals, or deregister something in blink.
So tl;Dr: shutdown == sadness
Yeah, there were a lot of bugs like that. Since blink::shutdown shuts down Oilpan, PartitionAlloc and V8, it's highly likely that any call into Blink after blink::shutdown crashes.BTW, if that is the case, we'll get back to Ojan's original question -- why do we need a graceful shutdown for renderers in the first place (because the graceful shutdown is causing the above issues)? If we always forcibly kill the renderers, will the issues be gone?Seems like figuring out this question and making sense of our shutdown would be a good project for the architecture team. Is this already on the backlog?I'm not sure. I think Chrome's long-term goal is to just _exit() processes when they quit since that's faster and we need to not corrupt on-disk data structures well even when quitting in the middle of things since that can happen at any time due to crashes. So I think in general we should never call shutdown, so maybe making it work well is time better invested elsewhere.
Sgtm
Note that there's a difference between shutting down a renderer and calling blink::shutdown() - the latter was maybe not elegant but basically always worked.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.