Repository navigation
[resize-observer] Crash when observing an element multiple times - #69080
Conversation
|
EWS run on previous version of this PR (hash 66726d4) Details |
macOS Safer C++ Build #119856 (66726d4)❌ Found 31 failing files with 119 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
66726d4 to
8e94de5
Compare
|
EWS run on previous version of this PR (hash 8e94de5) Details |
|
@tuankiet65 - This is something tested by WPT showed this (via History - test15 failing and timing out) - https://wpt.fyi/results/resize-observer/observe.html?label=experimental&label=master&aligned When rebasing my patch in another ResizeObserver branch, I hit same thing and did drive-by fix (but different way), I will rebase my branch later on - #60534 - Thanks for tackling this. |
|
Fun - thank you for bringing that up. I think I'll enable that |
|
It still timeouts because |
|
Okay, I split it into different test files here: #69291. That'll go in first, then this, then you can rebase on top of everything. cc @Ahmad-S792. |
…te tests rdar://182125983 https://bugs.webkit.org/show_bug.cgi?id=319287 Reviewed by Tim Nguyen. /resize-observer/observe.html contains 20 different subtests which are run sequentially, so one test timing out will block subsequent tests from running. Fix this by splitting it into 20 different test files. The motivation of this change is from WebKit#69080, which fixes test 15. Turns out, /resize-observer/observe.html has been marked as skipped because it times out. On further investigation, we do pass most of the subtests, but because of test 15 timing out, we don't have visibility into whether subsequent tests also pass or not. * LayoutTests/TestExpectations: * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-001-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-001.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-002-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-002.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-003-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-003.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-004-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-004.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-005-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-005.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-006-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-006.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-007-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-007.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-008-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-008.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-009-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-009.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-010-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-010.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-011-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-011.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-012-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-012.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-013-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-013.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-014-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-014.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-015-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-015.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-016-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-016.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-017-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-017.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-018-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-018.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-019-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-019.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-020-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-020.html: Added. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-expected.txt: Removed. * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe.html: Removed. Canonical link: https://commits.webkit.org/317175@main
8e94de5 to
32c37e7
Compare
|
EWS run on current version of this PR (hash 32c37e7) Details
|
macOS Safer C++ Build #120839 (32c37e7)❌ Found 32 failing files with 121 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
iOS Safer C++ Build #39839 (32c37e7)❌ Found 52 failing files with 1028 issues. Please address these issues before landing. See WebKit Guidelines for Safer C++ Programming. |
32c37e7 to
de3601d
Compare
rdar://181487491 https://bugs.webkit.org/show_bug.cgi?id=319009 Reviewed by Ryosuke Niwa. In ResizeObserver, an observation in m_observations should exist in m_observationMap and vice versa. But this invariant is broken if an element is observed twice with different box options: void ResizeObserver::observeInternal(Element& target, const ResizeObserverBoxOptions boxOptions) { ASSERT(!m_JSOrNativeCallback.valueless_by_exception()); auto addResult = m_observationMap.ensure(target, [&]() { return ResizeObservation::create(target, boxOptions); }); <-- (a) Ref observation = addResult.iterator->value; if (!addResult.isNewEntry) { // The spec suggests unconditionally unobserving here, but that causes a test failure: // web-platform-tests/wpt#30708 if (observation->observedBox() == boxOptions) return; unobserve(target); <-- (b) } // (c) auto& observerData = target.ensureResizeObserverData(); observerData.observers.append(*this); m_observations.add(WTF::move(observation)); [...] } (a) adds the element to m_observationMap if one doesn't exist, (b) unobserves if the element is already being observed but the new observation requests different box options, and (c) adds the element to m_observations. If an element is observed twice like this: observer.observe(input); observer.observe(input, { box: "border-box" }); On the second observation: (a) does not add anything to m_observationMap because it's already observed. (b) unobserve() removes the element from both m_observationMap and m_observations, and (c) adds it to m_observations, but crucially, it does not add it back to m_observationMap. This breaks the invariant between m_observation and m_observationMap. Fix this by first testing if the element is observed first. If it is, unobserve it before adding the element to m_observationMap and m_observation. Additionally, harden ResizeObserverData::observers by making it a WeakHashSet, so iterating through it would skip already freed observers. Test: imported/w3c/web-platform-tests/resize-observer/observe-015.html imported/w3c/web-platform-tests/resize-observer/observe-018.html resize-observer/resize-observer-observe-multiple-then-gc.html * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-015-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/resize-observer/observe-018-expected.txt: - Test progression. * LayoutTests/resize-observer/resize-observer-observe-multiple-then-gc-expected.txt: Added. * LayoutTests/resize-observer/resize-observer-observe-multiple-then-gc.html: Added. - Added test. The crash is during when an observed element is freed, so it needs to call the internal GC method and can't be upstreamed to WPT. * Source/WebCore/dom/Element.cpp: (WebCore::Element::disconnectFromResizeObserversSlow): * Source/WebCore/page/ResizeObserver.cpp: (WebCore::ResizeObserver::observeInternal): (WebCore::ResizeObserver::removeTarget): * Source/WebCore/page/ResizeObserver.h: Canonical link: https://commits.webkit.org/317224@main
de3601d to
bd130fc
Compare
|
Committed 317224@main (bd130fc): https://commits.webkit.org/317224@main Reviewed commits have been landed. Closing PR #69080 and removing active labels. |
🛠 vision-apple
bd130fc
32c37e7
🧪 win-tests🛠 playstation