From 5c69487bf3c71db533fac2acd8a4b3ef1bb64d30 Mon Sep 17 00:00:00 2001 From: Eric Seidel Date: Wed, 5 Nov 2014 13:09:08 -0800 Subject: [PATCH] Bring skydebugger closer to clean-shutdown This teaches the SkyDebugger prompt how to tell the sky debugger (server) to shut down instead of just calling exit(0). This also teaches the WindowManagerApp (server) how to tear down all of its connections itself instead of depending on the pipes to do so (which would crash when youd delete the WindowManagerApp as the pipes could outlive it with WindowManagerImpl objects containing raw pointers back to the WindowManagerApp). Shutdown is not yet clean. It errors out trying to talk to the X11 server, but it's closer to clean than it was prior to this change. I may add back and exit(0) to side-step shutdown until it can be made fully clean. R=jamesr@chromium.org, sky@chromium.org BUG=430291, 430242 Review URL: https://codereview.chromium.org/695183003 --- engine/src/flutter/tools/debugger/debugger.cc | 12 ++++++++++-- engine/src/flutter/tools/debugger/debugger.h | 1 + engine/src/flutter/tools/debugger/debugger.mojom | 1 + engine/src/flutter/tools/debugger/prompt/prompt.cc | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/engine/src/flutter/tools/debugger/debugger.cc b/engine/src/flutter/tools/debugger/debugger.cc index a764ae59571..4fdbbe88474 100644 --- a/engine/src/flutter/tools/debugger/debugger.cc +++ b/engine/src/flutter/tools/debugger/debugger.cc @@ -66,13 +66,11 @@ void SkyDebugger::OnEmbed( } void SkyDebugger::OnViewManagerDisconnected(mojo::ViewManager* view_manager) { - CHECK(false); // FIXME: This is dead code, why? view_manager_ = nullptr; root_ = nullptr; } void SkyDebugger::OnViewDestroyed(mojo::View* view) { - CHECK(false); // FIXME: This is dead code, why? view->RemoveObserver(this); } @@ -101,6 +99,16 @@ void SkyDebugger::NavigateToURL(const mojo::String& url) { } } +void SkyDebugger::Shutdown() { + // Make sure we shut down mojo before quitting the message loop or things + // like blink::shutdown() may try to talk to the message loop and crash. + window_manager_app_.reset(); + + // TODO(eseidel): This still hits an X11 error which I don't understand + // "X Error of failed request: GLXBadDrawable", crbug.com/430581 + mojo::ApplicationImpl::Terminate(); +} + void SkyDebugger::InjectInspector() { InspectorServicePtr inspector_service; mojo::ConnectToService(viewer_services_.get(), &inspector_service); diff --git a/engine/src/flutter/tools/debugger/debugger.h b/engine/src/flutter/tools/debugger/debugger.h index 4bd60db0681..e48a6280d7b 100644 --- a/engine/src/flutter/tools/debugger/debugger.h +++ b/engine/src/flutter/tools/debugger/debugger.h @@ -36,6 +36,7 @@ class SkyDebugger : public mojo::ApplicationDelegate, // Overridden from Debugger void NavigateToURL(const mojo::String& url) override; void InjectInspector() override; + void Shutdown() override; private: // Overridden from mojo::ApplicationDelegate: diff --git a/engine/src/flutter/tools/debugger/debugger.mojom b/engine/src/flutter/tools/debugger/debugger.mojom index 75e2f2f8a8a..8e5f23bc4e4 100644 --- a/engine/src/flutter/tools/debugger/debugger.mojom +++ b/engine/src/flutter/tools/debugger/debugger.mojom @@ -7,4 +7,5 @@ module sky; interface Debugger { NavigateToURL(string url); InjectInspector(); + Shutdown(); }; diff --git a/engine/src/flutter/tools/debugger/prompt/prompt.cc b/engine/src/flutter/tools/debugger/prompt/prompt.cc index b8007a78276..8a5ad048f5f 100644 --- a/engine/src/flutter/tools/debugger/prompt/prompt.cc +++ b/engine/src/flutter/tools/debugger/prompt/prompt.cc @@ -132,7 +132,7 @@ class Prompt : public mojo::ApplicationDelegate { void Quit() { std::cout << "quitting" << std::endl; - exit(0); + debugger_->Shutdown(); } void ToggleTracing() {