New issue
Advanced search Search tips

Issue 774175 link

Starred by 3 users

Issue metadata

Status: Assigned
Merged: issue 772353
Owner:
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Linux , Windows , Chrome , Mac
Pri: 3
Type: Bug



Sign in to add a comment

SigninViewControllerDelegate needs better ownership control

Project Member Reported by a...@chromium.org, Oct 12 2017

Issue description

SigninViewControllerDelegate uses WebContentsModalDialogManager is a peculiar way.

WebContentsModalDialogManager owns the dialogs run on a WebContents, and itself is tied lifetime-wise to that WebContents. However, SinginViewControllerDelegate makes a WebContents, binds a WebContentsModalDialogManager to it (making the WebContentsModalDialogManager share the WebContents's lifetime), makes a modal dialog, and then makes the WebContents be the contents of the dialog.

The ownership picture is then: WebContents owns the WebContentsModalDialogManager (which is tied to the lifetime of the WebContents), which owns a dialog, which owns the WebContents starting this all.

This ouroboros, as you'd imagine, has lifetime fragility issues.

In fixing a crash ( bug 760507 ), I added a check for visibility (https://crrev.com/c/653800). However, in the case of closing a SigninViewControllerDelegate, that check hit a dangling delegate pointer and crashed. That led to a hilarious series of bugs (bug 771142,  bug 771872 ,  bug 772745 ) that got worse and worse as I misunderstood the ownership issues of SigninViewControllerDelegate and broke it more and more.

Those are fixed, and there is a bandaid over the crash in bug 771142. However, that bandaid avoids the crash by short-circuiting early and avoiding touching the dangling delegate.

There _shouldn't be_ dangling delegate pointers in the code. Right now, the whole teardown scenario of SigninViewControllerDelegate is incredibly fragile.

If indeed putting a WebContents into a dialog owned by a WebContentsModalDialogManager attached to that very WebContents is intended to be a supported use case, the lifetime issues need to be officially addressed with better mechanisms which need to be retrofitted into SigninViewControllerDelegate. The situation we're in right now, where the "obviously" correct thing to do is completely wrong, is not a good situation to be in.
 

Comment 1 by a...@chromium.org, Oct 12 2017

(The band-aid is the change to WebContentsModalDialogManager, made in https://crrev.com/c/698666, which was the change intended to address bug 771142.)

Comment 2 by a...@chromium.org, Oct 18 2017

Summary: SigninViewControllerDelegate needs better ownership control (was: SinginViewControllerDelegate needs better ownership control)

Comment 3 by msarda@chromium.org, Oct 18 2017

Mergedinto: 772353
Status: Duplicate (was: Assigned)
Here is what I imagined to do:
* make SigninViewController own its delegate
* change the DeleteDialog from the delegate to actually call SigninViewController that will destroy it

If this seems reasonable, then i could take a look and try to fix this ownershipt issue.

Comment 4 by msarda@chromium.org, Oct 18 2017

Status: (was: Duplicate)
I did not want to duplicate this bug, sorry.

Comment 5 by msarda@chromium.org, Oct 18 2017

Status: Assigned

Comment 6 by msarda@chromium.org, Oct 18 2017

Cc: wittman@chromium.org msarda@chromium.org droger@chromium.org
 Issue 772353  has been merged into this issue.

Comment 7 by msarda@chromium.org, Oct 18 2017

Components: Services>SignIn
Owner: ----
Status: Available (was: Assigned)
Owner: msarda@chromium.org
Status: Assigned (was: Available)

Sign in to add a comment