Changeset 233196 in webkit


Ignore:
Timestamp:
Jun 26, 2018 5:30:19 AM (6 years ago)
Author:
zandobersek@gmail.com
Message:

Crash in WebAnimation::runPendingPlayTask
https://bugs.webkit.org/show_bug.cgi?id=186189

Reviewed by Carlos Garcia Campos.

Source/WebCore:

Avoid crashes on nullopt std::optional dereference in the
runPendingPlayTask() and runPendingPauseTask() methods of the
WebAnimation class by defaulting to a Seconds(0) value.

In both cases the std::optional value is the current time retrieved from
the associated DocumentTimeline object. But there's no guarantee that
the timeline is active and the resulting time value is resolved (i.e.
not nullopt). Dereferencing the nullopt Seconds value doesn't cause a
problem on configurations still building as C++14 and the fallback
std::optional implementation provided by WTF -- no signal is raised, and
a 0 value is returned. Configurations building as C++17 on the other
hand use the stdlib-provided std::optional that does raise a signal on
invalid access, leading to crashes.

The default-to-Seconds(0) solution avoids crashes on configurations
that build with C++17 support enabled, and thus match configurations
that are still using WTF's std::optional. This still doesn't address the
underlying problem of retrieving current time from an inactive document
timeline and using it as ready time for the pending play/pause task
execution.

runPendingPlayTask() change addresses crashes in the following tests:

  • fast/animation/css-animation-resuming-when-visible.html
  • fast/animation/css-animation-resuming-when-visible-with-style-change.html
  • imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/animate-no-browsing-context.html
  • imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html

runPendingPauseTask() change addresses crashes in the following tests:

  • animations/multiple-animations-timing-function.html
  • animation/WebAnimation.cpp:

(WebCore::WebAnimation::runPendingPlayTask):
(WebCore::WebAnimation::runPendingPauseTask):

LayoutTests:

  • platform/wpe/TestExpectations: Remove crashing expectations for fixed tests.
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r233191 r233196  
     12018-06-26  Zan Dobersek  <zdobersek@igalia.com>
     2
     3        Crash in WebAnimation::runPendingPlayTask
     4        https://bugs.webkit.org/show_bug.cgi?id=186189
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        * platform/wpe/TestExpectations: Remove crashing expectations for fixed tests.
     9
    1102018-06-25  Youenn Fablet  <youenn@apple.com>
    211
  • trunk/LayoutTests/platform/wpe/TestExpectations

    r233138 r233196  
    12251225webkit.org/b/186752 fast/css-grid-layout/maximize-tracks-definite-indefinite-height.html [ Crash ]
    12261226
    1227 webkit.org/b/186753 animations/multiple-animations-timing-function.html [ Crash ]
    1228 webkit.org/b/186753 fast/animation/css-animation-resuming-when-visible-with-style-change.html [ Crash ]
    1229 webkit.org/b/186753 fast/animation/css-animation-resuming-when-visible.html [ Crash ]
    1230 webkit.org/b/186753 imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/animate-no-browsing-context.html [ Crash ]
    1231 webkit.org/b/186753 imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html [ Crash ]
    1232 
    12331227webkit.org/b/186100 css3/color-filters/color-filter-color-property-list-item.html [ ImageOnlyFailure ]
    12341228webkit.org/b/186100 css3/color-filters/color-filter-ignore-semantic.html [ ImageOnlyFailure ]
  • trunk/Source/WebCore/ChangeLog

    r233194 r233196  
     12018-06-26  Zan Dobersek  <zdobersek@igalia.com>
     2
     3        Crash in WebAnimation::runPendingPlayTask
     4        https://bugs.webkit.org/show_bug.cgi?id=186189
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        Avoid crashes on nullopt std::optional dereference in the
     9        runPendingPlayTask() and runPendingPauseTask() methods of the
     10        WebAnimation class by defaulting to a Seconds(0) value.
     11
     12        In both cases the std::optional value is the current time retrieved from
     13        the associated DocumentTimeline object. But there's no guarantee that
     14        the timeline is active and the resulting time value is resolved (i.e.
     15        not nullopt). Dereferencing the nullopt Seconds value doesn't cause a
     16        problem on configurations still building as C++14 and the fallback
     17        std::optional implementation provided by WTF -- no signal is raised, and
     18        a 0 value is returned. Configurations building as C++17 on the other
     19        hand use the stdlib-provided std::optional that does raise a signal on
     20        invalid access, leading to crashes.
     21
     22        The default-to-Seconds(0) solution avoids crashes on configurations
     23        that build with C++17 support enabled, and thus match configurations
     24        that are still using WTF's std::optional. This still doesn't address the
     25        underlying problem of retrieving current time from an inactive document
     26        timeline and using it as ready time for the pending play/pause task
     27        execution.
     28
     29        runPendingPlayTask() change addresses crashes in the following tests:
     30        - fast/animation/css-animation-resuming-when-visible.html
     31        - fast/animation/css-animation-resuming-when-visible-with-style-change.html
     32        - imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/animate-no-browsing-context.html
     33        - imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/getAnimations.html
     34
     35        runPendingPauseTask() change addresses crashes in the following tests:
     36        - animations/multiple-animations-timing-function.html
     37
     38        * animation/WebAnimation.cpp:
     39        (WebCore::WebAnimation::runPendingPlayTask):
     40        (WebCore::WebAnimation::runPendingPauseTask):
     41
    1422018-06-26  Antoine Quint  <graouts@apple.com>
    243
  • trunk/Source/WebCore/animation/WebAnimation.cpp

    r232596 r233196  
    836836        // 1. Let new start time be the result of evaluating ready time - hold time / animation playback rate for animation.
    837837        // If the animation playback rate is zero, let new start time be simply ready time.
    838         auto newStartTime = readyTime.value();
     838        // FIXME: Implementation cannot guarantee an active timeline at the point of this async dispatch.
     839        // Subsequently, the resulting readyTime value can be null. Unify behavior between C++17 and
     840        // C++14 builds (the latter using WTF's std::optional) and avoid null std::optional dereferencing
     841        // by defaulting to a Seconds(0) value. See https://bugs.webkit.org/show_bug.cgi?id=186189.
     842        auto newStartTime = readyTime.value_or(0_s);
    839843        if (m_playbackRate)
    840844            newStartTime -= m_holdTime.value() / m_playbackRate;
     
    963967    //    Note: The hold time might be already set if the animation is finished, or if the animation is pending, waiting to begin
    964968    //    playback. In either case we want to preserve the hold time as we enter the paused state.
    965     if (animationStartTime && !m_holdTime)
    966         setHoldTime((readyTime.value() - animationStartTime.value()) * m_playbackRate);
     969    if (animationStartTime && !m_holdTime) {
     970        // FIXME: Implementation cannot guarantee an active timeline at the point of this async dispatch.
     971        // Subsequently, the resulting readyTime value can be null. Unify behavior between C++17 and
     972        // C++14 builds (the latter using WTF's std::optional) and avoid null std::optional dereferencing
     973        // by defaulting to a Seconds(0) value. See https://bugs.webkit.org/show_bug.cgi?id=186189.
     974        setHoldTime((readyTime.value_or(0_s) - animationStartTime.value()) * m_playbackRate);
     975    }
    967976
    968977    // 3. Make animation's start time unresolved.
Note: See TracChangeset for help on using the changeset viewer.