Commit graph

609 commits

Author SHA1 Message Date
Yulia Startsev
e6d68fc585 Bug 1805676 - Implement modules for shared workers; r=asuth
This patch introduces modules workers to shared workers. This includes the necessary chagnes to pass
the "type: module" to the shared worker. Beyond that, this patch relies on the work landed in
dedicated workers.

Depends on D162743

Differential Revision: https://phabricator.services.mozilla.com/D156103
2023-02-14 09:04:59 +00:00
Marian-Vasile Laza
2b10b4cf84 Backed out 4 changesets (bug 1805676) for wpt failures on shared-worker-import-csp.html. CLOSED TREE
Backed out changeset 95d1e02df42c (bug 1805676)
Backed out changeset 79f32abb379d (bug 1805676)
Backed out changeset 2d35363f5937 (bug 1805676)
Backed out changeset b173c8e2beba (bug 1805676)
2023-02-13 21:14:00 +02:00
Yulia Startsev
a3e98a92c7 Bug 1805676 - Implement modules for shared workers; r=asuth
This patch introduces modules workers to shared workers. This includes the necessary chagnes to pass
the "type: module" to the shared worker. Beyond that, this patch relies on the work landed in
dedicated workers.

Depends on D162743

Differential Revision: https://phabricator.services.mozilla.com/D156103
2023-02-13 16:09:46 +00:00
Stanca Serban
35c5dff6e9 Backed out 4 changesets (bug 1805676) for causing wpt failures in /workers/modules/shared-worker-import-csp.html. CLOSED TREE
Backed out changeset 3d943ee00682 (bug 1805676)
Backed out changeset 34da8cbd7db2 (bug 1805676)
Backed out changeset 1573d31341db (bug 1805676)
Backed out changeset 212f36c3a9e0 (bug 1805676)
2023-02-13 10:41:28 +02:00
Yulia Startsev
fad5626a3b Bug 1805676 - Implement modules for shared workers; r=asuth
This patch introduces modules workers to shared workers. This includes the necessary chagnes to pass
the "type: module" to the shared worker. Beyond that, this patch relies on the work landed in
dedicated workers.

Depends on D162743

Differential Revision: https://phabricator.services.mozilla.com/D156103
2023-02-13 07:35:59 +00:00
Yulia Startsev
b151bd5373 Bug 1812628 - put worker modules behind a flag; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D168129
2023-02-01 15:30:15 +00:00
Norisz Fay
b9628b7cd5 Backed out 2 changesets (bug 1812628) for causing wpt failures on pointerevent_pointerrawupdate_in_pointerlock.html CLOSED TREE
Backed out changeset da2c075d4524 (bug 1812628)
Backed out changeset cc6317f62e54 (bug 1812628)
2023-02-01 00:09:29 +02:00
Yulia Startsev
570e58e395 Bug 1812628 - put worker modules behind a flag; r=jonco
Differential Revision: https://phabricator.services.mozilla.com/D168129
2023-01-31 15:24:03 +00:00
Yulia Startsev
1c5ad3e91d Bug 1247687 - Implement csp for Module Workers; r=evilpie,asuth,rpl,ckerschb
Depends on D155691

Differential Revision: https://phabricator.services.mozilla.com/D156102
2023-01-18 13:46:33 +00:00
Yulia Startsev
87c8288cb8 Bug 1247687 - Handle cancellation of long running modules; r=jonco
This is a slightly annoying thing that can happen. When we abruptly cancel (such as an infinitely
running script being forcibly terminated) we will be in a state where the EvaluateModule call will
finish _after_ the loader is destroyed. So, instead we track if there has been a forcible
cancelation, and exit early.

Depends on D155690

Differential Revision: https://phabricator.services.mozilla.com/D155568
2023-01-18 13:46:32 +00:00
Yulia Startsev
84728b24c9 Bug 1247687 - Use requestCredentials to set secFlags for modules; r=jonco
This implements the specified request credentials behavior from the spec, and is tested in wpt.

Depends on D155566

Differential Revision: https://phabricator.services.mozilla.com/D155690
2023-01-18 13:46:32 +00:00
Yulia Startsev
99b0e5f9bb Bug 1247687 - Implement requestCredentials for Module Workers; r=jonco
This weaves credentials through from the private to script creation.

Depends on D155567

Differential Revision: https://phabricator.services.mozilla.com/D155566
2023-01-18 13:46:31 +00:00
Yulia Startsev
221fd06fcd Bug 1247687 - Implement correct referrer for modules; r=jonco
In our implementation, we do not have "client" as a referrer, so we resolve the URI directly as part
of ScriptLoadRequest creation.

Depends on D147327

Differential Revision: https://phabricator.services.mozilla.com/D155567
2023-01-18 13:46:31 +00:00
Yulia Startsev
51e7e0e857 Bug 1247687 - Implement initial Static Module Loading for Workers; r=jonco
This is the first pass of getting static module loading to work. This roughly implements
https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-worklet/module-worker-script-graph --
without some of the settings objects correctly set.

Th WorkerModuleLoader itself is implementing step 5, with the StartFetch method handling moving the work back to the main thread. The algorithm in step 5 is generic to all modules.

Depends on D147329

Differential Revision: https://phabricator.services.mozilla.com/D147327
2023-01-18 13:46:30 +00:00
Yulia Startsev
24d2db5bf6 Bug 1247687 - Disallow ImportScripts from module workers; r=jonco
ImportScripts should be disallowed for module works, which are initialized in the following way:
`new Worker("url", { module:true})`. We set the WorkerType for workers accordingly, and can use that
to detect if import scripts are being incorrectly used.

Depends on D147326

Differential Revision: https://phabricator.services.mozilla.com/D147329
2023-01-18 13:46:30 +00:00
Yulia Startsev
56c6f79308 Bug 1247687 - Implement InitModuleLoader methods for WorkerScriptLoader and WorkerGlobalScope; r=jonco
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).

Depends on D147324

Differential Revision: https://phabricator.services.mozilla.com/D147326
2023-01-18 13:46:29 +00:00
Jan Varga
72d9bf2d41 Bug 1808685 - Don't use SerialEventTargetGuard in workers code for now; r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D166048
2023-01-06 03:11:16 +00:00
Norisz Fay
8cf029b070 Backed out 15 changesets (bug 1247687) as requested by dev CLOSED TREE
Backed out changeset 81d052cabf84 (bug 1247687)
Backed out changeset d698041e5174 (bug 1247687)
Backed out changeset 2adf67f910e8 (bug 1247687)
Backed out changeset 0bc871906e97 (bug 1247687)
Backed out changeset 1700d5b79273 (bug 1247687)
Backed out changeset 31888ffde37a (bug 1247687)
Backed out changeset 9153182c650d (bug 1247687)
Backed out changeset 45de9ffeec19 (bug 1247687)
Backed out changeset 59207e959b7c (bug 1247687)
Backed out changeset 49f18430c465 (bug 1247687)
Backed out changeset 0ae1fd421d4f (bug 1247687)
Backed out changeset 7770ec4717fd (bug 1247687)
Backed out changeset 68b476066248 (bug 1247687)
Backed out changeset c94a9dc60dff (bug 1247687)
Backed out changeset 0ab366c6eaaf (bug 1247687)
2022-12-21 10:48:15 +02:00
Yulia Startsev
dcbacd54c8 Bug 1247687 - Implement csp for Module Workers; r=evilpie,asuth,rpl,ckerschb
Depends on D155691

Differential Revision: https://phabricator.services.mozilla.com/D156102
2022-12-20 20:56:15 +00:00
Yulia Startsev
ef3c7012f8 Bug 1247687 - Handle cancellation of long running modules; r=jonco
This is a slightly annoying thing that can happen. When we abruptly cancel (such as an infinitely
running script being forcibly terminated) we will be in a state where the EvaluateModule call will
finish _after_ the loader is destroyed. So, instead we track if there has been a forcible
cancelation, and exit early.

Depends on D155690

Differential Revision: https://phabricator.services.mozilla.com/D155568
2022-12-20 20:56:14 +00:00
Yulia Startsev
e35e35d3c0 Bug 1247687 - Use requestCredentials to set secFlags for modules; r=jonco
This implements the specified request credentials behavior from the spec, and is tested in wpt.

Depends on D155566

Differential Revision: https://phabricator.services.mozilla.com/D155690
2022-12-20 20:56:14 +00:00
Yulia Startsev
d625cafe6f Bug 1247687 - Implement requestCredentials for Module Workers; r=jonco
This weaves credentials through from the private to script creation.

Depends on D155567

Differential Revision: https://phabricator.services.mozilla.com/D155566
2022-12-20 20:56:13 +00:00
Yulia Startsev
a0b8b2351c Bug 1247687 - Implement correct referrer for modules; r=jonco
In our implementation, we do not have "client" as a referrer, so we resolve the URI directly as part
of ScriptLoadRequest creation.

Depends on D147327

Differential Revision: https://phabricator.services.mozilla.com/D155567
2022-12-20 20:56:13 +00:00
Yulia Startsev
83dd3f6844 Bug 1247687 - Implement initial Static Module Loading for Workers; r=jonco
This is the first pass of getting static module loading to work. This roughly implements
https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-worklet/module-worker-script-graph --
without some of the settings objects correctly set.

Th WorkerModuleLoader itself is implementing step 5, with the StartFetch method handling moving the work back to the main thread. The algorithm in step 5 is generic to all modules.

Depends on D147329

Differential Revision: https://phabricator.services.mozilla.com/D147327
2022-12-20 20:56:13 +00:00
Yulia Startsev
85669b74b0 Bug 1247687 - Disallow ImportScripts from module workers; r=jonco
ImportScripts should be disallowed for module works, which are initialized in the following way:
`new Worker("url", { module:true})`. We set the WorkerType for workers accordingly, and can use that
to detect if import scripts are being incorrectly used.

Depends on D147326

Differential Revision: https://phabricator.services.mozilla.com/D147329
2022-12-20 20:56:12 +00:00
Yulia Startsev
e859be10b8 Bug 1247687 - Implement InitModuleLoader methods for WorkerScriptLoader and WorkerGlobalScope; r=jonco
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).

Depends on D147324

Differential Revision: https://phabricator.services.mozilla.com/D147326
2022-12-20 20:56:12 +00:00
Csoregi Natalia
c382c6a7ca Backed out 16 changesets (bug 1247687) for frequent string bundle related crashes with PDF viewer (bug 1806064). a=backout
Backed out changeset 721f612fd09f (bug 1247687)
Backed out changeset c6c5750cf713 (bug 1247687)
Backed out changeset 5d05ab0c7cde (bug 1247687)
Backed out changeset 2429599729cb (bug 1247687)
Backed out changeset 55f13fb4ee3f (bug 1247687)
Backed out changeset 354711cf113a (bug 1247687)
Backed out changeset 40b8abaf1c0b (bug 1247687)
Backed out changeset 0c9650a1ac48 (bug 1247687)
Backed out changeset e7b103c79b1a (bug 1247687)
Backed out changeset 4dbd510fb042 (bug 1247687)
Backed out changeset 9276c7e1ddd9 (bug 1247687)
Backed out changeset 6ee318df6641 (bug 1247687)
Backed out changeset 6c129bd72b61 (bug 1247687)
Backed out changeset 4b0a4fcc6894 (bug 1247687)
Backed out changeset 34680059b9f0 (bug 1247687)
Backed out changeset 85b827971a48 (bug 1247687)
2022-12-17 11:27:32 +02:00
Jan Varga
650c726cb3 Bug 1803062 - GetCurrentSerialEventTarget should return the nested event target when a sync loop is running; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D163841
2022-12-15 05:15:31 +00:00
Yulia Startsev
4916e53611 Bug 1247687 - Implement csp for Module Workers; r=evilpie,asuth,rpl,ckerschb
Depends on D155691

Differential Revision: https://phabricator.services.mozilla.com/D156102
2022-12-14 14:55:38 +00:00
Yulia Startsev
51d7d18a24 Bug 1247687 - Handle cancellation of long running modules; r=jonco
This is a slightly annoying thing that can happen. When we abruptly cancel (such as an infinitely
running script being forcibly terminated) we will be in a state where the EvaluateModule call will
finish _after_ the loader is destroyed. So, instead we track if there has been a forcible
cancelation, and exit early.

Depends on D155690

Differential Revision: https://phabricator.services.mozilla.com/D155568
2022-12-14 14:55:37 +00:00
Yulia Startsev
904f7c679e Bug 1247687 - Use requestCredentials to set secFlags for modules; r=jonco
This implements the specified request credentials behavior from the spec, and is tested in wpt.

Depends on D155566

Differential Revision: https://phabricator.services.mozilla.com/D155690
2022-12-14 14:55:37 +00:00
Yulia Startsev
5ac66699bc Bug 1247687 - Implement requestCredentials for Module Workers; r=jonco
This weaves credentials through from the private to script creation.

Depends on D155567

Differential Revision: https://phabricator.services.mozilla.com/D155566
2022-12-14 14:55:36 +00:00
Yulia Startsev
d3ca0aecd0 Bug 1247687 - Implement correct referrer for modules; r=jonco
In our implementation, we do not have "client" as a referrer, so we resolve the URI directly as part
of ScriptLoadRequest creation.

Depends on D147327

Differential Revision: https://phabricator.services.mozilla.com/D155567
2022-12-14 14:55:36 +00:00
Yulia Startsev
3d4f58ac76 Bug 1247687 - Implement initial Static Module Loading for Workers; r=jonco
This is the first pass of getting static module loading to work. This roughly implements
https://html.spec.whatwg.org/multipage/webappapis.html#fetch-a-worklet/module-worker-script-graph --
without some of the settings objects correctly set.

Th WorkerModuleLoader itself is implementing step 5, with the StartFetch method handling moving the work back to the main thread. The algorithm in step 5 is generic to all modules.

Depends on D147329

Differential Revision: https://phabricator.services.mozilla.com/D147327
2022-12-14 14:55:35 +00:00
Yulia Startsev
33b96ee278 Bug 1247687 - Disallow ImportScripts from module workers; r=jonco
ImportScripts should be disallowed for module works, which are initialized in the following way:
`new Worker("url", { module:true})`. We set the WorkerType for workers accordingly, and can use that
to detect if import scripts are being incorrectly used.

Depends on D147326

Differential Revision: https://phabricator.services.mozilla.com/D147329
2022-12-14 14:55:35 +00:00
Yulia Startsev
a40b702d6e Bug 1247687 - Implement InitModuleLoader methods for WorkerScriptLoader and WorkerGlobalScope; r=jonco
This implements a method to initialize the moduleLoader for workers. This will initialize only once, for all worker types (module and classic).

Depends on D147324

Differential Revision: https://phabricator.services.mozilla.com/D147326
2022-12-14 14:55:35 +00:00
Yulia
4763aa8e30 Bug 1247687 - Call EnsureAndLoadStringBundle from Worker ScriptLoaderRunnable; r=allstarschh
Depends on D163238

Differential Revision: https://phabricator.services.mozilla.com/D163239
2022-12-14 14:55:33 +00:00
Stanca Serban
591b091f05 Backed out changeset 6499b9cc1cfc (bug 1803062) for causing worker related failures. CLOSED TREE 2022-12-13 10:21:29 +02:00
Jan Varga
1b5145d00f Bug 1803062 - GetSerialEventTarget should return the nested event target when a sync loop is running; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D163841
2022-12-13 04:56:35 +00:00
Nika Layzell
8351f7cc2d Bug 1804093 - Part 5: Eliminate WorkerPrincipal and WorkletPrincipals, r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D163856
2022-12-12 22:08:36 +00:00
Jan Varga
860132797b Bug 1803062 - Switch from ordinary bool errors to nsresult errors in code for handling sync loops; r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D163559
2022-12-12 16:09:12 +00:00
Yulia Startsev
efb8b72942 Bug 1801833 - ensure release request is only ever done in a lock; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D162759
2022-11-23 21:02:10 +00:00
Yulia Startsev
d2114afee2 Bug 1801344 - fix iteration over ThreadSafeRequestHandler; r=asuth
This fixes a build error. It was a bit tricker than I expected, comments are inline.

Differential Revision: https://phabricator.services.mozilla.com/D162578
2022-11-21 18:24:22 +00:00
Yulia Startsev
2a09430d95 Bug 1800496 - Revert mCacheCreator to being defined as part of ScriptLoaderRunnable; r=asuth
Previously, in the cancellation refactor, we removed knowledge of the list of scripts being loaded on the main thread. As a result of this, we could no longer clear the cache creator on the main thread after iterating over all requests. We can now do that once again, and it simplifies the code.

Differential Revision: https://phabricator.services.mozilla.com/D162220
2022-11-18 10:02:28 +00:00
Yulia Startsev
ddd2163a1b Bug 1800496 - Re-implement DispatchProcessPendingRequests; r=asuth
This brings back the "group" dispatch that existed before in https://searchfox.org/mozilla-central/rev/e0a7a014f3384ac1abc229d9961f244e3e70a52c/dom/workers/ScriptLoader.cpp#1027-1085

In my view, this is probably an optimization, but it may result in significant behavioral changes as timing has been a major issue with the cancellation refactor. What this does is, if two requests resolve in an order other than post order, then the requests will wait untill all of their dependencies have loaded before firing the dispatch. That means in some cases, we will have only one dispatch instead of two.

Differential Revision: https://phabricator.services.mozilla.com/D162219
2022-11-18 10:02:28 +00:00
Yulia Startsev
92dcd0556e Bug 1800496 - Re-introduce ScriptLoaderRunnable; r=asuth
The ScriptLoaderRunnable used to do double duty as both the runnable used to load a script, and as the data structure to hold on to loading information (what kind of worker, debugger status, etc, if we failed). The second half of these responsibilities remains with the WorkerScriptLoader. WorkerScriptLoader acts as a persistent data structure. ScriptLoaderRunnable is per batch of requests (such as ImportScripts, or a single module load). It works together with the ThreadSafeRequestHandle to load the script.

In the future, when we move to a single threaded implementation, ThreadSafeRequestHandle will likely be merged with WorkerLoadContext, but ScriptLoaderRunnable will stay as a datastructure to represent the batched request, and most of the existing fields (mSyncTarget, the request list) will stay. There is still some massaging to do here, but it gets closer to a final vision of how this should look.

Differential Revision: https://phabricator.services.mozilla.com/D162217
2022-11-18 10:02:27 +00:00
Yulia Startsev
a5b34cfc55 Bug 1800496 - Initial cancellation revert; r=asuth
This returns most of the behavior from https://searchfox.org/mozilla-central/rev/e0a7a014f3384ac1abc229d9961f244e3e70a52c/dom/workers/ScriptLoader.cpp#735-776

What is missing at this point is batch dispatching, as we once again cancel one-at-a-time rather than as a group.

Differential Revision: https://phabricator.services.mozilla.com/D162216
2022-11-18 10:02:27 +00:00
Yulia Startsev
1b7f8a5326 Bug 1800496 - Re-introduce channel tracking for cancellation; r=asuth
This was removed as part of an attempt to simplify worker cancellaton. However, this channel cancellation is important, as without it the timing changes when we finish a request. Without it, we continue to load a script, even after a worker has been shut down.

This tracking will help us reimplement cancellation.

Differential Revision: https://phabricator.services.mozilla.com/D162215
2022-11-18 10:02:26 +00:00
Yulia Startsev
32c96913a6 Bug 1800496 - Re-introduce Cycle Collected LoadContextBase for Workers; r=jonco
The non-cycle collected LoadContextBase caused failures for Module Workers. This reverts that change

Differential Revision: https://phabricator.services.mozilla.com/D162214
2022-11-18 10:02:26 +00:00
Yulia Startsev
2310f5b5b6 Bug 1800496 - Introduce ThreadSafeRequestHandle; r=asuth
This introduces a new datastructure that wraps the ScriptLoadRequest. Previously, we were using the WorkerLoadContext to access the request, and we made it not cycle collected in order to make it safe across threads. This, of course, broke module behavior, as the cycle needs to be broken in more places, and things get rather complex.

In the spirit of making everyone's life easier, the ThreadSafeRequestHandle exists as a way to move the request to the main thread, operate on it, and then return it to the worker. We no longer need to track and free the WorkerLoadContext. Once the ThreadSafeRequestHandle is returned to the worker, we release the request, and the handle is empty. There is a possibility that this will cause issues, so we should keep an eye on this. Alternatively, we can never release the ScriptLoadRequest and let the ThreadSafeRequestHandle clean it up on destruction.

In the case that we somehow end up releasing on the main thread, we will send a runnable to release the request correctly on the worker.

Differential Revision: https://phabricator.services.mozilla.com/D162213
2022-11-18 10:02:25 +00:00
Yulia Startsev
b122d68410 Bug 1800496 - Prep: Use nsISerialEventTarget for WorkerScriptLoader classes; r=dom-workers-and-storage-reviewers,asuth
We will be using the mSyncLoopTarget for module promises, and for returning to the worker thread
when cleaning up for ThreadSafeRequestHandle.

Differential Revision: https://phabricator.services.mozilla.com/D162212
2022-11-18 10:02:25 +00:00
Daniel Holbert
7f83cbcfba Bug 1800342: Make NS_NewPipe2 and NS_NewPipe infallible, to reflect reality. r=xpcom-reviewers,necko-reviewers,nika,kershaw
This patch doesn't change behavior; these APIs were already effectively
infallible, in the sense that it was impossible for them to return anything
other than NS_OK.

The actual API changes here are in xpcom/io/nsIPipe.idl and
xpcom/io/nsPipe3.cpp, and the rest of this patch is just updates to callsites,
removing code that handled failure-flavored return values from these functions.
(All of this removed code was already dead code, effectively.)

Differential Revision: https://phabricator.services.mozilla.com/D161947
2022-11-14 23:22:16 +00:00
Yulia Startsev
d2fa4ee51a Bug 1798667 - clear cache when finished with service worker scripts; r=asuth
I was over eager in introducing the strong pointers to WorkerLoadContext. It turns out that
previously when we were cycle collecting our ScriptLoadRequests, we were also cleaning up everything
related to WorkerLoadContext. Also, in an attempt to fix the cancellation for workers, We
accidentally stopped cleaning up the reference to the cache creator. This patch does the following:

1) cleans up the cache creator reference whenever we finish with a cache load handler. This is done
by calling Fail appropriately. This solves both bug 1798667 (we no longer reach NEW_URI if we fail)
and 1781295 (we no longer leak memory because things were not cleaned up properly).
2) Does no remove the back reference to WorkerLoadContext from the LoadRequest. It turns out that
this is sometimes necessary. There is a chance that we will accidently try to access the
WorkerLoadContext after cancellation. This actually causes problems later on in the module code.

Differential Revision: https://phabricator.services.mozilla.com/D161288
2022-11-04 15:04:27 +00:00
Yulia Startsev
088ae95178 Bug 1797327 - Use RefPtrs for all WorkerLoadContexts; r=asuth
As WorkerLoadContexts now inherit from a non-CC'd loadContextBase, we have two outcomes.
1) we need to break cycles with ScriptLoadRequests manually, so that ScriptLoadRequests can be collected (ScriptLoadRequests must be CC'd).
2) we can now have refptrs to WorkerLoadContexts in the CacheLoadHandler and NetworkLoadHandler classes, and remove any remaining raw pointers to ScriptLoadRequest/WorkerLoadContext. There are cases where the NetworkLoadHandler or CacheLoadHandler might outlive the Worker Loader, so having refpointers here should help us recover in those cases.

Differential Revision: https://phabricator.services.mozilla.com/D160334
2022-11-01 18:03:34 +00:00
Jan Varga
940cf12bc4 Bug 1791747 - AutoSyncLoopHolder::GetEventTarget should return nsISerialEventTarget (instead of nsIEventTarget); r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D157805
2022-10-28 06:18:10 +00:00
Yulia Startsev
e6ba9b8b31 Bug 1792984 - Introduce asserts and refptrs r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D158425
2022-10-18 16:20:13 +00:00
Yulia Startsev
a23d8dce11 Bug 1792984 - Introduce aggressive cancellation r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D158558
2022-10-18 16:20:12 +00:00
Iulian Moraru
160a1a400d Backed out 3 changesets (bug 1792984) for causing multiple failures. CLOSED TREE
Backed out changeset 82816b3aa215 (bug 1792984)
Backed out changeset 4e8cea95745a (bug 1792984)
Backed out changeset 44324c5af215 (bug 1792984)
2022-10-13 16:31:35 +03:00
Yulia Startsev
ea70cc191e Bug 1792984 - Introduce asserts r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D158425
2022-10-13 10:53:48 +00:00
Yulia Startsev
84918803f0 Bug 1792984 - Introduce aggressive cancellation r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D158558
2022-10-13 10:53:47 +00:00
Iulian Moraru
64f7ea66a0 Backed out 3 changesets (bug 1792984) for causing multiple failures. CLOSED TREE
Backed out changeset 67c10a19f5ce (bug 1792984)
Backed out changeset bb65c6e3135b (bug 1792984)
Backed out changeset d9ca4c5e8e61 (bug 1792984)
2022-10-13 11:16:36 +03:00
Yulia Startsev
dba0139599 Bug 1792984 - Introduce asserts r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D158425
2022-10-13 07:19:25 +00:00
Yulia Startsev
75e1b76e92 Bug 1792984 - Introduce aggressive cancellation r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D158558
2022-10-13 07:19:24 +00:00
Yulia Startsev
f593e162fd Bug 1784481 - Use ScriptLoaderInterface method for filling compile options; r=jonco
Depends on D147314

Differential Revision: https://phabricator.services.mozilla.com/D147315
2022-10-04 16:01:29 +00:00
Yulia Startsev
7bf63f5988 Bug 1784481 - Use ScriptLoaderInterface methods for reporting errors; r=jonco
Fill out the ReportErrorToConsole method, and add documentation for ReportWarningToConsole

Depends on D147313

Differential Revision: https://phabricator.services.mozilla.com/D147314
2022-10-04 16:01:29 +00:00
Yulia Startsev
0dd649a319 Bug 1784481 - Implement ScriptLoaderInterface Skeleton in WorkerScriptLoader; r=jonco
This introduces the basic skeleton to make WorkerScriptLoader a ScriptLoaderInterface.
ScriptLoaderInterface defines the methods that are shared between any given ScriptLoader (for
example the DOM script loader, the ComponentScriptLoader) and the ModuleLoader for a particular
component.

This patch also adds documentation to make the role and responsibilities of the
ScriptLoaderInterface clear.

Depends on D147321

Differential Revision: https://phabricator.services.mozilla.com/D147313
2022-10-04 16:01:28 +00:00
Yulia Startsev
5ad6240ade Bug 1786571 - Do not call LoadingFinished from handlers when cancelled; r=asuth
This largely keeps in tact what jstutte did. The initial crash was fixed by eagerly calling
LoadingFinished. The second crash is caused because we call it twice, and only in the service worker
case, where we call it once the promise rejects. Now, we check if we have cancelled, and if we have
then we don't call the scriptLoader methods from inside of the load handlers. LoadHandlers now only
use OnStreamComplete if they are "successful" -- that is, if they were not cancelled.

OnStreamComplete retains its assertion error in the case that something was cancelled and we somehow
ended up there. In a follow up, I will clean up the friend classes of the ScriptLoader so you can't
easily access these methods from the LoadHandlers.

Differential Revision: https://phabricator.services.mozilla.com/D158262
2022-09-29 16:28:30 +00:00
Jens Stutte
ecb5da0fbc Bug 1786571 - Add IsCancelled checks to NetworkLoadHandler::OnStreamComplete and have a GetCancelResult r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D157307
2022-09-20 05:58:45 +00:00
Cosmin Sabou
9281cd6961 Backed out changeset 374cb9c09095 (bug 1786571) for causing several service_worker related regressions. 2022-09-16 18:27:46 +03:00
Jens Stutte
d4688e2641 Bug 1786571 - Add IsCancelled checks to NetworkLoadHandler::OnStreamComplete and have a GetCancelResult r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D157307
2022-09-16 03:53:53 +00:00
Noemi Erli
0123802021 Backed out changeset b246c998fb8f (bug 1786571) for causing ScriptLoader failures CLOSED TREE 2022-09-15 14:20:23 +03:00
Jens Stutte
a5bd0870c0 Bug 1786571 - Add IsCancelled checks to NetworkLoadHandler::OnStreamComplete and have a GetCancelResult r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D157307
2022-09-15 10:37:50 +00:00
Yulia Startsev
dbb424426a Bug 1783190 - Introduce lock for cancellation in case of race;r=jstutte
Differential Revision: https://phabricator.services.mozilla.com/D156943
2022-09-09 13:22:42 +00:00
Yulia Startsev
0f84338a77 Bug 1784482 - Implement method for single script loading; r=asuth
This will be used by child modules. This is currently not used, but it will be in modules. I can
move this over to the other bug, if necessary.

Depends on D147325

Differential Revision: https://phabricator.services.mozilla.com/D147321
2022-09-08 17:13:28 +00:00
Yulia Startsev
53ed8260e3 Bug 1783190 - In the case of cancellation, cleanup cache; r=asuth
This brings back the behavior to iterated over all of the load requests to cancel the cache
promise. I tried a couple of different ways of doing this, including deleting the cache, but this
seemed to be the cleanest way.

Depends on D147322

Differential Revision: https://phabricator.services.mozilla.com/D154382
2022-09-08 17:13:27 +00:00
Yulia Startsev
4a09a4f2aa Bug 1784482 - Move shutdown operation to be always after ProcessRequests; r=asuth
This moves the shutdown operations out of the ScriptExecutorRunnable, and into something that can be
called independent. This does not change the behavior in this case, however it is important for
modules, which will have promises that resolve after the ScriptExecutorRunnable has closed.

Depends on D155231

Differential Revision: https://phabricator.services.mozilla.com/D147322
2022-09-08 17:13:27 +00:00
Yulia Startsev
55e47a4cc9 Bug 1784482 - Do not rely on ScriptLoadRequestList in the main thread; r=asuth
This enables us to send files to load that are not part of our executing scripts list. This unlocks
the ability to send single module scripts to be loaded without executing them. It also gives
us a way to get the list of files that are to be loaded.

Depends on D147318

Differential Revision: https://phabricator.services.mozilla.com/D155231
2022-09-08 17:13:27 +00:00
Yulia Startsev
9601e09968 Bug 1784482 - Move creation of ScriptLoadRequests into own functions; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D147318
2022-09-08 17:13:26 +00:00
Butkovits Atila
4b03a9e7f7 Backed out 6 changesets (bug 1783190, bug 1784482) for causing crashes at mozilla::dom::Promise::MaybeReject(nsresult)]. CLOSED TREE
Backed out changeset 3bbb7bedfa0a (bug 1784482)
Backed out changeset a67c04d83558 (bug 1784482)
Backed out changeset 593c1d517530 (bug 1783190)
Backed out changeset 25311707288f (bug 1784482)
Backed out changeset 13e623b3779f (bug 1784482)
Backed out changeset f1f81f81af17 (bug 1784482)
2022-09-07 16:12:45 +03:00
Yulia Startsev
8c7b1e9f2d Bug 1784482 - Implement method for single script loading; r=asuth
This will be used by child modules. This is currently not used, but it will be in modules. I can
move this over to the other bug, if necessary.

Depends on D147325

Differential Revision: https://phabricator.services.mozilla.com/D147321
2022-09-07 09:37:40 +00:00
Yulia Startsev
35baf41dd2 Bug 1783190 - In the case of cancellation, cleanup cache; r=asuth
This brings back the behavior to iterated over all of the load requests to cancel the cache
promise. I tried a couple of different ways of doing this, including deleting the cache, but this
seemed to be the cleanest way.

Depends on D147322

Differential Revision: https://phabricator.services.mozilla.com/D154382
2022-09-07 09:37:39 +00:00
Yulia Startsev
119c3f9a63 Bug 1784482 - Move shutdown operation to be always after ProcessRequests; r=asuth
This moves the shutdown operations out of the ScriptExecutorRunnable, and into something that can be
called independent. This does not change the behavior in this case, however it is important for
modules, which will have promises that resolve after the ScriptExecutorRunnable has closed.

Depends on D155231

Differential Revision: https://phabricator.services.mozilla.com/D147322
2022-09-07 09:37:39 +00:00
Yulia Startsev
4e067f14e8 Bug 1784482 - Do not rely on ScriptLoadRequestList in the main thread; r=asuth
This enables us to send files to load that are not part of our executing scripts list. This unlocks
the ability to send single module scripts to be loaded without executing them. It also gives
us a way to get the list of files that are to be loaded.

Depends on D147318

Differential Revision: https://phabricator.services.mozilla.com/D155231
2022-09-07 09:37:38 +00:00
Yulia Startsev
0d822c68c2 Bug 1784482 - Move creation of ScriptLoadRequests into own functions; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D147318
2022-09-07 09:37:38 +00:00
Yulia Startsev
e48cee9f1d Bug 1784476 - Move ClientInfo to WorkerLoadContext; r=asuth
Previously, we had the client info for main scripts on the ScriptLoadInfo, and in the ScriptLoader
for non-main scripts (ImportScripts case). This was a bit confusing, so I moved it all to the ScriptLoader as in the
importScripts case, it is always recreated with each new load. However, for modules this is not
true. In order to make it persistant for main scripts and modules, as well as ensure that it has the
correct data, it should always live on the WorkerLoadContext.

Differential Revision: https://phabricator.services.mozilla.com/D147317
2022-08-24 13:38:34 +00:00
Yulia Startsev
24c8e12590 Bug 1784476 - Move all required information for constructing ScriptLoadRequests to WorkerScriptLoader constructor; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D147316
2022-08-24 13:38:34 +00:00
Yulia Startsev
eeadeb575f Bug 1784457 - Implement IsTopLevel in place of IsMainWorkerModule; r=asuth
This implements the core of the change -- which is implementing an explicit IsTopLevel flag for
`WorkerLoadContexts`, and removing `mIsMainScript` from the loader. I've asked for some
clarification on this part of the spec from the whatwg editors, as I think this may be misnamed. It
is likely that what is meant here is `IsInitialScript` rather than `IsTopLevel` -- as there is a
note stating that this should be initialized with the agent cluster. Once this is clarified I may
update the name.

Differential Revision: https://phabricator.services.mozilla.com/D147319
2022-08-22 16:22:04 +00:00
Yulia Startsev
415c74a6cd Bug 1784457 - Split GetBaseURI into two functions; r=asuth
`GetBaseURI` will implement the virtual method `GetBaseURI` from ScriptLoaderInterface
(https://searchfox.org/mozilla-central/rev/6ec440e105c2b75d5cae9d34f957a2f85a106d54/js/loader/ModuleLoaderBase.h#64)
-- but the behavior needed there is only ever for child modules. By splitting this, we remove
contextual information which is only used for the initial script.

Differential Revision: https://phabricator.services.mozilla.com/D154520
2022-08-22 16:22:04 +00:00
Yulia Startsev
472e3c8cf5 Bug 1784457 - Remove unused mLoadingWorkerScript atomic boolean from WorkerPrivate; r=asuth
After investigating this a bit, I found that this wasn't used. It seems safe to remove.

Differential Revision: https://phabricator.services.mozilla.com/D154519
2022-08-22 16:22:04 +00:00
Yulia Startsev
09daba2264 Bug 1783190 - Replace WorkerPrivate usage on CacheLoadHandler with ThreadSafeWorkerRef; r=asuth
Cleanup, Optional, Same as the NetworkLoadHandler.

Differential Revision: https://phabricator.services.mozilla.com/D154385
2022-08-22 11:43:02 +00:00
Yulia Startsev
6b185b9350 Bug 1783190 - Replace WorkerPrivate usage with ThreadSafeWorkerRef usage; r=asuth
Cleanup, optional. It seems strange to have two ways to access the WorkerPrivate, and
ThreadSafeWorkerRef seems like the more reasonable choice.

Differential Revision: https://phabricator.services.mozilla.com/D154383
2022-08-22 11:43:02 +00:00
Yulia Startsev
e6dd426bff Bug 1783190 - Hold a ThreadSafeWorkerRef on WorkerScriptLoader; r=asuth
This addresses part of the issue, by holding a strong ref until we shutdown, so that we do not end
up in a situation where the worker closes before we finish cleanup.

Differential Revision: https://phabricator.services.mozilla.com/D154381
2022-08-22 11:43:01 +00:00
Yulia Startsev
3bd594dbd5 Bug 1779762 - Reimplement mLoadingFinished check; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D152181
2022-07-19 16:38:15 +00:00
Yulia Startsev
ccd1b4e8bd Bug 1742438 - Part 13: Use ScriptLoadRequest's mURL instead of WorkerLoadContext's; r=asuth,jonco,nchevobbe
Differential Revision: https://phabricator.services.mozilla.com/D146459
2022-07-14 17:07:29 +00:00
Yulia Startsev
0cfc4b16d0 Bug 1742438 - Part 12: Remove WorkerLoadContext mSourceMapURL and use ScriptLoadRequest mSourceMapURL; r=asuth
The simplest change: these two fields were identical across the representations

Differential Revision: https://phabricator.services.mozilla.com/D146184
2022-07-14 17:07:29 +00:00
Yulia Startsev
68fc4d0318 Bug 1742438 - Part 11: Replace Finished() check with IsAwaitingPromise() and move state change to worker thread; r=asuth,jonco
We don't need the mExecutionScheduled state, as the mLoadingFinished state was only used to
determine if the promise for a given request had resolved. In fact -- we already know that it is in
a possibly resolved state when we call MaybeExecuteFinishedScripts. So, we can remove this state,
and only have the meaningful check (whether or not a promise on the service worker case hasn't
resolved yet) instead.

Differential Revision: https://phabricator.services.mozilla.com/D146183
2022-07-14 17:07:28 +00:00
Yulia Startsev
5552f1227e Bug 1742438 - Part 10: Remove mExecutionResult; r=asuth
This field is no longer necessary, as we are removing executed scripts from our list of scripts to
execute, so we cannot enter a state where something may be executed twice.

Differential Revision: https://phabricator.services.mozilla.com/D146182
2022-07-14 17:07:28 +00:00
Yulia Startsev
9681fade05 Bug 1742438 - Part 9: Replace mLoadingFinished with State::Ready in ScriptLoadRequest; r=asuth
The "mLoadingFinished" state that we are using a boolean for can be represented by State::Ready in
ScriptLoadRequest.

Differential Revision: https://phabricator.services.mozilla.com/D146181
2022-07-14 17:07:28 +00:00
Yulia Startsev
d82f1773f0 Bug 1742438 - Part 8: Use mScriptData instead of custom load context field; r=arai,asuth
This is the most substantial change in the transition from ScriptLoadInfo to ScriptLoadRequest with
regards to data representation. ScriptLoadRequests can have their data incrementally loaded,
so it is already fully decoded and ready to go by the time that we create the source buffer for
worker scripts. This simplifies some of the code, and we can add incremental loading when we are ready.

Differential Revision: https://phabricator.services.mozilla.com/D146180
2022-07-14 17:07:27 +00:00
Yulia Startsev
de63d5eeab Bug 1742438 - Part 5: Rename ScriptLoadInfo to WorkerLoadContext; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D146177
2022-07-14 17:07:26 +00:00