Changeset 269141 in webkit
- Timestamp:
- Oct 29, 2020, 1:15:18 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 8 edited
- 1 copied
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/intersection-observer/intersection-observer-callback-after-gc-expected.txt (added)
-
LayoutTests/intersection-observer/intersection-observer-callback-after-gc.html (added)
-
LayoutTests/intersection-observer/intersection-observer-callback-leak-expected.txt (added)
-
LayoutTests/intersection-observer/intersection-observer-callback-leak.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Sources.txt (modified) (1 diff)
-
Source/WebCore/WebCore.xcodeproj/project.pbxproj (modified) (2 diffs)
-
Source/WebCore/bindings/js/JSIntersectionObserverCustom.cpp (copied) (copied from trunk/Source/WebCore/page/IntersectionObserverCallback.idl ) (2 diffs)
-
Source/WebCore/page/IntersectionObserver.h (modified) (1 diff)
-
Source/WebCore/page/IntersectionObserver.idl (modified) (1 diff)
-
Source/WebCore/page/IntersectionObserverCallback.h (modified) (1 diff)
-
Source/WebCore/page/IntersectionObserverCallback.idl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r269137 r269141 1 2020-10-29 Cathie Chen <cathiechen@igalia.com> 2 3 IntersectionObserverCallback leak 4 https://bugs.webkit.org/show_bug.cgi?id=218225 5 6 Reviewed by Ryosuke Niwa. 7 8 In intersection-observer-callback-after-gc.html, the callbacks with observed targets deleted should stay alive as long as observers are alive. 9 In intersection-observer-callback-leak.html, use `internals.numberOfLiveNodes` to check that the objects inside JSIntersectionObserverCallback 10 can be garbage collected. 11 12 * intersection-observer/intersection-observer-callback-after-gc-expected.txt: Added. 13 * intersection-observer/intersection-observer-callback-after-gc.html: Added. 14 * intersection-observer/intersection-observer-callback-leak-expected.txt: Added. 15 * intersection-observer/intersection-observer-callback-leak.html: Added. 16 1 17 2020-10-28 Julian Gonzalez <julian_a_gonzalez@apple.com> 2 18 -
trunk/Source/WebCore/ChangeLog
r269137 r269141 1 2020-10-29 Cathie Chen <cathiechen@igalia.com> 2 3 IntersectionObserverCallback leaks 4 https://bugs.webkit.org/show_bug.cgi?id=218225 5 6 Reviewed by Ryosuke Niwa. 7 8 Unless the page is unloaded, JSIntersectionObserverCallback and objects inside it can not be garbage collected properly. 9 To fix this, make IntersectionObserverCallback as a weak callback. To keep it alive, in JSIntersectionObserver::visitAdditionalChildren 10 add the callback to visitor. 11 12 Test: intersection-observer/intersection-observer-callback-leak.html 13 14 * Sources.txt: 15 * WebCore.xcodeproj/project.pbxproj: 16 * bindings/js/JSIntersectionObserverCustom.cpp: Copied from Source/WebCore/page/IntersectionObserverCallback.idl. 17 (WebCore::JSIntersectionObserver::visitAdditionalChildren): 18 * page/IntersectionObserver.h: 19 (WebCore::IntersectionObserver::callbackConcurrently): 20 * page/IntersectionObserver.idl: 21 * page/IntersectionObserverCallback.h: 22 (WebCore::IntersectionObserverCallback::hasCallback const): 23 * page/IntersectionObserverCallback.idl: 24 1 25 2020-10-28 Julian Gonzalez <julian_a_gonzalez@apple.com> 2 26 -
trunk/Source/WebCore/Sources.txt
r269081 r269141 546 546 bindings/js/JSIDBSerializationGlobalObject.cpp 547 547 bindings/js/JSImageDataCustom.cpp 548 bindings/js/JSIntersectionObserverCustom.cpp 548 549 bindings/js/JSIntersectionObserverEntryCustom.cpp 549 550 bindings/js/JSLazyEventListener.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r269081 r269141 10013 10013 77AAD6831ECFB66200BFA2D1 /* CredentialCreationOptions.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CredentialCreationOptions.idl; sourceTree = "<group>"; }; 10014 10014 77AAD6851ECFBD3900BFA2D1 /* CredentialCreationOptions.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CredentialCreationOptions.h; sourceTree = "<group>"; }; 10015 5868C7D52546E0B300BF9DF3 /* JSIntersectionObserverCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIntersectionObserverCustom.cpp; sourceTree = "<group>"; }; 10015 10016 77C13F042165658A002D9C5F /* JSIntersectionObserverEntryCustom.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = JSIntersectionObserverEntryCustom.cpp; sourceTree = "<group>"; }; 10016 10017 77CAAAEF1F2FC35000CB5C8D /* VisualViewport.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = VisualViewport.idl; sourceTree = "<group>"; }; … … 22364 22365 51E269321DD3BC43006B6A58 /* JSIDBTransactionCustom.cpp */, 22365 22366 A7D0318D0E93540300E24ACD /* JSImageDataCustom.cpp */, 22367 5868C7D52546E0B300BF9DF3 /* JSIntersectionObserverCustom.cpp */, 22366 22368 77C13F042165658A002D9C5F /* JSIntersectionObserverEntryCustom.cpp */, 22367 22369 CD0320152279F5BF00DD9F0B /* JSMediaCapabilitiesCustom.h */, -
trunk/Source/WebCore/bindings/js/JSIntersectionObserverCustom.cpp
r269137 r269141 1 1 /* 2 * Copyright (C) 20 16 Apple Inc. All rights reserved.2 * Copyright (C) 2020 Igalia S.L. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 24 24 */ 25 25 26 // https://wicg.github.io/IntersectionObserver/ 26 #include "config.h" 27 #include "JSIntersectionObserver.h" 27 28 28 [ 29 Conditional=INTERSECTION_OBSERVER, 30 CallbackThisObject=IntersectionObserver, 31 ] callback IntersectionObserverCallback = undefined (sequence<IntersectionObserverEntry> entries, IntersectionObserver observer); 29 #include <JavaScriptCore/JSCInlines.h> 30 31 namespace WebCore { 32 33 void JSIntersectionObserver::visitAdditionalChildren(JSC::SlotVisitor& visitor) 34 { 35 if (auto* callback = wrapped().callbackConcurrently()) 36 callback->visitJSFunction(visitor); 37 } 38 39 } -
trunk/Source/WebCore/page/IntersectionObserver.h
r260736 r269141 100 100 void notify(); 101 101 102 IntersectionObserverCallback* callbackConcurrently() { return m_callback.get(); } 103 102 104 private: 103 105 IntersectionObserver(Document&, Ref<IntersectionObserverCallback>&&, ContainerNode* root, LengthBox&& parsedRootMargin, Vector<double>&& thresholds); -
trunk/Source/WebCore/page/IntersectionObserver.idl
r267813 r269141 30 30 Conditional=INTERSECTION_OBSERVER, 31 31 EnabledBySetting=IntersectionObserver, 32 Exposed=Window 32 Exposed=Window, 33 JSCustomMarkFunction, 33 34 ] interface IntersectionObserver { 34 35 [CallWith=Document] constructor(IntersectionObserverCallback callback, optional IntersectionObserverInit options); -
trunk/Source/WebCore/page/IntersectionObserverCallback.h
r265397 r269141 42 42 using ActiveDOMCallback::ActiveDOMCallback; 43 43 44 virtual bool hasCallback() const { return false; } 45 44 46 virtual CallbackResult<void> handleEvent(IntersectionObserver&, const Vector<Ref<IntersectionObserverEntry>>&, IntersectionObserver&) = 0; 45 47 }; -
trunk/Source/WebCore/page/IntersectionObserverCallback.idl
r266311 r269141 29 29 Conditional=INTERSECTION_OBSERVER, 30 30 CallbackThisObject=IntersectionObserver, 31 IsWeakCallback, 31 32 ] callback IntersectionObserverCallback = undefined (sequence<IntersectionObserverEntry> entries, IntersectionObserver observer);
Note:
See TracChangeset
for help on using the changeset viewer.