- a/Source/WebCore/ChangeLog +25 lines
Lines 1-3 a/Source/WebCore/ChangeLog_sec1
1
2012-09-26  Arvid Nilsson  <anilsson@rim.com>
2
3
        [BlackBerry] Destroy thread-specific data for Platform::Graphics::Buffer on the right thread
4
        https://bugs.webkit.org/show_bug.cgi?id=97674
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        A new API was added to BlackBerry::Platform::Graphics for destroying
9
        thread-specific data generated on the compositing thread when we blit
10
        buffers. The buffers are otherwise created and destroyed on the WebKit
11
        thread, which doesn't give platform any opportunity to destroy the
12
        thread-specific data.
13
14
        This patch adds calls to the new API to avoid leaking resources.
15
16
        Reviewed internally by Jakob Petsovits and Filip Spacek.
17
18
        PR 214644
19
20
        Verified using manual testing.
21
22
        * plugins/blackberry/PluginViewPrivateBlackBerry.cpp:
23
        (WebCore::PluginViewPrivate::createBuffers):
24
        (WebCore::PluginViewPrivate::destroyBuffers):
25
1
2012-09-27  Jinwoo Song  <jinwoo7.song@samsung.com>
26
2012-09-27  Jinwoo Song  <jinwoo7.song@samsung.com>
2
27
3
        [CMAKE] Remove unnecessary header files from CMakeLists.txt
28
        [CMAKE] Remove unnecessary header files from CMakeLists.txt
- a/Source/WebKit/blackberry/ChangeLog +28 lines
Lines 1-3 a/Source/WebKit/blackberry/ChangeLog_sec1
1
2012-09-26  Arvid Nilsson  <anilsson@rim.com>
2
3
        [BlackBerry] Destroy thread-specific data for Platform::Graphics::Buffer on the right thread
4
        https://bugs.webkit.org/show_bug.cgi?id=97674
5
6
        Reviewed by NOBODY (OOPS!).
7
8
        A new API was added to BlackBerry::Platform::Graphics for destroying
9
        thread-specific data generated on the compositing thread when we blit
10
        buffers. The buffers are otherwise created and destroyed on the WebKit
11
        thread, which doesn't give platform any opportunity to destroy the
12
        thread-specific data.
13
14
        This patch adds calls to the new API to avoid leaking resources.
15
16
        Reviewed internally by Jakob Petsovits and Filip Spacek.
17
18
        PR 214644
19
20
        * WebKitSupport/SurfacePool.cpp:
21
        (BlackBerry::WebKit::SurfacePool::initialize):
22
        (BlackBerry::WebKit::SurfacePool::createPlatformGraphicsContext):
23
        (BlackBerry::WebKit::SurfacePool::lockTileRenderingSurface):
24
        (BlackBerry::WebKit::SurfacePool::releaseTileRenderingSurface):
25
        (BlackBerry::WebKit::SurfacePool::initializeVisibleTileBuffer):
26
        (BlackBerry::WebKit::SurfacePool::createBuffers):
27
        (BlackBerry::WebKit::SurfacePool::releaseBuffers):
28
1
2012-09-26  Jakob Petsovits  <jpetsovits@rim.com>
29
2012-09-26  Jakob Petsovits  <jpetsovits@rim.com>
2
30
3
        [BlackBerry] Remove blitContents() in favor of blitVisibleContents().
31
        [BlackBerry] Remove blitContents() in favor of blitVisibleContents().
- a/Source/WebCore/plugins/blackberry/PluginViewPrivateBlackBerry.cpp +16 lines
Lines 25-30 a/Source/WebCore/plugins/blackberry/PluginViewPrivateBlackBerry.cpp_sec1
25
#include "PluginLayerWebKitThread.h"
25
#include "PluginLayerWebKitThread.h"
26
#endif
26
#endif
27
#include "NPCallbacksBlackBerry.h"
27
#include "NPCallbacksBlackBerry.h"
28
#include <BlackBerryPlatformExecutableMessage.h>
29
#include <BlackBerryPlatformMessageClient.h>
28
#include <wtf/MainThread.h>
30
#include <wtf/MainThread.h>
29
31
30
static unsigned s_counter = 0;
32
static unsigned s_counter = 0;
Lines 277-284 bool PluginViewPrivate::createBuffers(NPSurfaceFormat format, int width, int hei a/Source/WebCore/plugins/blackberry/PluginViewPrivateBlackBerry.cpp_sec2
277
    PthreadMutexLocker backLock(&m_backBufferMutex);
279
    PthreadMutexLocker backLock(&m_backBufferMutex);
278
    PthreadWriteLocker frontLock(&m_frontBufferRwLock);
280
    PthreadWriteLocker frontLock(&m_frontBufferRwLock);
279
281
282
    bool didDestroyBuffers = false;
280
    for (int i = 0; i < PLUGIN_BUFFERS; i++) {
283
    for (int i = 0; i < PLUGIN_BUFFERS; i++) {
281
        if (m_pluginBuffers[i]) {
284
        if (m_pluginBuffers[i]) {
285
            didDestroyBuffers = true;
282
            BlackBerry::Platform::Graphics::destroyBuffer(m_pluginBuffers[i]);
286
            BlackBerry::Platform::Graphics::destroyBuffer(m_pluginBuffers[i]);
283
            m_pluginBuffers[i] = 0;
287
            m_pluginBuffers[i] = 0;
284
        }
288
        }
Lines 298-303 bool PluginViewPrivate::createBuffers(NPSurfaceFormat format, int width, int hei a/Source/WebCore/plugins/blackberry/PluginViewPrivateBlackBerry.cpp_sec3
298
    if (success) {
302
    if (success) {
299
        m_pluginBufferSize = IntSize(width, height);
303
        m_pluginBufferSize = IntSize(width, height);
300
        m_pluginBufferType = toBufferType(format);
304
        m_pluginBufferType = toBufferType(format);
305
306
        if (didDestroyBuffers) {
307
            BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage(
308
                BlackBerry::Platform::createFunctionCallMessage(&BlackBerry::Platform::Graphics::collectThreadSpecificGarbage));
309
        }
301
    } else {
310
    } else {
302
        m_pluginBufferSize = IntSize();
311
        m_pluginBufferSize = IntSize();
303
        m_pluginBufferType = BlackBerry::Platform::Graphics::PluginBufferWithAlpha;
312
        m_pluginBufferType = BlackBerry::Platform::Graphics::PluginBufferWithAlpha;
Lines 358-371 bool PluginViewPrivate::destroyBuffers() a/Source/WebCore/plugins/blackberry/PluginViewPrivateBlackBerry.cpp_sec4
358
    PthreadMutexLocker backLock(&m_backBufferMutex);
367
    PthreadMutexLocker backLock(&m_backBufferMutex);
359
    PthreadWriteLocker frontLock(&m_frontBufferRwLock);
368
    PthreadWriteLocker frontLock(&m_frontBufferRwLock);
360
369
370
    bool didDestroyBuffers = false;
361
    for (int i = 0; i < PLUGIN_BUFFERS; i++) {
371
    for (int i = 0; i < PLUGIN_BUFFERS; i++) {
362
        if (m_pluginBuffers[i]) {
372
        if (m_pluginBuffers[i]) {
373
            didDestroyBuffers = true;
363
            BlackBerry::Platform::Graphics::destroyBuffer(m_pluginBuffers[i]);
374
            BlackBerry::Platform::Graphics::destroyBuffer(m_pluginBuffers[i]);
364
            m_pluginBuffers[i] = 0;
375
            m_pluginBuffers[i] = 0;
365
        }
376
        }
366
    }
377
    }
367
    m_pluginBufferSize = IntSize();
378
    m_pluginBufferSize = IntSize();
368
379
380
    if (didDestroyBuffers) {
381
        BlackBerry::Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage(
382
            BlackBerry::Platform::createFunctionCallMessage(&BlackBerry::Platform::Graphics::collectThreadSpecificGarbage));
383
    }
384
369
    return true;
385
    return true;
370
}
386
}
371
387
- a/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp -19 / +24 lines
Lines 21-28 a/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp_sec1
21
21
22
#include "PlatformContextSkia.h"
22
#include "PlatformContextSkia.h"
23
23
24
#include <BlackBerryPlatformExecutableMessage.h>
24
#include <BlackBerryPlatformGraphics.h>
25
#include <BlackBerryPlatformGraphics.h>
25
#include <BlackBerryPlatformLog.h>
26
#include <BlackBerryPlatformLog.h>
27
#include <BlackBerryPlatformMessageClient.h>
26
#include <BlackBerryPlatformMisc.h>
28
#include <BlackBerryPlatformMisc.h>
27
#include <BlackBerryPlatformScreen.h>
29
#include <BlackBerryPlatformScreen.h>
28
#include <BlackBerryPlatformSettings.h>
30
#include <BlackBerryPlatformSettings.h>
Lines 62-86 SurfacePool::SurfacePool() a/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp_sec2
62
{
64
{
63
}
65
}
64
66
65
void SurfacePool::initialize(const BlackBerry::Platform::IntSize& tileSize)
67
void SurfacePool::initialize(const Platform::IntSize& tileSize)
66
{
68
{
67
    if (m_initialized)
69
    if (m_initialized)
68
        return;
70
        return;
69
    m_initialized = true;
71
    m_initialized = true;
70
72
71
    const unsigned numberOfTiles = BlackBerry::Platform::Settings::instance()->numberOfBackingStoreTiles();
73
    const unsigned numberOfTiles = Platform::Settings::instance()->numberOfBackingStoreTiles();
72
    const unsigned maxNumberOfTiles = BlackBerry::Platform::Settings::instance()->maximumNumberOfBackingStoreTilesAcrossProcesses();
74
    const unsigned maxNumberOfTiles = Platform::Settings::instance()->maximumNumberOfBackingStoreTilesAcrossProcesses();
73
75
74
    if (numberOfTiles) { // Only allocate if we actually use a backingstore.
76
    if (numberOfTiles) { // Only allocate if we actually use a backingstore.
75
        unsigned byteLimit = (maxNumberOfTiles /*pool*/ + 2 /*visible tile buffer, backbuffer*/) * tileSize.width() * tileSize.height() * 4;
77
        unsigned byteLimit = (maxNumberOfTiles /*pool*/ + 2 /*visible tile buffer, backbuffer*/) * tileSize.width() * tileSize.height() * 4;
76
        bool success = BlackBerry::Platform::Graphics::createPixmapGroup(SHARED_PIXMAP_GROUP, byteLimit);
78
        bool success = Platform::Graphics::createPixmapGroup(SHARED_PIXMAP_GROUP, byteLimit);
77
        if (!success) {
79
        if (!success) {
78
            BlackBerry::Platform::log(BlackBerry::Platform::LogLevelWarn,
80
            Platform::log(Platform::LogLevelWarn,
79
                "Shared buffer pool could not be set up, using regular memory allocation instead.");
81
                "Shared buffer pool could not be set up, using regular memory allocation instead.");
80
        }
82
        }
81
    }
83
    }
82
84
83
    m_tileRenderingSurface = BlackBerry::Platform::Graphics::drawingSurface();
85
    m_tileRenderingSurface = Platform::Graphics::drawingSurface();
84
86
85
    if (!numberOfTiles)
87
    if (!numberOfTiles)
86
        return; // we only use direct rendering when 0 tiles are specified.
88
        return; // we only use direct rendering when 0 tiles are specified.
Lines 113-119 void SurfacePool::initialize(const BlackBerry::Platform::IntSize& tileSize) a/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp_sec3
113
    pthread_mutexattr_destroy(&attr);
115
    pthread_mutexattr_destroy(&attr);
114
}
116
}
115
117
116
PlatformGraphicsContext* SurfacePool::createPlatformGraphicsContext(BlackBerry::Platform::Graphics::Drawable* drawable) const
118
PlatformGraphicsContext* SurfacePool::createPlatformGraphicsContext(Platform::Graphics::Drawable* drawable) const
117
{
119
{
118
    return new WebCore::PlatformContextSkia(drawable);
120
    return new WebCore::PlatformContextSkia(drawable);
119
}
121
}
Lines 123-129 PlatformGraphicsContext* SurfacePool::lockTileRenderingSurface() const a/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp_sec4
123
    if (!m_tileRenderingSurface)
125
    if (!m_tileRenderingSurface)
124
        return 0;
126
        return 0;
125
127
126
    return createPlatformGraphicsContext(BlackBerry::Platform::Graphics::lockBufferDrawable(m_tileRenderingSurface));
128
    return createPlatformGraphicsContext(Platform::Graphics::lockBufferDrawable(m_tileRenderingSurface));
127
}
129
}
128
130
129
void SurfacePool::releaseTileRenderingSurface(PlatformGraphicsContext* context) const
131
void SurfacePool::releaseTileRenderingSurface(PlatformGraphicsContext* context) const
Lines 132-141 void SurfacePool::releaseTileRenderingSurface(PlatformGraphicsContext* context) a/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp_sec5
132
        return;
134
        return;
133
135
134
    delete context;
136
    delete context;
135
    BlackBerry::Platform::Graphics::releaseBufferDrawable(m_tileRenderingSurface);
137
    Platform::Graphics::releaseBufferDrawable(m_tileRenderingSurface);
136
}
138
}
137
139
138
void SurfacePool::initializeVisibleTileBuffer(const BlackBerry::Platform::IntSize& visibleSize)
140
void SurfacePool::initializeVisibleTileBuffer(const Platform::IntSize& visibleSize)
139
{
141
{
140
    if (!m_visibleTileBuffer || m_visibleTileBuffer->size() != visibleSize) {
142
    if (!m_visibleTileBuffer || m_visibleTileBuffer->size() != visibleSize) {
141
        delete m_visibleTileBuffer;
143
        delete m_visibleTileBuffer;
Lines 161-173 void SurfacePool::createBuffers() a/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp_sec6
161
163
162
    // Create the tile pool.
164
    // Create the tile pool.
163
    for (size_t i = 0; i < m_tilePool.size(); ++i)
165
    for (size_t i = 0; i < m_tilePool.size(); ++i)
164
        BlackBerry::Platform::Graphics::createPixmapBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer());
166
        Platform::Graphics::createPixmapBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer());
165
167
166
    if (m_visibleTileBuffer)
168
    if (m_visibleTileBuffer)
167
        BlackBerry::Platform::Graphics::createPixmapBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer());
169
        Platform::Graphics::createPixmapBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer());
168
170
169
    if (backBuffer())
171
    if (backBuffer())
170
        BlackBerry::Platform::Graphics::createPixmapBuffer(backBuffer()->nativeBuffer());
172
        Platform::Graphics::createPixmapBuffer(backBuffer()->nativeBuffer());
171
173
172
    m_buffersSuspended = false;
174
    m_buffersSuspended = false;
173
}
175
}
Lines 183-203 void SurfacePool::releaseBuffers() a/Source/WebKit/blackberry/WebKitSupport/SurfacePool.cpp_sec7
183
    for (size_t i = 0; i < m_tilePool.size(); ++i) {
185
    for (size_t i = 0; i < m_tilePool.size(); ++i) {
184
        m_tilePool[i]->frontBuffer()->clearRenderedRegion();
186
        m_tilePool[i]->frontBuffer()->clearRenderedRegion();
185
        // Clear the buffer to prevent accidental leakage of (possibly sensitive) pixel data.
187
        // Clear the buffer to prevent accidental leakage of (possibly sensitive) pixel data.
186
        BlackBerry::Platform::Graphics::clearBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer(), 0, 0, 0, 0);
188
        Platform::Graphics::clearBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer(), 0, 0, 0, 0);
187
        BlackBerry::Platform::Graphics::destroyPixmapBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer());
189
        Platform::Graphics::destroyPixmapBuffer(m_tilePool[i]->frontBuffer()->nativeBuffer());
188
    }
190
    }
189
191
190
    if (m_visibleTileBuffer) {
192
    if (m_visibleTileBuffer) {
191
        m_visibleTileBuffer->frontBuffer()->clearRenderedRegion();
193
        m_visibleTileBuffer->frontBuffer()->clearRenderedRegion();
192
        BlackBerry::Platform::Graphics::clearBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer(), 0, 0, 0, 0);
194
        Platform::Graphics::clearBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer(), 0, 0, 0, 0);
193
        BlackBerry::Platform::Graphics::destroyPixmapBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer());
195
        Platform::Graphics::destroyPixmapBuffer(m_visibleTileBuffer->frontBuffer()->nativeBuffer());
194
    }
196
    }
195
197
196
    if (backBuffer()) {
198
    if (backBuffer()) {
197
        backBuffer()->clearRenderedRegion();
199
        backBuffer()->clearRenderedRegion();
198
        BlackBerry::Platform::Graphics::clearBuffer(backBuffer()->nativeBuffer(), 0, 0, 0, 0);
200
        Platform::Graphics::clearBuffer(backBuffer()->nativeBuffer(), 0, 0, 0, 0);
199
        BlackBerry::Platform::Graphics::destroyPixmapBuffer(backBuffer()->nativeBuffer());
201
        Platform::Graphics::destroyPixmapBuffer(backBuffer()->nativeBuffer());
200
    }
202
    }
203
204
    Platform::userInterfaceThreadMessageClient()->dispatchSyncMessage(
205
        Platform::createFunctionCallMessage(&Platform::Graphics::collectThreadSpecificGarbage));
201
}
206
}
202
207
203
void SurfacePool::waitForBuffer(TileBuffer* tileBuffer)
208
void SurfacePool::waitForBuffer(TileBuffer* tileBuffer)

Return to Bug 97674