|
|
Chromium Code Reviews|
Created:
7 years, 7 months ago by robertshield Modified:
7 years, 7 months ago CC:
chromium-reviews, tfarina, kareng Base URL:
svn://svn.chromium.org/chrome/trunk/src Visibility:
Public. |
DescriptionAdd a leaked reference to g_browser_process before showing the uninstall dialog to avoid the views framework from erroneously exiting the browser process.
BUG=241366
TEST=Uninstall Chrome while it is set as the default browser. Select an item from the "make other browser default" combobox. Observe that the dialog does not immediately close.
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=200732
Patch Set 1 : #
Total comments: 1
Messages
Total messages: 17 (0 generated)
On 2013/05/16 15:14:24, robertshield wrote: FWIW, I'm not 100% happy with this. It would be better in the abstract to make the Views code work in a chrome.exe that hasn't yet bumped the refcount on g_browser_process to a non-zero value, though I'm not sure how to do that safely. Suggestions welcome :-)
Wow, what an awful bug. I suggest getting review from someone that understands the Menu code a bit better, specifically why MenuController::Run needs g_browser_process at all (though I only saw add/release refs on ViewsDelegate::views_delegate), perhaps Scott knows more. This LGTM as a short-term workaround fix for this one case (I wonder if there are other dialogs we might show without Chrome running that might have the same issue), but again I'm not totally familiar with menu's g_browser_process add/release ref.
On 2013/05/16 17:45:38, msw wrote: > Wow, what an awful bug. I suggest getting review from someone that understands > the Menu code a bit better, specifically why MenuController::Run needs > g_browser_process at all (though I only saw add/release refs on > ViewsDelegate::views_delegate In practice ViewsDelegate::views_delegate is a ChromeViewsDelegate whose AddRef/Release implementations forward directly to g_browser_process' AddRefModule/ReleaseModule methods. > ), perhaps Scott knows more. This LGTM as a > short-term workaround fix for this one case (I wonder if there are other dialogs > we might show without Chrome running that might have the same issue), but again > I'm not totally familiar with menu's g_browser_process add/release ref. Yeah, I'd welcome a better way to do this too :-) Right now it isn't really safe to use Views menus anywhere during Chrome startup until g_browser_process has been refcounted. Scott, any ideas?
I don't really have anything to add, so LGTM. It would be nice if the hack wasn't needed, but it seems like a significant undertaking.
On 2013/05/16 17:53:54, robertshield wrote: > On 2013/05/16 17:45:38, msw wrote: > > Wow, what an awful bug. I suggest getting review from someone that understands > > the Menu code a bit better, specifically why MenuController::Run needs > > g_browser_process at all (though I only saw add/release refs on > > ViewsDelegate::views_delegate > > In practice ViewsDelegate::views_delegate is a ChromeViewsDelegate whose > AddRef/Release implementations forward directly to g_browser_process' > AddRefModule/ReleaseModule methods. > > > ), perhaps Scott knows more. This LGTM as a > > short-term workaround fix for this one case (I wonder if there are other > dialogs > > we might show without Chrome running that might have the same issue), but > again > > I'm not totally familiar with menu's g_browser_process add/release ref. > > Yeah, I'd welcome a better way to do this too :-) Right now it isn't really safe > to use Views menus anywhere during Chrome startup until g_browser_process has > been refcounted. > > Scott, any ideas? Could ChromeViewsDelegate::AddRef/ReleaseRef do something else in the case where the g_browser_process ref count is 0 to start? Also, is leaking the AddRef in your workaround okay? Will the process shut down correctly when the dialog closes?
On 2013/05/16 18:01:58, msw wrote: > On 2013/05/16 17:53:54, robertshield wrote: > > On 2013/05/16 17:45:38, msw wrote: > > > Wow, what an awful bug. I suggest getting review from someone that > understands > > > the Menu code a bit better, specifically why MenuController::Run needs > > > g_browser_process at all (though I only saw add/release refs on > > > ViewsDelegate::views_delegate > > > > In practice ViewsDelegate::views_delegate is a ChromeViewsDelegate whose > > AddRef/Release implementations forward directly to g_browser_process' > > AddRefModule/ReleaseModule methods. > > > > > ), perhaps Scott knows more. This LGTM as a > > > short-term workaround fix for this one case (I wonder if there are other > > dialogs > > > we might show without Chrome running that might have the same issue), but > > again > > > I'm not totally familiar with menu's g_browser_process add/release ref. > > > > Yeah, I'd welcome a better way to do this too :-) Right now it isn't really > safe > > to use Views menus anywhere during Chrome startup until g_browser_process has > > been refcounted. > > > > Scott, any ideas? > > Could ChromeViewsDelegate::AddRef/ReleaseRef do something else in the case where > the g_browser_process ref count is 0 to start? I wondered about that, and it would fix it here, but I couldn't convince myself it would always be correct. Greg also suggested setting state on the ChromeViewDelegate to let it know Chrome is still in a pre-startup phase and no-oping the AddRef/Release while that state is set. I'll try one of those. > Also, is leaking the AddRef in > your workaround okay? Will the process shut down correctly when the dialog > closes? In this case, yes. This code is called from ChromeBrowserMainParts::PreMainMessageLoopRunImpl and regardless of the dialog outcome, Chrome exits immediately afterwards.
On 2013/05/16 18:32:07, robertshield wrote: > On 2013/05/16 18:01:58, msw wrote: > > On 2013/05/16 17:53:54, robertshield wrote: > > > On 2013/05/16 17:45:38, msw wrote: > > > > Wow, what an awful bug. I suggest getting review from someone that > > understands > > > > the Menu code a bit better, specifically why MenuController::Run needs > > > > g_browser_process at all (though I only saw add/release refs on > > > > ViewsDelegate::views_delegate > > > > > > In practice ViewsDelegate::views_delegate is a ChromeViewsDelegate whose > > > AddRef/Release implementations forward directly to g_browser_process' > > > AddRefModule/ReleaseModule methods. > > > > > > > ), perhaps Scott knows more. This LGTM as a > > > > short-term workaround fix for this one case (I wonder if there are other > > > dialogs > > > > we might show without Chrome running that might have the same issue), but > > > again > > > > I'm not totally familiar with menu's g_browser_process add/release ref. > > > > > > Yeah, I'd welcome a better way to do this too :-) Right now it isn't really > > safe > > > to use Views menus anywhere during Chrome startup until g_browser_process > has > > > been refcounted. > > > > > > Scott, any ideas? > > > > Could ChromeViewsDelegate::AddRef/ReleaseRef do something else in the case > where > > the g_browser_process ref count is 0 to start? > > I wondered about that, and it would fix it here, but I couldn't convince myself > it would always be correct. > > Greg also suggested setting state on the ChromeViewDelegate to let it know > Chrome is still in a pre-startup phase and no-oping the AddRef/Release while > that state is set. > > I'll try one of those. > > > Also, is leaking the AddRef in > > your workaround okay? Will the process shut down correctly when the dialog > > closes? > > In this case, yes. This code is called from > ChromeBrowserMainParts::PreMainMessageLoopRunImpl and regardless of the dialog > outcome, Chrome exits immediately afterwards. I'll also check this in in the meantime to give folk a chance to merge it if they need a spot fix.
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/robertshield@chromium.org/15134004/3001
Retried try job too often on chromium_presubmit for step(s) presubmit http://build.chromium.org/p/tryserver.chromium/buildstatus?builder=chromium_p...
https://codereview.chromium.org/15134004/diff/3001/chrome/browser/ui/views/un... File chrome/browser/ui/views/uninstall_view.cc (right): https://codereview.chromium.org/15134004/diff/3001/chrome/browser/ui/views/un... chrome/browser/ui/views/uninstall_view.cc:178: g_browser_process->AddRefModule(); How does the ref count end up hitting 0 here?
On 2013/05/16 19:26:49, sky wrote: > https://codereview.chromium.org/15134004/diff/3001/chrome/browser/ui/views/un... > File chrome/browser/ui/views/uninstall_view.cc (right): > > https://codereview.chromium.org/15134004/diff/3001/chrome/browser/ui/views/un... > chrome/browser/ui/views/uninstall_view.cc:178: > g_browser_process->AddRefModule(); > How does the ref count end up hitting 0 here? It doesn't. This method is called only via DoUninstallTasks in ChromeBrowserMainParts::PreMainMessageLoopRunImpl. When it returns, Chrome exits, never starting the main message loops.
On 2013/05/16 19:49:06, robertshield wrote: > On 2013/05/16 19:26:49, sky wrote: > > > https://codereview.chromium.org/15134004/diff/3001/chrome/browser/ui/views/un... > > File chrome/browser/ui/views/uninstall_view.cc (right): > > > > > https://codereview.chromium.org/15134004/diff/3001/chrome/browser/ui/views/un... > > chrome/browser/ui/views/uninstall_view.cc:178: > > g_browser_process->AddRefModule(); > > How does the ref count end up hitting 0 here? > > It doesn't. This method is called only via DoUninstallTasks in > ChromeBrowserMainParts::PreMainMessageLoopRunImpl. When it returns, Chrome > exits, never starting the main message loops. See here for an alternate approach that blocks the AddRef/Release calls from views during startup: https://codereview.chromium.org/14845020/
LGTM
Ok, I get it. I approved this as I prefer keeping the ref counting isolate. It's too easy to misuse disabling of ref counting. On Thu, May 16, 2013 at 2:56 PM, <robertshield@chromium.org> wrote: > On 2013/05/16 19:49:06, robertshield wrote: >> >> On 2013/05/16 19:26:49, sky wrote: >> > > > > https://codereview.chromium.org/15134004/diff/3001/chrome/browser/ui/views/un... >> >> > File chrome/browser/ui/views/uninstall_view.cc (right): >> > >> > > > > https://codereview.chromium.org/15134004/diff/3001/chrome/browser/ui/views/un... >> >> > chrome/browser/ui/views/uninstall_view.cc:178: >> > g_browser_process->AddRefModule(); >> > How does the ref count end up hitting 0 here? > > >> It doesn't. This method is called only via DoUninstallTasks in >> ChromeBrowserMainParts::PreMainMessageLoopRunImpl. When it returns, Chrome >> exits, never starting the main message loops. > > > See here for an alternate approach that blocks the AddRef/Release calls from > views during startup: https://codereview.chromium.org/14845020/ > > https://codereview.chromium.org/15134004/
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/robertshield@chromium.org/15134004/3001
Message was sent while issue was closed.
Change committed as 200732 |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
