Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 71f03e43c748b03c7b9d9df377186009db45ccb2
https://github.com/WebKit/WebKit/commit/71f03e43c748b03c7b9d9df377186009db45ccb2
Author: Ahmad Saleem <[email protected]>
Date: 2026-07-26 (Sun, 26 Jul 2026)
Changed paths:
M Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp
M Source/WebCore/Modules/webaudio/RealtimeAnalyser.h
Log Message:
-----------
RealtimeAnalyser heap-allocates a temporary FFT buffer on every analysis pass
https://bugs.webkit.org/show_bug.cgi?id=320278
rdar://183195414
Reviewed by Chris Dumez.
doFFTAnalysisIfNecessary() constructed a fresh AudioFloatArray on each
call to unroll the input buffer into. AudioArray's constructor does an
aligned malloc followed by a full zero-fill, and every one of those bytes
is then immediately overwritten by the unroll memcpy that follows, so the
zero-fill was pure waste. At the default fftSize of 2048 that is an 8KB
malloc/memset/free per pass, and 128KB at the maximum fftSize of 32768.
This runs once per render quantum whenever frequency data is being read,
so a typical requestAnimationFrame-driven visualizer hits it around 60
times a second.
Hold the scratch buffer as a member instead, sized alongside
m_magnitudeBuffer in setFftSize(), matching how the magnitude buffer is
already managed. The unroll writes every element it uses, so dropping the
per-call zero-initialization is not observable.
While here, change applyWindow() to derive its length from the span it is
given rather than taking a separate count, so the two cannot disagree.
* Source/WebCore/Modules/webaudio/RealtimeAnalyser.cpp:
(WebCore::RealtimeAnalyser::setFftSize):
(WebCore::RealtimeAnalyser::doFFTAnalysisIfNecessary):
* Source/WebCore/Modules/webaudio/RealtimeAnalyser.h:
Canonical link: https://commits.webkit.org/317954@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications