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

Changeset 199042 in webkit


Ignore:
Timestamp:
Apr 4, 2016, 10:39:18 PM (11 years ago)
Author:
jer.noble@apple.com
Message:

[iOS] Crash when playing <video> after playing Web Audio
​https://bugs.webkit.org/show_bug.cgi?id=156185
<rdar://problem/10177005>

Reviewed by Eric Carlson.

Off-by-one error in AudioDestinationIOS::render. The ivars m_firstSpareFrame and m_lastSpareFrame imply that
the sample range is inclusive, i.e. [m_firstSpareFrame .. m_lastSpareFrame], but the length of the range was
being calculated as if m_lastSpareFrame was exclusive; when the two were equal, the length was calculated as
0, rather than 1. This was caught by an ASSERT (and would have been caught by a downstream ASSERT had that one
not been present).

Fix the off-by-one by treating them as inclusive/exclusive--similar to C++ iterators--and renaming them to reflect
this: [m_startSpareFrame .. m_endSpareFrame). This corrects the "length" math which caused the crash.

  • platform/audio/ios/AudioDestinationIOS.cpp:

(WebCore::AudioDestinationIOS::render):

  • platform/audio/ios/AudioDestinationIOS.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r199039 r199042  
     12016-04-04  Jer Noble  <jer.noble@apple.com>
     2
     3        [iOS] Crash when playing <video> after playing Web Audio
     4        https://bugs.webkit.org/show_bug.cgi?id=156185
     5        <rdar://problem/10177005>
     6
     7        Reviewed by Eric Carlson.
     8
     9        Off-by-one error in AudioDestinationIOS::render. The ivars m_firstSpareFrame and m_lastSpareFrame imply that
     10        the sample range is inclusive, i.e. [m_firstSpareFrame .. m_lastSpareFrame], but the length of the range was
     11        being calculated as if m_lastSpareFrame was exclusive; when the two were equal, the length was calculated as
     12        0, rather than 1. This was caught by an ASSERT (and would have been caught by a downstream ASSERT had that one
     13        not been present).
     14
     15        Fix the off-by-one by treating them as inclusive/exclusive--similar to C++ iterators--and renaming them to reflect
     16        this: [m_startSpareFrame .. m_endSpareFrame). This corrects the "length" math which caused the crash.
     17
     18        * platform/audio/ios/AudioDestinationIOS.cpp:
     19        (WebCore::AudioDestinationIOS::render):
     20        * platform/audio/ios/AudioDestinationIOS.h:
     21
    1222016-04-04  John Wilander  <wilander@apple.com>
    223
  • trunk/Source/WebCore/platform/audio/ios/AudioDestinationIOS.cpp

    r198850 r199042  
    219219    UInt32 frameOffset = 0;
    220220    while (framesRemaining > 0) {
    221         if (m_firstSpareFrame && m_lastSpareFrame) {
    222             ASSERT(m_firstSpareFrame < m_lastSpareFrame);
    223             UInt32 framesThisTime = m_lastSpareFrame - m_firstSpareFrame;
     221        if (m_startSpareFrame && m_endSpareFrame) {
     222            ASSERT(m_startSpareFrame < m_endSpareFrame);
     223            UInt32 framesThisTime = m_endSpareFrame - m_startSpareFrame;
    224224            assignAudioBuffersToBus(buffers, *m_renderBus, numberOfBuffers, numberOfFrames, frameOffset, framesThisTime);
    225             m_renderBus->copyFromRange(*m_spareBus, m_firstSpareFrame, m_lastSpareFrame);
     225            m_renderBus->copyFromRange(*m_spareBus, m_startSpareFrame, m_endSpareFrame);
    226226            frameOffset += framesThisTime;
    227227            framesRemaining -= framesThisTime;
    228             m_firstSpareFrame = 0;
    229             m_lastSpareFrame = 0;
     228            m_startSpareFrame = 0;
     229            m_endSpareFrame = 0;
    230230        }
    231231
    … …  
    236236            m_callback.render(0, m_spareBus.get(), kRenderBufferSize);
    237237            m_renderBus->copyFromRange(*m_spareBus, 0, framesThisTime);
    238             m_firstSpareFrame = framesThisTime;
    239             m_lastSpareFrame = kRenderBufferSize - 1;
     238            m_startSpareFrame = framesThisTime;
     239            m_endSpareFrame = kRenderBufferSize;
    240240        } else
    241241            m_callback.render(0, m_renderBus.get(), framesThisTime);
  • trunk/Source/WebCore/platform/audio/ios/AudioDestinationIOS.h

    r198035 r199042  
    6767    RefPtr<AudioBus> m_renderBus;
    6868    RefPtr<AudioBus> m_spareBus;
    69     unsigned m_firstSpareFrame { 0 };
    70     unsigned m_lastSpareFrame { 0 };
     69    unsigned m_startSpareFrame { 0 };
     70    unsigned m_endSpareFrame { 0 };
    7171
    7272    double m_sampleRate;
Note: See TracChangeset for help on using the changeset viewer.