[webkit-changes] [WebKit/WebKit] 37dfbb: Make Frame::m_mainFrame a WeakPtr instead of WeakRef

Alex Christensen noreply at github.com
Fri Jan 10 22:07:46 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 37dfbbf4e29e7e44ab8bc032f6b9027450651a2c
      https://github.com/WebKit/WebKit/commit/37dfbbf4e29e7e44ab8bc032f6b9027450651a2c
  Author: Alex Christensen <achristensen at apple.com>
  Date:   2025-01-10 (Fri, 10 Jan 2025)

  Changed paths:
    M Source/WebCore/page/Frame.h
    M Source/WebCore/page/LocalFrame.cpp
    M Source/WebCore/page/LocalFrame.h

  Log Message:
  -----------
  Make Frame::m_mainFrame a WeakPtr instead of WeakRef
https://bugs.webkit.org/show_bug.cgi?id=285792
rdar://142724245

Reviewed by Chris Dumez.

I'm seeing a long tail of crashes from something calling Frame::isMainFrame
during teardown when the main frame has already been destroyed but something
is keeping a non-main frame alive with a RefPtr.  That is because WeakRef::get
and WeakRef::ptr have a release assertion that the object they point to has
not yet been destroyed.  Switching to a WeakPtr will make it more tolerant
of nondeterministic teardown order with reference counting of Frames.

While I was at it, I made the accessors more const correct and did the same
thing to LocalFrame's m_rootFrame.

* Source/WebCore/page/Frame.h:
(WebCore::Frame::mainFrame):
(WebCore::Frame::mainFrame const):
(WebCore::Frame::isMainFrame const):
* Source/WebCore/page/LocalFrame.cpp:
(WebCore::LocalFrame::localMainFrame const):
(WebCore::LocalFrame::localMainFrame):
* Source/WebCore/page/LocalFrame.h:

Canonical link: https://commits.webkit.org/288755@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list