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

Changeset 281661 in webkit


Ignore:
Timestamp:
Aug 26, 2021, 3:07:30 PM (5 years ago)
Author:
Cameron McCormack
Message:

Manually release SharedBitmap if CGBitmapContextCreateWithData fails and doesn't do it
https://bugs.webkit.org/show_bug.cgi?id=229428
<rdar://problem/82264138>

Reviewed by Darin Adler.

  • Shared/ShareableBitmap.h:
  • Shared/cg/ShareableBitmapCG.cpp:

(WebKit::ShareableBitmap::createGraphicsContext):
(WebKit::ShareableBitmap::releaseBitmapContextData):

Location:
trunk/Source/WebKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r281646 r281661  
     12021-08-26  Cameron McCormack  <heycam@apple.com>
     2
     3        Manually release SharedBitmap if CGBitmapContextCreateWithData fails and doesn't do it
     4        https://bugs.webkit.org/show_bug.cgi?id=229428
     5        <rdar://problem/82264138>
     6
     7        Reviewed by Darin Adler.
     8
     9        * Shared/ShareableBitmap.h:
     10        * Shared/cg/ShareableBitmapCG.cpp:
     11        (WebKit::ShareableBitmap::createGraphicsContext):
     12        (WebKit::ShareableBitmap::releaseBitmapContextData):
     13
    1142021-08-26  Aditya Keerthi  <akeerthi@apple.com>
    215
  • trunk/Source/WebKit/Shared/ShareableBitmap.h

    r278351 r281661  
    177177#endif
    178178
     179#if USE(CG)
     180    bool m_releaseBitmapContextDataCalled { false };
     181#endif
     182
    179183    // If the shareable bitmap is backed by shared memory, this points to the shared memory object.
    180184    RefPtr<SharedMemory> m_sharedMemory;
  • trunk/Source/WebKit/Shared/cg/ShareableBitmapCG.cpp

    r278351 r281661  
    9898        return nullptr;
    9999
     100    ref(); // Balanced by deref in releaseBitmapContextData.
     101
     102    m_releaseBitmapContextDataCalled = false;
    100103    RetainPtr<CGContextRef> bitmapContext = adoptCF(CGBitmapContextCreateWithData(data(), m_size.width(), m_size.height(), bitsPerComponent, bytesPerRow, colorSpace(m_configuration), bitmapInfo(m_configuration), releaseBitmapContextData, this));
    101     if (!bitmapContext)
    102         return nullptr;
    103 
    104     ref(); // Balanced by deref in releaseBitmapContextData.
     104    if (!bitmapContext) {
     105        // When CGBitmapContextCreateWithData fails and returns null, it will only
     106        // call the release callback in some circumstances <rdar://82228446>. We
     107        // work around this by recording whether it was called, and calling it
     108        // ourselves if needed.
     109        if (!m_releaseBitmapContextDataCalled)
     110            releaseBitmapContextData(this, this->data());
     111        return nullptr;
     112    }
     113    ASSERT(!m_releaseBitmapContextDataCalled);
    105114
    106115    // We want the origin to be in the top left corner so we flip the backing store context.
     
    172181    ShareableBitmap* bitmap = static_cast<ShareableBitmap*>(typelessBitmap);
    173182    ASSERT_UNUSED(typelessData, bitmap->data() == typelessData);
     183    bitmap->m_releaseBitmapContextDataCalled = true;
    174184    bitmap->deref(); // Balanced by ref in createGraphicsContext.
    175185}
Note: See TracChangeset for help on using the changeset viewer.