Title: [274541] trunk/Source/WebCore
- Revision
- 274541
- Author
- [email protected]
- Date
- 2021-03-16 17:52:10 -0700 (Tue, 16 Mar 2021)
Log Message
Avoid heap allocation under AudioSummingJunction::updateRenderingState()
https://bugs.webkit.org/show_bug.cgi?id=223230
Reviewed by Darin Adler.
Avoid heap allocation under AudioSummingJunction::updateRenderingState()
since this runs on the audio thread.
* Modules/webaudio/AudioSummingJunction.cpp:
(WebCore::AudioSummingJunction::addOutput):
(WebCore::AudioSummingJunction::removeOutput):
(WebCore::AudioSummingJunction::updateRenderingState):
* Modules/webaudio/AudioSummingJunction.h:
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (274540 => 274541)
--- trunk/Source/WebCore/ChangeLog 2021-03-17 00:37:33 UTC (rev 274540)
+++ trunk/Source/WebCore/ChangeLog 2021-03-17 00:52:10 UTC (rev 274541)
@@ -1,3 +1,19 @@
+2021-03-16 Chris Dumez <[email protected]>
+
+ Avoid heap allocation under AudioSummingJunction::updateRenderingState()
+ https://bugs.webkit.org/show_bug.cgi?id=223230
+
+ Reviewed by Darin Adler.
+
+ Avoid heap allocation under AudioSummingJunction::updateRenderingState()
+ since this runs on the audio thread.
+
+ * Modules/webaudio/AudioSummingJunction.cpp:
+ (WebCore::AudioSummingJunction::addOutput):
+ (WebCore::AudioSummingJunction::removeOutput):
+ (WebCore::AudioSummingJunction::updateRenderingState):
+ * Modules/webaudio/AudioSummingJunction.h:
+
2021-03-15 Ebrahim Byagowi <[email protected]> and Myles C. Maxfield <[email protected]>
<img> isn't able to render RTL text correctly in ALT text
Modified: trunk/Source/WebCore/Modules/webaudio/AudioSummingJunction.cpp (274540 => 274541)
--- trunk/Source/WebCore/Modules/webaudio/AudioSummingJunction.cpp 2021-03-17 00:37:33 UTC (rev 274540)
+++ trunk/Source/WebCore/Modules/webaudio/AudioSummingJunction.cpp 2021-03-17 00:52:10 UTC (rev 274541)
@@ -59,6 +59,12 @@
ASSERT(context().isGraphOwner());
if (!m_outputs.add(&output).isNewEntry)
return false;
+
+ if (m_pendingRenderingOutputs.isEmpty())
+ m_pendingRenderingOutputs = copyToVector(m_outputs);
+ else
+ m_pendingRenderingOutputs.append(&output);
+
markRenderingStateAsDirty();
return true;
}
@@ -68,6 +74,12 @@
ASSERT(context().isGraphOwner());
if (!m_outputs.remove(&output))
return false;
+
+ if (m_pendingRenderingOutputs.isEmpty())
+ m_pendingRenderingOutputs = copyToVector(m_outputs);
+ else
+ m_pendingRenderingOutputs.removeFirst(&output);
+
markRenderingStateAsDirty();
return true;
}
@@ -78,12 +90,9 @@
if (m_renderingStateNeedUpdating && canUpdateState()) {
// Copy from m_outputs to m_renderingOutputs.
- m_renderingOutputs.resize(m_outputs.size());
- unsigned i = 0;
- for (auto& output : m_outputs) {
- m_renderingOutputs[i++] = output;
+ m_renderingOutputs = std::exchange(m_pendingRenderingOutputs, { });
+ for (auto& output : m_renderingOutputs)
output->updateRenderingState();
- }
didUpdate();
Modified: trunk/Source/WebCore/Modules/webaudio/AudioSummingJunction.h (274540 => 274541)
--- trunk/Source/WebCore/Modules/webaudio/AudioSummingJunction.h 2021-03-17 00:37:33 UTC (rev 274540)
+++ trunk/Source/WebCore/Modules/webaudio/AudioSummingJunction.h 2021-03-17 00:52:10 UTC (rev 274541)
@@ -84,6 +84,7 @@
// m_outputs contains the AudioNodeOutputs representing current connections which are not disabled.
// The rendering code should never use this directly, but instead uses m_renderingOutputs.
HashSet<AudioNodeOutput*> m_outputs;
+ Vector<AudioNodeOutput*> m_pendingRenderingOutputs;
};
} // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes