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

Changeset 264945 in webkit


Ignore:
Timestamp:
Jul 27, 2020, 2:57:15 PM (6 years ago)
Author:
timothy_horton@apple.com
Message:

Occasional crashes under PDFPlugin::createScrollbar and PDFPlugin::updateScrollbars
https://bugs.webkit.org/show_bug.cgi?id=214845
<rdar://problem/59293598>

Reviewed by Brady Eidson.

No new tests; timing is such that I can't reproduce without inserting
intentional delays into the main thread hops, which is further than
I'm willing to go for a test.

This is a speculative fix due to the aforementioned reproducibility issue.

  • WebProcess/Plugins/PDF/PDFPlugin.h:
  • WebProcess/Plugins/PDF/PDFPlugin.mm:

(WebKit::PDFPlugin::destroy):
Keep track of when destroy() has been called.

(WebKit::PDFPlugin::receivedNonLinearizedPDFSentinel):
(WebKit::PDFPlugin::threadEntry):
If the PDFPlugin is destroyed (explicit destroy(), not the destructor, which won't run since we're protecting this)
during the window in which the PDF thread is dispatching to the main thread, just ignore
the callback. We don't want to run it, because many of the things we depend on (like PluginView)
are disconnected at this point.

(WebKit::PDFPlugin::scrollbarStyleChanged):
It appears that in some much rarer case, even before the PDF thread existed, WebScrollerImpPairDelegate could
call us back after being destroy()'d but before being deallocated. Use the new bit to guard scrollbarStyleChanged().

Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r264928 r264945  
     12020-07-27  Tim Horton  <timothy_horton@apple.com>
     2
     3        Occasional crashes under PDFPlugin::createScrollbar and PDFPlugin::updateScrollbars
     4        https://bugs.webkit.org/show_bug.cgi?id=214845
     5        <rdar://problem/59293598>
     6
     7        Reviewed by Brady Eidson.
     8
     9        No new tests; timing is such that I can't reproduce without inserting
     10        intentional delays into the main thread hops, which is further than
     11        I'm willing to go for a test.
     12
     13        This is a speculative fix due to the aforementioned reproducibility issue.
     14
     15        * WebProcess/Plugins/PDF/PDFPlugin.h:
     16        * WebProcess/Plugins/PDF/PDFPlugin.mm:
     17        (WebKit::PDFPlugin::destroy):
     18        Keep track of when destroy() has been called.
     19
     20        (WebKit::PDFPlugin::receivedNonLinearizedPDFSentinel):
     21        (WebKit::PDFPlugin::threadEntry):
     22        If the PDFPlugin is destroyed (explicit destroy(), not the destructor, which won't run since we're protecting `this`)
     23        during the window in which the PDF thread is dispatching to the main thread, just ignore
     24        the callback. We don't want to run it, because many of the things we depend on (like PluginView)
     25        are disconnected at this point.
     26
     27        (WebKit::PDFPlugin::scrollbarStyleChanged):
     28        It appears that in some much rarer case, even before the PDF thread existed, WebScrollerImpPairDelegate could
     29        call us back after being destroy()'d but before being deallocated. Use the new bit to guard scrollbarStyleChanged().
     30
    1312020-07-27  Megan Gardner  <megan_gardner@apple.com>
    232
  • trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.h

    r260981 r264945  
    332332
    333333    bool m_documentFinishedLoading { false };
     334    bool m_hasBeenDestroyed { false };
    334335    unsigned m_firstPageHeight { 0 };
    335336    WebCore::IntSize m_pdfDocumentSize; // All pages, including gaps.
  • trunk/Source/WebKit/WebProcess/Plugins/PDF/PDFPlugin.mm

    r264525 r264945  
    711711#endif
    712712        callOnMainThread([this, protectedThis = makeRef(*this)] {
     713            if (m_hasBeenDestroyed)
     714                return;
    713715            receivedNonLinearizedPDFSentinel();
    714716        });
     
    886888        if (m_incrementalPDFLoadingEnabled) {
    887889            callOnMainThread([this] {
     890                if (m_hasBeenDestroyed)
     891                    return;
    888892                adoptBackgroundThreadDocument();
    889893            });
     
    14311435{
    14321436    if (!forceUpdate)
     1437        return;
     1438
     1439    if (m_hasBeenDestroyed)
    14331440        return;
    14341441
     
    17911798void PDFPlugin::destroy()
    17921799{
     1800    m_hasBeenDestroyed = true;
    17931801    m_documentFinishedLoading = true;
    17941802
Note: See TracChangeset for help on using the changeset viewer.