⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 281188 in webkit


Ignore:
Timestamp:
Aug 18, 2021, 8:25:04 AM (5 years ago)
Author:
Chris Dumez
Message:

Crash under JSIntersectionObserverCallback::handleEvent()
​https://bugs.webkit.org/show_bug.cgi?id=229196
<rdar://82016054>

Reviewed by Geoffrey Garen.

Early return in IntersectionObserver::notify() if the callback has already been destroyed.
This is not supposed to happen as we're supposed to be keeping the JSIntersectionObserver
wrapper alive as long as the IntersectionObserver may fire events, which should keep the
callback alive too. However, despite Ryosuke's fix in r280549, the crash is still happening
in the wild. To address the crash, I am simply doing an early return for now, similarly to
what we already do in MutationObserver::deliver(), while keeping a debug assertion around
in hope of finding the root cause at some point.

No new tests, we do not not how this is happening yet.

  • page/IntersectionObserver.cpp:

(WebCore::IntersectionObserver::notify):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r281185 r281188  
     12021-08-18  Chris Dumez  <cdumez@apple.com>
     2
     3        Crash under JSIntersectionObserverCallback::handleEvent()
     4        https://bugs.webkit.org/show_bug.cgi?id=229196
     5        <rdar://82016054>
     6
     7        Reviewed by Geoffrey Garen.
     8
     9        Early return in IntersectionObserver::notify() if the callback has already been destroyed.
     10        This is not supposed to happen as we're supposed to be keeping the JSIntersectionObserver
     11        wrapper alive as long as the IntersectionObserver may fire events, which should keep the
     12        callback alive too. However, despite Ryosuke's fix in r280549, the crash is still happening
     13        in the wild. To address the crash, I am simply doing an early return for now, similarly to
     14        what we already do in MutationObserver::deliver(), while keeping a debug assertion around
     15        in hope of finding the root cause at some point.
     16
     17        No new tests, we do not not how this is happening yet.
     18
     19        * page/IntersectionObserver.cpp:
     20        (WebCore::IntersectionObserver::notify):
     21
    1222021-08-18  Martin Robinson  <mrobinson@webkit.org>
    223
  • trunk/Source/WebCore/html/LazyLoadFrameObserver.cpp

    r279800 r281188  
    4444
    4545private:
     46    bool hasCallback() const final { return true; }
     47
    4648    CallbackResult<void> handleEvent(IntersectionObserver&, const Vector<Ref<IntersectionObserverEntry>>& entries, IntersectionObserver&) final
    4749    {
  • trunk/Source/WebCore/html/LazyLoadImageObserver.cpp

    r279800 r281188  
    4444
    4545private:
     46    bool hasCallback() const final { return true; }
     47
    4648    CallbackResult<void> handleEvent(IntersectionObserver&, const Vector<Ref<IntersectionObserverEntry>>& entries, IntersectionObserver&) final
    4749    {
  • trunk/Source/WebCore/page/IntersectionObserver.cpp

    r280549 r281188  
    274274    }
    275275
     276    auto takenRecords = takeRecords();
     277
     278    // FIXME: The JSIntersectionObserver wrapper should be kept alive as long as the intersection observer can fire events.
     279    ASSERT(m_callback->hasCallback());
     280    if (!m_callback->hasCallback())
     281        return;
     282
    276283    auto* context = m_callback->scriptExecutionContext();
    277284    if (!context)
    278285        return;
    279 
    280     auto takenRecords = takeRecords();
    281286
    282287    InspectorInstrumentation::willFireObserverCallback(*context, "IntersectionObserver"_s);
  • trunk/Source/WebCore/page/IntersectionObserverCallback.h

    r269141 r281188  
    4242    using ActiveDOMCallback::ActiveDOMCallback;
    4343
    44     virtual bool hasCallback() const { return false; }
     44    virtual bool hasCallback() const = 0;
    4545
    4646    virtual CallbackResult<void> handleEvent(IntersectionObserver&, const Vector<Ref<IntersectionObserverEntry>>&, IntersectionObserver&) = 0;
  • trunk/Source/WebCore/page/ResizeObserver.cpp

    r280551 r281188  
    125125    auto activeObservationTargets = std::exchange(m_activeObservationTargets, { });
    126126
     127    // FIXME: The JSResizeObserver wrapper should be kept alive as long as the resize observer can fire events.
     128    ASSERT(m_callback->hasCallback());
     129    if (!m_callback->hasCallback())
     130        return;
     131
    127132    auto* context = m_callback->scriptExecutionContext();
    128133    if (!context)
Note: See TracChangeset for help on using the changeset viewer.