Changeset 202037 in webkit


Ignore:
Timestamp:
Jun 14, 2016 12:48:54 AM (8 years ago)
Author:
Carlos Garcia Campos
Message:

[Threaded Compositor] Flickering and rendering artifacts when resizing the web view
https://bugs.webkit.org/show_bug.cgi?id=154070

Reviewed by Žan Doberšek.

Resizing the web view is expected to be a sync operation, the UI process creates a new backing store state ID,
sends UpdateBackingStoreState message with the flag RespondImmediately to the web process and waits up to 500ms
for the reply (DidUpdateBackingStoreState message). When using the threaded compositor, we schedule a task in
the compositing thread to update the viewport size, and return immediately, so that we reply to the UI process
before the compositing thread has actually updated its size. There's a moment in which sizes are out of sync
causing the flickering and rendering artifacts, the UI process continues rendering at the new size, while the
web process is still rendering at the previous size. We can prevent this from happening just by making the
resize task synchronous in the threaded compositor.

  • Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:

(WebKit::CompositingRunLoop::performTaskSync): Add sync version of performTask().

  • Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h:
  • Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:

(WebKit::ThreadedCompositor::didChangeViewportSize): Use performTaskSync().

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r202036 r202037  
     12016-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        [Threaded Compositor] Flickering and rendering artifacts when resizing the web view
     4        https://bugs.webkit.org/show_bug.cgi?id=154070
     5
     6        Reviewed by Žan Doberšek.
     7
     8        Resizing the web view is expected to be a sync operation, the UI process creates a new backing store state ID,
     9        sends UpdateBackingStoreState message with the flag RespondImmediately to the web process and waits up to 500ms
     10        for the reply (DidUpdateBackingStoreState message). When using the threaded compositor, we schedule a task in
     11        the compositing thread to update the viewport size, and return immediately, so that we reply to the UI process
     12        before the compositing thread has actually updated its size. There's a moment in which sizes are out of sync
     13        causing the flickering and rendering artifacts, the UI process continues rendering at the new size, while the
     14        web process is still rendering at the previous size. We can prevent this from happening just by making the
     15        resize task synchronous in the threaded compositor.
     16
     17        * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp:
     18        (WebKit::CompositingRunLoop::performTaskSync): Add sync version of performTask().
     19        * Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h:
     20        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
     21        (WebKit::ThreadedCompositor::didChangeViewportSize): Use performTaskSync().
     22
    1232016-06-14  Carlos Garcia Campos  <cgarcia@igalia.com>
    224
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.cpp

    r201922 r202037  
    3838    , m_updateTimer(m_runLoop, this, &CompositingRunLoop::updateTimerFired)
    3939    , m_updateFunction(WTFMove(updateFunction))
    40     , m_lastUpdateTime(0)
    4140{
    4241}
     
    4645    ASSERT(isMainThread());
    4746    m_runLoop.dispatch(WTFMove(function));
     47}
     48
     49void CompositingRunLoop::performTaskSync(std::function<void ()>&& function)
     50{
     51    ASSERT(isMainThread());
     52    LockHolder locker(m_dispatchSyncConditionMutex);
     53    m_runLoop.dispatch([this, function = WTFMove(function)] {
     54        LockHolder locker(m_dispatchSyncConditionMutex);
     55        function();
     56        m_dispatchSyncCondition.notifyOne();
     57    });
     58    m_dispatchSyncCondition.wait(m_dispatchSyncConditionMutex);
    4859}
    4960
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/CompositingRunLoop.h

    r201922 r202037  
    4848
    4949    void performTask(std::function<void ()>&&);
     50    void performTaskSync(std::function<void ()>&&);
    5051
    5152    void setUpdateTimer(UpdateTiming timing = Immediate);
     
    6061    RunLoop::Timer<CompositingRunLoop> m_updateTimer;
    6162    std::function<void ()> m_updateFunction;
     63    Lock m_dispatchSyncConditionMutex;
     64    Condition m_dispatchSyncCondition;
    6265
    63     double m_lastUpdateTime;
     66    double m_lastUpdateTime { 0 };
    6467};
    6568
  • trunk/Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp

    r201922 r202037  
    8383{
    8484    RefPtr<ThreadedCompositor> protector(this);
    85     m_compositingRunLoop->performTask([protector, size] {
     85    m_compositingRunLoop->performTaskSync([protector, size] {
    8686        protector->viewportController()->didChangeViewportSize(size);
    8787    });
Note: See TracChangeset for help on using the changeset viewer.