Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Issue 2714643008: NetworkStateNotifier: also remove NetworkStateObserver in finalizer too (Closed)

Created:
3 years, 10 months ago by kinuko
Modified:
3 years, 9 months ago
CC:
chromium-reviews, eae+blinkwatch, blink-reviews-dom_chromium.org, dglazkov+blink, blink-reviews, rwlbuis
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

NetworkStateNotifier: also remove NetworkStateObserver in finalizer too I was wrong that contextDestroy is not always called before the document gets destructed. Make sure we remove NetworkStateNotifier in finalizer too to avoid crash. BUG=695783 TEST=See the bug for repro Review-Url: https://codereview.chromium.org/2714643008 Cr-Commit-Position: refs/heads/master@{#452870} Committed: https://chromium.googlesource.com/chromium/src/+/ef33cbc2c4e56e2aa5c1503b7cbaf0b826c3affe

Patch Set 1 #

Total comments: 7

Patch Set 2 : . #

Total comments: 2

Patch Set 3 : add comment + another method #

Unified diffs Side-by-side diffs Delta from patch set Stats (+11 lines, -1 line) Patch
M third_party/WebKit/Source/core/dom/Document.cpp View 1 2 3 chunks +11 lines, -1 line 0 comments Download

Messages

Total messages: 36 (16 generated)
kinuko
So looks like I was wrong about Document / NetworkStateObserver destruction... could you review?
3 years, 10 months ago (2017-02-24 12:58:50 UTC) #5
jkarlin
https://codereview.chromium.org/2714643008/diff/1/third_party/WebKit/Source/core/dom/Document.cpp File third_party/WebKit/Source/core/dom/Document.cpp (right): https://codereview.chromium.org/2714643008/diff/1/third_party/WebKit/Source/core/dom/Document.cpp#newcode413 third_party/WebKit/Source/core/dom/Document.cpp:413: USING_PRE_FINALIZER(Document::NetworkStateObserver, dispose); Why PRE_FINALIZER instead of normal destructor? https://codereview.chromium.org/2714643008/diff/1/third_party/WebKit/Source/core/dom/Document.cpp#newcode447 ...
3 years, 10 months ago (2017-02-24 13:13:51 UTC) #6
kinuko
Thanks! +oilpan-reviews@ too https://codereview.chromium.org/2714643008/diff/1/third_party/WebKit/Source/core/dom/Document.cpp File third_party/WebKit/Source/core/dom/Document.cpp (right): https://codereview.chromium.org/2714643008/diff/1/third_party/WebKit/Source/core/dom/Document.cpp#newcode413 third_party/WebKit/Source/core/dom/Document.cpp:413: USING_PRE_FINALIZER(Document::NetworkStateObserver, dispose); On 2017/02/24 13:13:51, jkarlin ...
3 years, 10 months ago (2017-02-24 13:56:25 UTC) #14
jkarlin
https://codereview.chromium.org/2714643008/diff/1/third_party/WebKit/Source/core/dom/Document.cpp File third_party/WebKit/Source/core/dom/Document.cpp (right): https://codereview.chromium.org/2714643008/diff/1/third_party/WebKit/Source/core/dom/Document.cpp#newcode413 third_party/WebKit/Source/core/dom/Document.cpp:413: USING_PRE_FINALIZER(Document::NetworkStateObserver, dispose); On 2017/02/24 13:56:25, kinuko wrote: > On ...
3 years, 10 months ago (2017-02-24 14:20:06 UTC) #15
sof
lgtm from my side, a case of Document::shutdown() not being called. I wonder if we ...
3 years, 10 months ago (2017-02-24 14:21:59 UTC) #17
kinuko
Thanks! I agree that we should avoid storing unsafe raw observer pointers, will try to ...
3 years, 10 months ago (2017-02-24 14:43:16 UTC) #18
jkarlin
lgtm https://codereview.chromium.org/2714643008/diff/1/third_party/WebKit/Source/core/dom/Document.cpp File third_party/WebKit/Source/core/dom/Document.cpp (right): https://codereview.chromium.org/2714643008/diff/1/third_party/WebKit/Source/core/dom/Document.cpp#newcode413 third_party/WebKit/Source/core/dom/Document.cpp:413: USING_PRE_FINALIZER(Document::NetworkStateObserver, dispose); On 2017/02/24 14:43:16, kinuko wrote: > ...
3 years, 10 months ago (2017-02-24 15:31:27 UTC) #19
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.chromium.org/2714643008/60001
3 years, 10 months ago (2017-02-24 16:25:28 UTC) #22
jkarlin
I hit the commit button due to the high crash rate.
3 years, 10 months ago (2017-02-24 16:27:02 UTC) #23
dcheng
Can you help me understand why Document::shutdown() is not called? That seems like a bug.
3 years, 10 months ago (2017-02-24 17:57:12 UTC) #24
commit-bot: I haz the power
Committed patchset #3 (id:60001) as https://chromium.googlesource.com/chromium/src/+/ef33cbc2c4e56e2aa5c1503b7cbaf0b826c3affe
3 years, 10 months ago (2017-02-24 18:08:55 UTC) #27
sof
On 2017/02/24 17:57:12, dcheng wrote: > Can you help me understand why Document::shutdown() is not ...
3 years, 10 months ago (2017-02-24 18:22:55 UTC) #28
dcheng
On 2017/02/24 18:22:55, sof wrote: > On 2017/02/24 17:57:12, dcheng wrote: > > Can you ...
3 years, 10 months ago (2017-02-24 18:26:46 UTC) #29
sof
On 2017/02/24 18:26:46, dcheng wrote: > On 2017/02/24 18:22:55, sof wrote: > > On 2017/02/24 ...
3 years, 10 months ago (2017-02-24 18:41:52 UTC) #30
dcheng
On 2017/02/24 18:41:52, sof wrote: > On 2017/02/24 18:26:46, dcheng wrote: > > On 2017/02/24 ...
3 years, 10 months ago (2017-02-24 19:24:13 UTC) #31
sof
On 2017/02/24 19:24:13, dcheng wrote: > On 2017/02/24 18:41:52, sof wrote: > > On 2017/02/24 ...
3 years, 10 months ago (2017-02-24 20:30:01 UTC) #32
haraken
On 2017/02/24 20:30:01, sof wrote: > On 2017/02/24 19:24:13, dcheng wrote: > > On 2017/02/24 ...
3 years, 10 months ago (2017-02-25 00:43:11 UTC) #33
kinuko
On 2017/02/25 00:43:11, haraken wrote: > On 2017/02/24 20:30:01, sof wrote: > > On 2017/02/24 ...
3 years, 10 months ago (2017-02-25 02:47:43 UTC) #34
haraken
This CL LGTM as a short-term fix. > > Yeah, this CL is doing something ...
3 years, 10 months ago (2017-02-25 02:59:01 UTC) #35
kinuko
3 years, 9 months ago (2017-02-27 06:44:10 UTC) #36
Message was sent while issue was closed.
On 2017/02/25 02:59:01, haraken wrote:
> This CL LGTM as a short-term fix.
> 
> > > Yeah, this CL is doing something weird...
> > > 
> > > Document::shudown() is guaranteed to be called for documents that are
> attached
> > > to frames. Would it be possible to stop attaching a context lifecycle
> observer
> > > to an ExecutionContext that isn't attached to a frame (e.g., a document
> > created
> > > via DOMImplementation)? Or will it break other things? (i.e., is there any
> > > actual scenario where we want to attach a context lifecycle observer to an
> > > ExecutionContext that isn't attached to a frame?)
> > 
> > I agree that what this CL does is very unfortunate / undesirable.  I wanted
to
> > stop registering the observer when the document is not attached but wasn't
> sure
> > about the right behavior either, and needed a fix to stop crashes first 
> > ¯\_(ツ)_/¯  I could try making the follow-up patch, or I wonder if Document
> could
> > just make sure it always advance the lifecycle to call contextDestroyed in
> > prefinalizer if it hasn't?
> 
> Before trying to introducing a pre-finalizer to Document, I might want to see
if
> we can stop attaching a context lifecycle observer to a Document that is not
> attached to a frame. (However, I'm not sure how easy the change will be.)

Do you mean by having an assert or something and see what'll get broken?

I'm not entirely sure if we could (or should) convert all the observers, but for
this particular one it's probably likely ok not to attach when it's not attached
to frames. I'll create a follow-up patch and send a review-

> A pre-finalizer is a bit weird since 1) the timing is GC-dependent (if you do
> something complicated in contextDestroyed, you may end up with exposing a GC
> behavior to user scripts), 2) the pre-finalizer is called during a GC (so
you're
> not allowed to do something complicated in contextDestroyed) and 3) the
> pre-finalizer doesn't get called until Document becomes unreachable (if you're
> clearing a pointer to the document in contextDestroyed, it will leak the
> document).
> 
> > (By the way if you talk about ExecutionContext but not Document let me
remind
> > that ExecutionContext isn't / shouldn't be necessarily associated with
Frames)
> 
> Ah, yes, I meant Document. Documents that are not attached to frames don't
call
> notifyContextDestroyed().

Powered by Google App Engine
This is Rietveld 408576698