Commit Graph

80 Commits

Author SHA1 Message Date
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
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
8c2e39f053 Bug 1247687 - Add WorkerModuleLoader skeleton; r=jonco
Initial Skeleton for module loader work.

Depends on D134052

Differential Revision: https://phabricator.services.mozilla.com/D147324
2023-01-18 13:46:29 +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
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
0289a05e1e Bug 1247687 - Add WorkerModuleLoader skeleton; r=jonco
Initial Skeleton for module loader work.

Depends on D134052

Differential Revision: https://phabricator.services.mozilla.com/D147324
2022-12-20 20:56:11 +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
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
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
5b3b7e0007 Bug 1247687 - Add WorkerModuleLoader skeleton; r=jonco
Initial Skeleton for module loader work.

Depends on D134052

Differential Revision: https://phabricator.services.mozilla.com/D147324
2022-12-14 14:55:34 +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
73d40318c9 Bug 1801616 - Cancellation should abort network and cache loads if it has already completed; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D162557
2022-11-21 18:23:20 +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
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
Yulia Startsev
17fd034c7a Bug 1797327 - Introduce CC'd and non CC'd variants of LoadContextBase; r=jonco
In order to use the WorkerLoadContext as a handle for ScriptLoadRequests in the main thread portion
of worker loading, we need to make it thread safe. Which means, it cannot be CC'd, and we need to
manually break cycles. This patch does the first portion of this work, which is inroduce two new
loadContextBase classes, that are either cc'd or not cc'd. For the DOM and mozJSComponent loader, we
continue to use a CC'd LoadContextBase. Workers however now have a non-cc'd variant.

Differential Revision: https://phabricator.services.mozilla.com/D160333
2022-11-01 18:03:34 +00:00
Yulia Startsev
0dd2da9471 Bug 1796460 - Use nsMainthreadPtrHolder instead of RefPtr for CacheCreator r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D160024
2022-10-26 08:08:11 +00:00
Simon Friedberger
3c5991df13 Bug 1549057 - Rename (Gg)etCSP to (Gg)etCsp - r=freddyb
Differential Revision: https://phabricator.services.mozilla.com/D159268
2022-10-24 20:38:11 +00:00
Yulia Startsev
a65474ccb9 Bug 1792984 - Fix missing check for cancellation in resolved cached requests r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D158559
2022-10-18 16:20:13 +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
1e43874d8c Bug 1792984 - Fix missing check for cancellation in resolved cached requests r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D158559
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
f216d57d5c Bug 1792984 - Fix missing check for cancellation in resolved cached requests r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D158559
2022-10-13 07:19:24 +00:00
Yulia Startsev
79dfb2e088 Bug 1793405 - Add missing check for cacheCreator; r=dom-worker-reviewers,smaug
Differential Revision: https://phabricator.services.mozilla.com/D158664
2022-10-06 11:04:08 +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
bc0039cc77 Bug 1784482 - Implement corrected base URI for module redirection; r=asuth
This relates to 1784482, in that it allows modules to pass through the scriptloader independently.
This was a small bug that I caught in the wpt tests. I didn't have a better segment to put it under
so it is here.

Depends on D154382

Differential Revision: https://phabricator.services.mozilla.com/D147325
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
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
02db260709 Bug 1784482 - Implement corrected base URI for module redirection; r=asuth
This relates to 1784482, in that it allows modules to pass through the scriptloader independently.
This was a small bug that I caught in the wpt tests. I didn't have a better segment to put it under
so it is here.

Depends on D154382

Differential Revision: https://phabricator.services.mozilla.com/D147325
2022-09-07 09:37:39 +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
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
7e38c5af58 Bug 1784457 - Add documentation to worker kinds; r=asuth
Differential Revision: https://phabricator.services.mozilla.com/D154521
2022-08-22 16:22:05 +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
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
0334d49d7e Bug 1783190 - Replace WorkerPrivate usage on NetworkLoadHandler with ThreadSafeWorkerRef; r=asuth
Cleanup, optional. Repeating the same work on the NetWorkLoaderHandler as on the WorkerScriptLoader.

Previously, this was considered "safe" because the assumption is that the NetworkLoadHandler is
shorter lived than the WorkerScriptLoader. Rather than assuming this, if we end up in a situation
where this does out-live the WorkerScriptLoader, then we will end up leaking.

Differential Revision: https://phabricator.services.mozilla.com/D154384
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
Sean Feng
288cbe9f46 Bug 1778492 - Add an origin trial for coep: credentialless r=emilio,necko-reviewers,kershaw
Differential Revision: https://phabricator.services.mozilla.com/D151381
2022-07-27 20:33:19 +00:00
Marian-Vasile Laza
2ab97e789a Backed out 2 changesets (bug 1778492) for causing eslint failures.
Backed out changeset 6c3ac3569d31 (bug 1778492)
Backed out changeset 34227495753a (bug 1778492)
2022-07-26 17:43:53 +03:00