Repository navigation
SharedWorker: Implement SharedWorker constructor reuse - #45088
Conversation
TimvdLippe
left a comment
There was a problem hiding this comment.
I am having a hard time understanding how your changes match the specification. I see you added the spec text (which is good!) but then I don't seem to be able to match it to what you wrote. Additionally, it seems like we are synchronously running steps that should run asynchronously instead in step 11.
Maybe Gregory is a better reviewer for this change?
gterzian
left a comment
There was a problem hiding this comment.
Just a general architectural comment for now.
|
So re the crash we're seeing in CI, I think we just need to do what dedicated workers do, which is a pity because it means we keep going in the direction of making this a kind of semi-shared dedicated worker, but that is as good as it gets for now I think. So see how workers are tracked, and then do the same with shared workers, instead of dropping their join handle. |
Add constructor-side SharedWorker lookup and matching using storage key, constructor origin, constructor URL, name, type, credentials, extended lifetime, and secure_context state Signed-off-by: Taym Haddadi <[email protected]>
Signed-off-by: Taym Haddadi <[email protected]>
Signed-off-by: Taym Haddadi <[email protected]>
Signed-off-by: Taym Haddadi <[email protected]>
1f0beb9 to
ac0d072
Compare
Signed-off-by: Taym Haddadi <[email protected]>
There was a problem hiding this comment.
So the current find_or_claim_shared_worker seems very complicated(and I am not sure how it works, although I could make more efforts to understand it if you think it is the right way forward).
What I meant earlier was to just use a condvar and then if the state is Creating, wait on the condvar until it is created; that makes the logic bulletproof and simple, but blocking, although it doesn't block longer then it takes to create a worker, which would take time anyway, and the actual contention should rarely happen.
So literally I just meant something like https://doc.rust-lang.org/std/sync/struct.Condvar.html#examples (but wait on the worker being created).
Such a simple setup seems like the right way forward, because doing anything more complicated is likely to lead to more work (maybe intermittency) and will have to be thrown away anyway when a proper manager is introduced later.
makes sense, I was trying to avoid blocking by queuing pending connections in the Creating state, but I agree that it makes the temporary script side registry more complicated than it needs to be, let me give Condvar a try. |
Signed-off-by: Taym Haddadi <[email protected]>
gterzian
left a comment
There was a problem hiding this comment.
Couple more comments on the condvar logic.
gterzian
left a comment
There was a problem hiding this comment.
We can also address those intermittent crashes at #45509 (review) in this PR (or a follow-up, but writing it now).
Signed-off-by: Taym Haddadi <[email protected]>
gterzian
left a comment
There was a problem hiding this comment.
LGTM with some minor points to address.
Signed-off-by: Taym Haddadi <[email protected]>
Signed-off-by: Taym Haddadi <[email protected]>
Add SharedWorker lookup and matching using storage key, constructor origin, constructor URL, name, type, credentials, extended lifetime, and secure_context state
Testing: more SharedWorker WPT test are passing now.
part of #7458