Sometimes, we're not removing InShadowTreeFlag after removing a node. In addition, I'm fixing a bug in VTTCue::~VTTCue that it could ref a document while the document is being destructed.
Created attachment 280510 [details] Fixes the bug
Comment on attachment 280510 [details] Fixes the bug View in context: https://bugs.webkit.org/attachment.cgi?id=280510&action=review > Source/WebCore/html/track/VTTCue.cpp:271 > + if (m_displayTree && m_displayTree->document().refCount()) It seems very odd to have to check the document ref count. It is also weird that bodes would have to remove themselves from the tree upon destruction. I could not find the code that adds this displayTree to the DOM.
(In reply to comment #2) > Comment on attachment 280510 [details] > Fixes the bug > > View in context: > https://bugs.webkit.org/attachment.cgi?id=280510&action=review > > > Source/WebCore/html/track/VTTCue.cpp:271 > > + if (m_displayTree && m_displayTree->document().refCount()) > > It seems very odd to have to check the document ref count. It is also weird > that bodes would have to remove themselves from the tree upon destruction. I > could not find the code that adds this displayTree to the DOM. That's done in HTMLMediaElement. The problem here is that m_displayTree refers back to VTTCue using a reference so we can end up doing a use-after-free if we don't remove the nodes from the UA shadow tree. However, when the document itself is being destructed, we don't need to do this because we won't be updating style, etc... anymore. On the other hand, Node::remove would try to ref the document before dispatching mutation events, and this would hit an assertion since we've already began destructing the document. An alternative approach would be to change the reference to a pointer and set it to null when VTTCue is getting destroyed.
> An alternative approach would be to change the reference to a pointer and > set it to null when VTTCue is getting destroyed. That might be nicer.
(In reply to comment #4) > > An alternative approach would be to change the reference to a pointer and > > set it to null when VTTCue is getting destroyed. > > That might be nicer. I'm going to add a FIXME for now since I'm not an expert on this area and I couldn't get a feedback from Eric & Jer.
<rdar://problem/26664749>
Committed r201736: <http://trac.webkit.org/changeset/201736>