Changeset 175655 in webkit


Ignore:
Timestamp:
Nov 5, 2014, 6:21:14 PM (11 years ago)
Author:
Chris Dumez
Message:

Assertion hit DOMTimer::updateTimerIntervalIfNecessary()
https://bugs.webkit.org/show_bug.cgi?id=138440

Reviewed by Geoffrey Garen.

Source/WebCore:

We sometimes hit the ASSERT(repeatInterval() == previousInterval)
assertion in DOMTimer::updateTimerIntervalIfNecessary() when visiting
the following pages:
http://lifehacker.com/the-healthiest-foods-for-one-handed-snacking-while-gami-1654728164
http://longform.org/posts/like-something-the-lord-made

After debugging, the issue turned out to be that we are comparing
floating point numbers using ==, and the check sometimes fails even
though the values really close to each other. This patch updates the
DOMTimer code to use WTF::withinEpsilon() instead of operator==()
to compare the floating point intervals.

I confirmed manually that the assertion is no longer hit.

  • page/DOMTimer.cpp:

(WebCore::DOMTimer::updateTimerIntervalIfNecessary):

  • platform/graphics/FloatQuad.cpp:

(WebCore::FloatQuad::isRectilinear):
(WebCore::withinEpsilon): Deleted.

Source/WTF:

Move the withinEpsilon() function to WTF to avoid code duplication.

  • wtf/MathExtras.h:

(WTF::withinEpsilon):

Location:
trunk/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r175648 r175655  
     12014-11-05  Chris Dumez  <cdumez@apple.com>
     2
     3        Assertion hit DOMTimer::updateTimerIntervalIfNecessary()
     4        https://bugs.webkit.org/show_bug.cgi?id=138440
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Move the withinEpsilon() function to WTF to avoid code duplication.
     9
     10        * wtf/MathExtras.h:
     11        (WTF::withinEpsilon):
     12
    1132014-11-05  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/Source/WTF/wtf/MathExtras.h

    r175261 r175655  
    393393}
    394394
     395template <typename T>
     396inline bool withinEpsilon(T a, T b)
     397{
     398    return std::abs(a - b) <= std::numeric_limits<T>::epsilon();
     399}
     400
    395401} // namespace WTF
    396402
  • trunk/Source/WebCore/ChangeLog

    r175654 r175655  
     12014-11-05  Chris Dumez  <cdumez@apple.com>
     2
     3        Assertion hit DOMTimer::updateTimerIntervalIfNecessary()
     4        https://bugs.webkit.org/show_bug.cgi?id=138440
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        We sometimes hit the ASSERT(repeatInterval() == previousInterval)
     9        assertion in DOMTimer::updateTimerIntervalIfNecessary() when visiting
     10        the following pages:
     11        http://lifehacker.com/the-healthiest-foods-for-one-handed-snacking-while-gami-1654728164
     12        http://longform.org/posts/like-something-the-lord-made
     13
     14        After debugging, the issue turned out to be that we are comparing
     15        floating point numbers using ==, and the check sometimes fails even
     16        though the values really close to each other. This patch updates the
     17        DOMTimer code to use WTF::withinEpsilon() instead of operator==()
     18        to compare the floating point intervals.
     19
     20        I confirmed manually that the assertion is no longer hit.
     21
     22        * page/DOMTimer.cpp:
     23        (WebCore::DOMTimer::updateTimerIntervalIfNecessary):
     24        * platform/graphics/FloatQuad.cpp:
     25        (WebCore::FloatQuad::isRectilinear):
     26        (WebCore::withinEpsilon): Deleted.
     27
    1282014-11-05  Chris Fleizach  <cfleizach@apple.com>
    229
  • trunk/Source/WebCore/page/DOMTimer.cpp

    r175627 r175655  
    3636#include <wtf/CurrentTime.h>
    3737#include <wtf/HashSet.h>
     38#include <wtf/MathExtras.h>
    3839#include <wtf/StdLibExtras.h>
    3940
     
    318319    m_currentTimerInterval = intervalClampedToMinimum();
    319320
    320     if (previousInterval == m_currentTimerInterval)
     321    if (WTF::withinEpsilon(previousInterval, m_currentTimerInterval))
    321322        return;
    322323
    323324    if (repeatInterval()) {
    324         ASSERT(repeatInterval() == previousInterval);
     325        ASSERT(WTF::withinEpsilon(repeatInterval(), previousInterval));
    325326        augmentRepeatInterval(m_currentTimerInterval - previousInterval);
    326327    } else
  • trunk/Source/WebCore/platform/graphics/FloatQuad.cpp

    r165676 r175655  
    3434#include <algorithm>
    3535#include <limits>
     36#include <wtf/MathExtras.h>
    3637
    3738namespace WebCore {
     
    9192}
    9293
    93 static inline bool withinEpsilon(float a, float b)
    94 {
    95     return fabs(a - b) < std::numeric_limits<float>::epsilon();
    96 }
    97 
    9894bool FloatQuad::isRectilinear() const
    9995{
    100     return (withinEpsilon(m_p1.x(), m_p2.x()) && withinEpsilon(m_p2.y(), m_p3.y()) && withinEpsilon(m_p3.x(), m_p4.x()) && withinEpsilon(m_p4.y(), m_p1.y()))
    101         || (withinEpsilon(m_p1.y(), m_p2.y()) && withinEpsilon(m_p2.x(), m_p3.x()) && withinEpsilon(m_p3.y(), m_p4.y()) && withinEpsilon(m_p4.x(), m_p1.x()));
     96    return (WTF::withinEpsilon(m_p1.x(), m_p2.x()) && WTF::withinEpsilon(m_p2.y(), m_p3.y()) && WTF::withinEpsilon(m_p3.x(), m_p4.x()) && WTF::withinEpsilon(m_p4.y(), m_p1.y()))
     97        || (WTF::withinEpsilon(m_p1.y(), m_p2.y()) && WTF::withinEpsilon(m_p2.x(), m_p3.x()) && WTF::withinEpsilon(m_p3.y(), m_p4.y()) && WTF::withinEpsilon(m_p4.x(), m_p1.x()));
    10298}
    10399
Note: See TracChangeset for help on using the changeset viewer.