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

Unified Diff: third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp

Issue 2377953002: Make hasPendingActivity return false after the associated browsing context is detached (Closed)
Patch Set: temp Created 4 years, 2 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/bindings/core/v8/V8GCController.cpp
diff --git a/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp b/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp
index 495da2103d2e16abe2651b8071badbdfd89fcc71..b7fd54ad2023baeac542ff27a43d931ceeeb44e6 100644
--- a/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp
+++ b/third_party/WebKit/Source/bindings/core/v8/V8GCController.cpp
@@ -172,8 +172,21 @@ class MajorGCWrapperVisitor : public v8::PersistentHandleVisitor {
const WrapperTypeInfo* type = toWrapperTypeInfo(wrapper);
if (type->isActiveScriptWrappable() &&
toScriptWrappable(wrapper)->hasPendingActivity()) {
- m_isolate->SetObjectGroupId(*value, liveRootId());
- ++m_domObjectsWithPendingActivity;
+ // Enable hasPendingActivity only when the associated
+ // ExecutionContext is not yet detached. This is a work-around
+ // to avoid memory leaks caused by hasPendingActivity that keeps
+ // returning true forever. This will be okay in practice because
+ // the spec requires to stop almost all DOM activities when the
+ // associated browsing context is detached. However, the real
+ // problem is that some hasPendingActivity's are wrongly implemented
+ // and never return false.
+ // TODO(haraken): Implement correct lifetime using traceWrapper.
+ ExecutionContext* context =
+ toExecutionContext(wrapper->CreationContext());
+ if (context && !context->activeDOMObjectsAreStopped()) {
+ m_isolate->SetObjectGroupId(*value, liveRootId());
+ ++m_domObjectsWithPendingActivity;
+ }
}
if (classId == WrapperTypeInfo::NodeClassId) {
@@ -489,21 +502,14 @@ class PendingActivityVisitor : public v8::PersistentHandleVisitor {
ASSERT(V8DOMWrapper::hasInternalFieldsSet(wrapper));
// The ExecutionContext check is heavy, so it should be done at the last.
if (toWrapperTypeInfo(wrapper)->isActiveScriptWrappable() &&
- toScriptWrappable(wrapper)->hasPendingActivity()
- // TODO(haraken): Currently we don't have a way to get a creation
- // context from a wrapper. We should implement the way and enable
- // the following condition.
- //
- // This condition affects only compositor workers, where one isolate
- // is shared by multiple workers. If we don't have the condition,
- // a worker object for a compositor worker doesn't get collected
- // until all compositor workers in the same isolate lose pending
- // activities. In other words, not having the condition delays
- // destruction of a worker object of a compositor worker.
- //
- /* && toExecutionContext(wrapper->creationContext()) == m_executionContext */
- )
- m_pendingActivityFound = true;
+ toScriptWrappable(wrapper)->hasPendingActivity()) {
+ // See the comment in MajorGCWrapperVisitor::VisitPersistentHandle.
+ ExecutionContext* context =
+ toExecutionContext(wrapper->CreationContext());
+ if (context == m_executionContext && context &&
+ !context->activeDOMObjectsAreStopped())
+ m_pendingActivityFound = true;
+ }
}
bool pendingActivityFound() const { return m_pendingActivityFound; }
« 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