Bug 1918506 - Align stack sizes for AudioWorkletProcessor. r=karlt

Differential Revision: https://phabricator.services.mozilla.com/D222084
This commit is contained in:
Paul Adenot 2024-09-17 14:09:05 +00:00
Родитель f0224e83cf
Коммит f996a9241f
5 изменённых файлов: 33 добавлений и 2 удалений

Просмотреть файл

@ -13,6 +13,7 @@
#include "nsISupportsPriority.h" #include "nsISupportsPriority.h"
#include "prthread.h" #include "prthread.h"
#include "Tracing.h" #include "Tracing.h"
#include "mozilla/dom/WorkletThread.h"
#include "audio_thread_priority.h" #include "audio_thread_priority.h"
#ifdef MOZ_WIDGET_ANDROID #ifdef MOZ_WIDGET_ANDROID
# include "AndroidProcess.h" # include "AndroidProcess.h"
@ -37,8 +38,10 @@ GraphRunner::~GraphRunner() {
/* static */ /* static */
already_AddRefed<GraphRunner> GraphRunner::Create(MediaTrackGraphImpl* aGraph) { already_AddRefed<GraphRunner> GraphRunner::Create(MediaTrackGraphImpl* aGraph) {
nsCOMPtr<nsIThread> thread; nsCOMPtr<nsIThread> thread;
if (NS_WARN_IF(NS_FAILED( nsIThreadManager::ThreadCreationOptions options = {
NS_NewNamedThread("GraphRunner", getter_AddRefs(thread))))) { .stackSize = mozilla::dom::WorkletThread::StackSize()};
if (NS_WARN_IF(NS_FAILED(NS_NewNamedThread(
"GraphRunner", getter_AddRefs(thread), nullptr, options)))) {
return nullptr; return nullptr;
} }
nsCOMPtr<nsISupportsPriority> supportsPriority = do_QueryInterface(thread); nsCOMPtr<nsISupportsPriority> supportsPriority = do_QueryInterface(thread);

Просмотреть файл

@ -0,0 +1,21 @@
<!DOCTYPE html>
<html class="reftest-wait">
<script type="worklet">
function recursive(a) {
if(a < 0) return 0;
return recursive(a - 1);
}
recursive(2400);
</script>
<script>
var ac = new AudioContext();
var e = document.querySelector("script[type=worklet]");
var text = e.innerText;
const blob = new Blob([text], { type: "application/javascript" });
var url = URL.createObjectURL(blob);
ac.audioWorklet.addModule(url).then(() => {
document.documentElement.removeAttribute("class");
});
</script>
</html>

Просмотреть файл

@ -183,3 +183,4 @@ load vp9cake_corrupt.webm
load 1903669.html load 1903669.html
load 1905234.html load 1905234.html
load 1905231.webm load 1905231.webm
skip-if(Android) load audioworkletprocessor-recursion.html

Просмотреть файл

@ -423,6 +423,8 @@ void WorkletThread::Terminate() {
DispatchRunnable(runnable.forget()); DispatchRunnable(runnable.forget());
} }
uint32_t WorkletThread::StackSize() { return kWorkletStackSize; }
void WorkletThread::TerminateInternal() { void WorkletThread::TerminateInternal() {
MOZ_ASSERT(!CycleCollectedJSContext::Get() || IsOnWorkletThread()); MOZ_ASSERT(!CycleCollectedJSContext::Get() || IsOnWorkletThread());

Просмотреть файл

@ -45,6 +45,10 @@ class WorkletThread final : public nsThread, public nsIObserver {
void Terminate(); void Terminate();
// Recommended native stack size to use, greater than the stack size
// internally used by SpiderMonkey.
static uint32_t StackSize();
private: private:
explicit WorkletThread(WorkletImpl* aWorkletImpl); explicit WorkletThread(WorkletImpl* aWorkletImpl);
~WorkletThread(); ~WorkletThread();