Dynamically importing slow modules causes the tab to hang
Categories
(Core :: DOM: Core & HTML, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox86 | --- | fixed |
People
(Reporter: yulia, Assigned: yulia)
References
Details
Attachments
(3 files)
We found this during the Top-level await integration: https://github.com/whatwg/html/pull/4352#discussion_r539722647
But the issue affects all scripts, even with top level await turned off. The expected behaviour is a QuotaExceededError
.
test.html
<script>
(async function() {
try {
await import("./loop.mjs");
} catch (e) {
// e should ideally be a "QuotaExceededError" DOMException
}
})();
</script>
loop.js
while (true) { }
Comment 1•4 years ago
|
||
Well, it's a bit vaguer than that:
User agents may impose resource limitations on scripts, for example CPU quotas, memory limits, total execution time limits, or bandwidth limitations. When a script exceeds a limit, the user agent may either throw a "QuotaExceededError" DOMException, abort the script without an exception, prompt the user, or throttle script execution.
But yeah, completely hanging the tab seems like a bad experience.
Assignee | ||
Comment 2•4 years ago
|
||
That is interesting:
When a script exceeds a limit, the user agent may either throw a "QuotaExceededError" DOMException, abort the script without an exception, prompt the user, or throttle script execution.
We do show a prompt to the user asking if they want to stop the script. Maybe this is working as intended?
Comment 3•4 years ago
|
||
If you stop the script, can you then still interact with the page? E.g., click a link? If that works, I don't think there's a problem on our side. (There might still be a problem with the specification though.)
Assignee | ||
Comment 4•4 years ago
•
|
||
This might be specific to top level await. The tab crashes when the script is stopped. The link displays. The loading it without the TLA seems to have the expected behavior: User is prompted to stop the script. script is stopped and link is clickable.
Assignee | ||
Comment 5•4 years ago
•
|
||
Olli, just bringing this to your attention in case you have some idea what might be happening here.
Comment 6•4 years ago
|
||
Do you have a testcase uploaded somewhere?
Assignee | ||
Comment 7•4 years ago
|
||
Assignee | ||
Comment 8•4 years ago
|
||
Comment 9•4 years ago
|
||
Downloaded those and tested locally and I get slow script warning and if script is canceled, the page gets a chance to be painted and link works.
So, that feels like just a normal slow script handling.
Comment 10•4 years ago
|
||
The crash requires one to enable top_level_await. That looks like a compartment check failing.
#0 js::ContextChecks::check(JSObject*, int) (this=<optimized out>, obj=0x7800000000000, argIndex=0) at /home/smaug/mozilla/hg/shistory/js/src/vm/JSContext-inl.h:90
#1 JSContext::checkImpl<JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*> >(JS::Handle<JSObject*> const&, JS::Handle<JSObject*> const&, JS::Handle<JSObject*> const&)
(this=this@entry=0x7f6b18a2f000, args=..., args=..., args=...) at /home/smaug/mozilla/hg/shistory/js/src/vm/JSContext-inl.h:206
#2 0x00007f6b2f0d4069 in JSContext::check<JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*> >(JS::Handle<JSObject*> const&, JS::Handle<JSObject*> const&, JS::Handle<JSObject*> const&) (this=0x7f6b18a2f000, args=..., args=..., args=...) at /home/smaug/mozilla/hg/shistory/js/src/vm/JSContext-inl.h:213
#3 ReactToPromise(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*>, js::UnhandledRejectionBehavior)
(cx=cx@entry=0x7f6b18a2f000, promiseObj=..., onFulfilled=..., onRejected=..., behavior=behavior@entry=js::UnhandledRejectionBehavior::Ignore)
at /home/smaug/mozilla/hg/shistory/js/src/jsapi.cpp:3966
#4 0x00007f6b2f0d41fd in JS::AddPromiseReactionsIgnoringUnhandledRejection(JSContext*, JS::Handle<JSObject*>, JS::Handle<JSObject*>, JS::Handle<JSObject*>)
(cx=cx@entry=0x7f6b18a2f000, promiseObj=..., promiseObj@entry=..., onFulfilled=..., onFulfilled@entry=..., onRejected=..., onRejected@entry=...)
at /home/smaug/mozilla/hg/shistory/js/src/jsapi.cpp:4000
#5 0x00007f6b2edf0e66 in FinishDynamicModuleImport_impl(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::Handle<JSString*>, JS::Handle<JSObject*>)
(cx=cx@entry=0x7f6b18a2f000, evaluationPromise=..., referencingPrivate=referencingPrivate@entry=..., specifier=..., promiseArg=...)
at /home/smaug/mozilla/hg/shistory/js/src/builtin/ModuleObject.cpp:2306
#6 0x00007f6b2edf1511 in js::FinishDynamicModuleImport(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::Handle<JSString*>, JS::Handle<JSObject*>)
(cx=cx@entry=0x7f6b18a2f000, evaluationPromise=..., evaluationPromise@entry=..., referencingPrivate=referencingPrivate@entry=..., specifier=..., specifier@entry=..., promiseArg=...,
promiseArg@entry=...) at /home/smaug/mozilla/hg/shistory/js/src/builtin/ModuleObject.cpp:2326
#7 0x00007f6b2ef754f8 in JS::FinishDynamicModuleImport(JSContext*, JS::Handle<JSObject*>, JS::Handle<JS::Value>, JS::Handle<JSString*>, JS::Handle<JSObject*>)
(cx=cx@entry=0x7f6b18a2f000, evaluationPromise=evaluationPromise@entry=..., referencingPrivate=referencingPrivate@entry=..., specifier=specifier@entry=..., promise=promise@entry=...)
at /home/smaug/mozilla/hg/shistory/js/src/vm/Modules.cpp:83
#8 0x00007f6b2d52e976 in mozilla::dom::ScriptLoader::FinishDynamicImport(JSContext*, mozilla::dom::ModuleLoadRequest*, nsresult, JS::Handle<JSObject*>)
(this=<optimized out>, aCx=aCx@entry=0x7f6b18a2f000, aRequest=aRequest@entry=0x7f6b162b7400, aResult=<optimized out>, aResult@entry=nsresult::NS_OK, aEvaluationPromise=...)
at /home/smaug/mozilla/hg/shistory/dom/script/ScriptLoader.cpp:1137
#9 0x00007f6b2d53419f in mozilla::dom::ScriptLoader::EvaluateScript(mozilla::dom::ScriptLoadRequest*) (this=this@entry=0x7f6b19711500, aRequest=aRequest@entry=0x7f6b162b7400)
at /home/smaug/mozilla/hg/shistory/dom/script/ScriptLoader.cpp:3041
#10 0x00007f6b2d53501f in mozilla::dom::ScriptLoader::ProcessDynamicImport(mozilla::dom::ModuleLoadRequest*) (this=0x7f6b19711500, aRequest=0x7f6b162b7400)
at /home/smaug/mozilla/hg/shistory/dom/script/ScriptLoader.cpp:2686
#11 0x00007f6b2d53b0d3 in mozilla::dom::ScriptRequestProcessor::Run() (this=<optimized out>) at /home/smaug/mozilla/hg/shistory/dom/script/ScriptLoader.cpp:1210
#12 0x00007f6b2bc866e9 in nsContentUtils::AddScriptRunner(already_AddRefed<nsIRunnable>) (aRunnable=...) at /home/smaug/mozilla/hg/shistory/dom/base/nsContentUtils.cpp:5642
#13 nsContentUtils::AddScriptRunner(nsIRunnable*) (aRunnable=0x7f6b1628bdc0) at /home/smaug/mozilla/hg/shistory/dom/base/nsContentUtils.cpp:5648
#14 0x00007f6b2d525741 in mozilla::dom::ScriptLoader::RunScriptWhenSafe(mozilla::dom::ScriptLoadRequest*) (this=0x7f6b19711500, aRequest=0x7f6b162b7400)
at /home/smaug/mozilla/hg/shistory/dom/script/ScriptLoader.cpp:1220
#15 mozilla::dom::ScriptLoader::ProcessLoadedModuleTree(mozilla::dom::ModuleLoadRequest*) (this=0x7f6b19711500, aRequest=aRequest@entry=0x7f6b162b7400)
at /home/smaug/mozilla/hg/shistory/dom/script/ScriptLoader.cpp:1230
#16 0x00007f6b2d525510 in mozilla::dom::ModuleLoadRequest::LoadFinished() (this=0x7f6b162b7400) at /home/smaug/mozilla/hg/shistory/dom/script/ModuleLoadRequest.cpp:206
#17 mozilla::dom::ModuleLoadRequest::DependenciesLoaded() (this=this@entry=0x7f6b162b7400) at /home/smaug/mozilla/hg/shistory/dom/script/ModuleLoadRequest.cpp:190
#18 0x00007f6b2d524fbd in mozilla::dom::ScriptLoader::StartFetchingModuleDependencies(mozilla::dom::ModuleLoadRequest*) (this=this@entry=0x7f6b19711500, aRequest=0x7f6b18a2f000,
aRequest@entry=0x7f6b162b7400) at /home/smaug/mozilla/hg/shistory/dom/script/ScriptLoader.cpp:814
#19 0x00007f6b2d52ab3e in mozilla::dom::ScriptLoader::ProcessFetchedModuleSource(mozilla::dom::ModuleLoadRequest*) (this=this@entry=0x7f6b19711500, aRequest=aRequest@entry=0x7f6b162b7400)
at /home/smaug/mozilla/hg/shistory/dom/script/ScriptLoader.cpp:533
#20 0x00007f6b2d5370e9 in mozilla::dom::ScriptLoader::PrepareLoadedRequest(mozilla::dom::ScriptLoadRequest*, nsIIncrementalStreamLoader*, nsresult)
(this=this@entry=0x7f6b19711500, aRequest=aRequest@entry=0x7f6b162b7400, aLoader=aLoader@entry=0x7f6b162951a0, aStatus=<optimized out>, aStatus@entry=nsresult::NS_OK)
at /home/smaug/mozilla/hg/shistory/dom/script/ScriptLoader.cpp:4059
#21 0x00007f6b2d527dc6 in mozilla::dom::ScriptLoader::OnStreamComplete(nsIIncrementalStreamLoader*, mozilla::dom::ScriptLoadRequest*, nsresult, nsresult, mozilla::dom::SRICheckDataVerifier*)--Type <RET> for more, q to quit, c to continue without paging--
(this=0x7f6b19711500, aLoader=aLoader@entry=0x7f6b162951a0, aRequest=0x7f6b162b7400, aChannelStatus=aChannelStatus@entry=nsresult::NS_OK, aSRIStatus=<optimized out>, aSRIDataVerifier=<optimized out>) at /home/smaug/mozilla/hg/shistory/dom/script/ScriptLoader.cpp:3652
#22 0x00007f6b2d5279b6 in mozilla::dom::ScriptLoadHandler::OnStreamComplete(nsIIncrementalStreamLoader*, nsISupports*, nsresult, unsigned int, unsigned char const*)
(this=0x7f6b1748bb00, aLoader=<optimized out>, aContext=<optimized out>, aStatus=nsresult::NS_OK, aDataLength=0, aData=<optimized out>)
at /home/smaug/mozilla/hg/shistory/dom/script/ScriptLoadHandler.cpp:444
#23 0x00007f6b2ac15d11 in nsIncrementalStreamLoader::OnStopRequest(nsIRequest*, nsresult) (this=0x7f6b162951a0, request=<optimized out>, aStatus=3138041440)
at /home/smaug/mozilla/hg/shistory/netwerk/base/nsIncrementalStreamLoader.cpp:85
#24 0x00007f6b2b029c66 in nsCORSListenerProxy::OnStopRequest(nsIRequest*, nsresult) (this=0x7f6b1749c820, aRequest=0x7ffcbb0ab670, aStatusCode=nsresult::NS_OK)
at /home/smaug/mozilla/hg/shistory/netwerk/protocol/http/nsCORSListenerProxy.cpp:614
#25 0x00007f6b2ac00c64 in nsBaseChannel::OnStopRequest(nsIRequest*, nsresult) (this=0x7f6b33c66790, request=<optimized out>, status=<optimized out>)
at /home/smaug/mozilla/hg/shistory/netwerk/base/nsBaseChannel.cpp:853
#26 0x00007f6b2ac00d2d in non-virtual thunk to nsBaseChannel::OnStopRequest(nsIRequest*, nsresult) () at /home/smaug/mozilla/hg/shistory/netwerk/base/nsBaseChannel.cpp:865
#27 0x00007f6b2ac18479 in nsInputStreamPump::OnStateStop() (this=this@entry=0x7f6b162e7240) at /home/smaug/mozilla/hg/shistory/netwerk/base/nsInputStreamPump.cpp:649
#28 0x00007f6b2ac17ceb in nsInputStreamPump::OnInputStreamReady(nsIAsyncInputStream*) (this=0x7f6b162e7240, stream=<optimized out>)
at /home/smaug/mozilla/hg/shistory/netwerk/base/nsInputStreamPump.cpp:397
#29 0x00007f6b2ab09271 in nsInputStreamReadyEvent::Run() (this=0x7f6b16d20040) at /home/smaug/mozilla/hg/shistory/xpcom/io/nsStreamUtils.cpp:94
#30 0x00007f6b2ab235f8 in mozilla::SchedulerGroup::Runnable::Run() (this=0x7f6b17483300) at /home/smaug/mozilla/hg/shistory/xpcom/threads/SchedulerGroup.cpp:146
#31 0x00007f6b2ab28ae4 in mozilla::RunnableTask::Run() (this=0x7f6b174bbd80) at /home/smaug/mozilla/hg/shistory/xpcom/threads/TaskController.cpp:452
#32 0x00007f6b2ab25f6f in mozilla::TaskController::DoExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&)
(this=this@entry=0x7f6b18de3090, aProofOfLock=<optimized out>) at /home/smaug/mozilla/hg/shistory/xpcom/threads/TaskController.cpp:732
#33 0x00007f6b2ab253e5 in mozilla::TaskController::ExecuteNextTaskOnlyMainThreadInternal(mozilla::detail::BaseAutoLock<mozilla::Mutex&> const&)
(this=this@entry=0x7f6b18de3090, aProofOfLock=...) at /home/smaug/mozilla/hg/shistory/xpcom/threads/TaskController.cpp:591
#34 0x00007f6b2ab25578 in mozilla::TaskController::ProcessPendingMTTask(bool) (this=0x7f6b18de3090, aMayWait=false) at /home/smaug/mozilla/hg/shistory/xpcom/threads/TaskController.cpp:375
#35 0x00007f6b2ab263c2 in mozilla::TaskController::InitializeInternal()::$_3::operator()() const (this=<optimized out>)
at /home/smaug/mozilla/hg/shistory/xpcom/threads/TaskController.cpp:122
#36 mozilla::detail::RunnableFunction<mozilla::TaskController::InitializeInternal()::$_3>::Run() (this=<optimized out>)
at /home/smaug/mozilla/hg/shistory/ff_build_opt/dist/include/nsThreadUtils.h:534
#37 0x00007f6b2ab3481e in nsThread::ProcessNextEvent(bool, bool*) (this=0x7f6b33c968d0, aMayWait=<optimized out>, aResult=<optimized out>)
at /home/smaug/mozilla/hg/shistory/xpcom/threads/nsThread.cpp:1200
#38 0x00007f6b2ab37d98 in NS_ProcessNextEvent(nsIThread*, bool) (aThread=0x7f6b18a2f000, aThread@entry=0x7f6b33c968d0, aMayWait=false)
at /home/smaug/mozilla/hg/shistory/xpcom/threads/nsThreadUtils.cpp:548
#39 0x00007f6b2b1f5a08 in mozilla::ipc::MessagePump::Run(base::MessagePump::Delegate*) (this=0x7f6b33ca4830, aDelegate=0x7ffcbb0acac0)
at /home/smaug/mozilla/hg/shistory/ipc/glue/MessagePump.cpp:87
#40 0x00007f6b2b17d166 in MessageLoop::RunInternal() (this=0x7ffcbb0ab670) at /home/smaug/mozilla/hg/shistory/ipc/chromium/src/base/message_loop.cc:334
#41 MessageLoop::RunHandler() (this=0x7ffcbb0ab670) at /home/smaug/mozilla/hg/shistory/ipc/chromium/src/base/message_loop.cc:327
#42 MessageLoop::Run() (this=0x7ffcbb0ab670) at /home/smaug/mozilla/hg/shistory/ipc/chromium/src/base/message_loop.cc:309
#43 0x00007f6b2d682789 in nsBaseAppShell::Run() (this=0x7f6b18d6a9a0) at /home/smaug/mozilla/hg/shistory/widget/nsBaseAppShell.cpp:137
#44 0x00007f6b2ec977b4 in XRE_RunAppShell() () at /home/smaug/mozilla/hg/shistory/toolkit/xre/nsEmbedFunctions.cpp:902
#45 0x00007f6b2b17d166 in MessageLoop::RunInternal() (this=0x7ffcbb0ab670) at /home/smaug/mozilla/hg/shistory/ipc/chromium/src/base/message_loop.cc:334
#46 MessageLoop::RunHandler() (this=0x7ffcbb0ab670) at /home/smaug/mozilla/hg/shistory/ipc/chromium/src/base/message_loop.cc:327
#47 MessageLoop::Run() (this=0x7ffcbb0ab670) at /home/smaug/mozilla/hg/shistory/ipc/chromium/src/base/message_loop.cc:309
#48 0x00007f6b2ec97352 in XRE_InitChildProcess(int, char**, XREChildData const*) (aArgc=13, aArgv=0x7ffcbb0adea8, aChildData=<optimized out>)
at /home/smaug/mozilla/hg/shistory/toolkit/xre/nsEmbedFunctions.cpp:733
#49 0x0000556b6ac702e0 in content_process_main(mozilla::Bootstrap*, int, char**) (bootstrap=0x7f6b33c026d0, argc=15, argv=0x7ffcbb0adea8)
Assignee | ||
Updated•4 years ago
|
Updated•4 years ago
|
Assignee | ||
Comment 11•4 years ago
|
||
Comment 12•4 years ago
|
||
Pushed by ystartsev@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/540c9159c3c6 Allow Top-level await modules which fail to evaluate due to user action to fail without crashing. r=jonco,mconley
Comment 13•4 years ago
|
||
Backed out for perma failures.
Push with failures: https://treeherder.mozilla.org/jobs?repo=autoland&resultStatus=testfailed%2Cbusted%2Cexception&revision=37a6b8654987d85dc7f5d1db97cd0074143ff013
Log: https://treeherder.mozilla.org/logviewer?job_id=324963781&repo=autoland&lineNumber=8765
Backout: https://hg.mozilla.org/integration/autoland/rev/c69896c3ff1e8d07fb904f12412dd846bdeb4d4d
Assignee | ||
Comment 14•4 years ago
|
||
Thanks for the heads up, I will look at this after the break.
Comment 15•4 years ago
|
||
There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:ystartsev, could you have a look please?
For more information, please visit auto_nag documentation.
Comment 16•4 years ago
|
||
Pushed by ystartsev@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/490dbdb4e499 Allow Top-level await modules which fail to evaluate due to user action to fail without crashing. r=jonco,mconley
Comment 17•4 years ago
|
||
bugherder |
Assignee | ||
Updated•4 years ago
|
Description
•