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

Unified Diff: third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp

Issue 1680563002: Improve MediaStreamTrack's hasPendingActivity predicate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp
diff --git a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp
index 2dbab3b640342811d0596e906da702aa77ea7db5..68bffa34dd684a47015ed787f1aea43f14f37dbb 100644
--- a/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp
+++ b/third_party/WebKit/Source/modules/mediastream/MediaStreamTrack.cpp
@@ -212,7 +212,19 @@ void MediaStreamTrack::stop()
bool MediaStreamTrack::hasPendingActivity() const
{
- return !m_stopped && hasEventListeners();
+ // If 'ended' listeners exist and the object hasn't yet reached
+ // that state, keep the object alive.
+ //
+ // An otherwise unreachable MediaStreamTrack object in an non-ended
+ // state will otherwise indirectly be transitioned to the 'ended' state
+ // while finalizing m_component. Which dispatches an 'ended' event,
+ // referring to this object as the target. If this object is then GCed
+ // at the same time, v8 objects will retain (wrapper) references to
+ // this dead MediaStreamTrack object. Bad.
+ //
+ // Hence insisting on keeping this object alive until the 'ended'
+ // state has been reached & handled.
+ return !ended() && hasEventListeners(EventTypeNames::ended);
}
PassOwnPtr<AudioSourceProvider> MediaStreamTrack::createWebAudioSource()
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698