зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1450644 - Better shutdown approach for Workers - part 3 - Preference for time worker timeout, r=asuth
This commit is contained in:
Родитель
01dfdace45
Коммит
423880eafd
|
@ -23,11 +23,13 @@ DOMPrefs::Initialize()
|
|||
|
||||
#define DOM_PREF(name, pref) DOMPrefs::name();
|
||||
#define DOM_WEBIDL_PREF(name)
|
||||
#define DOM_UINT32_PREF(name, pref, defaultValue) DOMPrefs::name();
|
||||
|
||||
#include "DOMPrefsInternal.h"
|
||||
|
||||
#undef DOM_PREF
|
||||
#undef DOM_WEBIDL_PREF
|
||||
#undef DOM_UINT32_PREF
|
||||
}
|
||||
|
||||
#define DOM_PREF(name, pref) \
|
||||
|
@ -50,6 +52,19 @@ DOMPrefs::Initialize()
|
|||
return DOMPrefs::name(); \
|
||||
}
|
||||
|
||||
#define DOM_UINT32_PREF(name, pref, defaultValue) \
|
||||
/* static */ uint32_t \
|
||||
DOMPrefs::name() \
|
||||
{ \
|
||||
static bool initialized = false; \
|
||||
static Atomic<uint32_t> cachedValue; \
|
||||
if (!initialized) { \
|
||||
initialized = true; \
|
||||
Preferences::AddAtomicUintVarCache(&cachedValue, pref, defaultValue); \
|
||||
} \
|
||||
return cachedValue; \
|
||||
}
|
||||
|
||||
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
|
||||
DOM_PREF(DumpEnabled, "browser.dom.window.dump.enabled")
|
||||
#else
|
||||
|
@ -64,6 +79,7 @@ DOMPrefs::DumpEnabled()
|
|||
|
||||
#undef DOM_PREF
|
||||
#undef DOM_WEBIDL_PREF
|
||||
#undef DOM_UINT32_PREF
|
||||
|
||||
} // dom namespace
|
||||
} // mozilla namespace
|
||||
|
|
|
@ -21,11 +21,13 @@ public:
|
|||
|
||||
#define DOM_PREF(name, pref) static bool name();
|
||||
#define DOM_WEBIDL_PREF(name) static bool name(JSContext* aCx, JSObject* aObj);
|
||||
#define DOM_UINT32_PREF(name, pref, defaultValue) static uint32_t name();
|
||||
|
||||
#include "DOMPrefsInternal.h"
|
||||
|
||||
#undef DOM_PREF
|
||||
#undef DOM_WEBIDL_PREF
|
||||
#undef DOM_UINT32_PREF
|
||||
};
|
||||
|
||||
} // dom namespace
|
||||
|
|
|
@ -56,3 +56,7 @@ DOM_WEBIDL_PREF(WebkitBlinkDirectoryPickerEnabled)
|
|||
DOM_WEBIDL_PREF(NetworkInformationEnabled)
|
||||
DOM_WEBIDL_PREF(FetchObserverEnabled)
|
||||
DOM_WEBIDL_PREF(PerformanceObserverEnabled)
|
||||
|
||||
DOM_UINT32_PREF(WorkerCancelingTimeoutMillis,
|
||||
"dom.worker.canceling.timeoutMilliseconds",
|
||||
30000 /* 30 seconds */)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "js/MemoryMetrics.h"
|
||||
#include "MessageEventRunnable.h"
|
||||
#include "mozilla/ScopeExit.h"
|
||||
#include "mozilla/dom/ClientManager.h"
|
||||
#include "mozilla/dom/ClientSource.h"
|
||||
#include "mozilla/dom/ClientState.h"
|
||||
|
@ -72,8 +73,6 @@
|
|||
// A shrinking GC will run five seconds after the last event is processed.
|
||||
#define IDLE_GC_TIMER_DELAY_SEC 5
|
||||
|
||||
#define CANCELING_TIMEOUT 30000 // 30 seconds
|
||||
|
||||
static mozilla::LazyLogModule sWorkerPrivateLog("WorkerPrivate");
|
||||
static mozilla::LazyLogModule sWorkerTimeoutsLog("WorkerTimeouts");
|
||||
|
||||
|
@ -4969,7 +4968,7 @@ WorkerPrivate::StartCancelingTimer()
|
|||
{
|
||||
AssertIsOnParentThread();
|
||||
|
||||
auto raii = MakeScopeExit([&] {
|
||||
auto errorCleanup = MakeScopeExit([&] {
|
||||
mCancelingTimer = nullptr;
|
||||
});
|
||||
|
||||
|
@ -4993,14 +4992,17 @@ WorkerPrivate::StartCancelingTimer()
|
|||
}
|
||||
}
|
||||
|
||||
uint32_t cancelingTimeoutMillis = DOMPrefs::WorkerCancelingTimeoutMillis();
|
||||
|
||||
RefPtr<CancelingTimerCallback> callback = new CancelingTimerCallback(this);
|
||||
nsresult rv = mCancelingTimer->InitWithCallback(callback, CANCELING_TIMEOUT,
|
||||
nsresult rv = mCancelingTimer->InitWithCallback(callback,
|
||||
cancelingTimeoutMillis,
|
||||
nsITimer::TYPE_ONE_SHOT);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return;
|
||||
}
|
||||
|
||||
raii.release();
|
||||
errorCleanup.release();
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
function test() {
|
||||
(async function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.requestLongerTimeout(5);
|
||||
|
||||
info("Create a top-level chrome worker that creates a non-top-level " +
|
||||
"content worker and wait for their debuggers to be registered.");
|
||||
|
@ -56,7 +57,7 @@
|
|||
"Non-top-level worker debugger should not have window.");
|
||||
|
||||
info("Terminate the top-level chrome worker and the non-top-level " +
|
||||
"content worker, and wait for their debuggers to be " +
|
||||
"content worker, and wait for their debuggers to be " +
|
||||
"unregistered and closed.");
|
||||
promise = waitForMultiple([
|
||||
waitForUnregister(CHILD_WORKER_URL),
|
||||
|
@ -67,7 +68,7 @@
|
|||
worker.terminate();
|
||||
await promise;
|
||||
|
||||
info("Create a shared worker and wait for its debugger to be " +
|
||||
info("Create a shared worker and wait for its debugger to be " +
|
||||
"registered");
|
||||
promise = waitForRegister(SHARED_WORKER_URL);
|
||||
worker = new SharedWorker(SHARED_WORKER_URL);
|
||||
|
@ -117,6 +118,14 @@
|
|||
waitForDebuggerClose(sharedDbg)
|
||||
]);
|
||||
|
||||
// When the closing process begins, we schedule a timer to terminate
|
||||
// the worker in case it's in an infinite loop, which is exactly what
|
||||
// we do in this test. We want a duration long enough that we can be
|
||||
// confident that the infinite loop was entered as measured by
|
||||
// performance.now() and that we terminated it, but not as long as our
|
||||
// 30 second default we currently ship.
|
||||
await SpecialPowers.pushPrefEnv({"set": [[ "dom.worker.canceling.timeoutMilliseconds", 15000 ]]});
|
||||
|
||||
worker.port.start();
|
||||
worker.port.postMessage("close_loop");
|
||||
await promise;
|
||||
|
|
|
@ -4958,6 +4958,12 @@ Preferences::AddAtomicUintVarCache(Atomic<uint32_t, ReleaseAcquire>*,
|
|||
uint32_t,
|
||||
bool);
|
||||
|
||||
template nsresult
|
||||
Preferences::AddAtomicUintVarCache(Atomic<uint32_t, SequentiallyConsistent>*,
|
||||
const char*,
|
||||
uint32_t,
|
||||
bool);
|
||||
|
||||
static void
|
||||
FloatVarChanged(const char* aPref, void* aClosure)
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче