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

Changeset 175955 in webkit


Ignore:
Timestamp:
Nov 11, 2014, 10:15:46 AM (12 years ago)
Author:
Carlos Garcia Campos
Message:

Merge r175655 - 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:
releases/WebKitGTK/webkit-2.6/Source
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.6/Source/WTF/ChangeLog

    r175933 r175955  
     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-10-30  Jeffrey Pfau  <jpfau@apple.com>
    214
  • releases/WebKitGTK/webkit-2.6/Source/WTF/wtf/MathExtras.h

    r165676 r175955  
    385385}
    386386
     387template <typename T>
     388inline bool withinEpsilon(T a, T b)
     389{
     390    return std::abs(a - b) <= std::numeric_limits<T>::epsilon();
     391}
     392
    387393} // namespace WTF
    388394
  • releases/WebKitGTK/webkit-2.6/Source/WebCore/ChangeLog

    r175952 r175955  
     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 Dumez  <cdumez@apple.com>
    229
  • releases/WebKitGTK/webkit-2.6/Source/WebCore/page/DOMTimer.cpp

    r173694 r175955  
    3636#include <wtf/CurrentTime.h>
    3737#include <wtf/HashSet.h>
     38#include <wtf/MathExtras.h>
    3839#include <wtf/StdLibExtras.h>
    3940
     
    262263    m_currentTimerInterval = intervalClampedToMinimum();
    263264
    264     if (previousInterval == m_currentTimerInterval)
     265    if (WTF::withinEpsilon(previousInterval, m_currentTimerInterval))
    265266        return;
    266267
    267268    if (repeatInterval()) {
    268         ASSERT(repeatInterval() == previousInterval);
     269        ASSERT(WTF::withinEpsilon(repeatInterval(), previousInterval));
    269270        augmentRepeatInterval(m_currentTimerInterval - previousInterval);
    270271    } else
  • releases/WebKitGTK/webkit-2.6/Source/WebCore/platform/graphics/FloatQuad.cpp

    r165676 r175955  
    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.