Comments (8)
Constraining transferControlToOffscreen()
and its output seems like a reasonable solution to me. Having a weak reference to an element across process boundaries seems very sketchy.
We should probably require OffscreenCanvas
with a placeholder canvas
element to stay within the same agent cluster, just like SharedArrayBuffer
.
from html.
There was something like it, but it was not as well understood and had some issues ("unit of related similar-origin browsing contexts"). OffscreenCanvas
was added in 2016 and SharedArrayBuffer
/ agent cluster integration was added in 2017 (and then adjusted in 2020 for Spectre purposes).
from html.
The specs currently explicitely disable rAF in SharedWorker and in ServiceWorker by checking at the substep 1. of your link if the global object is a supported DedicatedWorkerGlobalScope
.
And to be supported means
So not only is this reserved to windows and dedicated workers, but it even excludes the dedicated workers that have been created from a SharedWorker.
I guess there is a bug in that we do expose OffscreenCanvas
in all Worker
scopes though.
Actually it does make sense to expose it in other scopes, but I'm wondering why you do need to hook to update the rendering? Currently all it does is to update the content of a placeholder <canvas>
element. But in a SharedWorker or a ServiceWorker you will never have such a placeholder <canvas>
.
[edit]: I now realize there is nothing preventing the transfer of such an OffscreenCanvas
gotten from transferControlToOffscreen()
using serviceWorker.postMessage(data, [canvas])
or sharedWorker.postMessage()
... However from my quick tests it seems only Chrome does support doing so with ServiceWorkers, while Firefox and Chrome support it for SharedWorkers. So indeed, if we do allow transferring such DOM-weak-linked OffscreenCanvas, we should probably expose rAF there. But maybe we don't want to allow these in such contexts? Is there an use case for it?
Maybe someone from @whatwg/canvas may want to chime in.
from html.
@beaufortfrancois did you look into blame to figure out why things are constrained the way they are? Service workers in particular do not seem like a place that should have to care about rendering at all. Shared workers is also fraught I think as they can be associated with multiple documents each of which can have their own refresh rate. What should the refresh rate of the shared worker be?
I think the change to WebGPU should be reverted and we should look into potentially constraining OffscreenCanvas
more.
from html.
What @Kaiido concluded seems right to me.
We've seen many reasonable use cases of OffscreenCanvas
in ServiceWorkers, like folks trying to build resource icons or pre-loaded images on the fly ("hash default images", etc).
Regarding them being transferred, it does seem to me that the current set of constraints (Windows or Workers that are "children of a Document") seems reasonable to follow (i.e., you can only transfer if it's created from a Document, therefore those are the only ones that need some rendering update notion).
Apart from "easy to plug in on the spec", is there any reason why WebGPU content can't be updated without the worker having a "render update"?
from html.
WebGPU is useful without a canvas, and we definitely want it in ServiceWorker/SharedWorker regardless. And if OffscreenCanvas is going to stay in these workers (I think it should), it secondarily validates that choice.
That to say, I think we can fix-forward in the WebGPU spec, because the error is very small (and has an inline issue attached to it already). We're already mostly correct in that we only define an interaction with rAF if the OffscreenCanvas is a linked one.
If indeed transferControlToOffscreen isn't valid to send to these workers, then we just have to remove the two hooks and leave a note explaining why only dedicated workers get this behavior. Which I agree makes sense.
from html.
This makes sense.
Just out of curiosity, did we even have the notion of agent clusters back when we added OffscreenCanvas
?
from html.
We should probably require
OffscreenCanvas
with a placeholdercanvas
element to stay within the same agent cluster, just likeSharedArrayBuffer
.
I did not realize that SharedArrayBuffer
had such a constraint. Matching that definitely makes sense!
from html.
Related Issues (20)
- Should dir=auto with no strong characters inherit directionality from parent or be ltr? HOT 10
- Navigation: DocumentState request referrer is not set for about:srcdoc
- `<callout>` element for callouts/alerts/admonitions HOT 35
- Proposal: HTML Attribute to state non-consent when scraping for training datasets HOT 1
- Can a task throw exceptions? HOT 2
- "run a classic script" returns completion records and throws HOT 1
- Session history step of top level navigable when child navigables traverse history HOT 1
- Should there be an opt-out for declarative shadow roots having `clonable=true`? HOT 27
- Should `<a target="_blank">` and `window.open` consume the transient activation? HOT 2
- `<img sizes="auto, 100px" loading="eager">`: `auto` equates to `100wv` but should ideally be ignored
- A way to run code before the next frame HOT 8
- New attribute for avoiding to autocapitalize text input fields HOT 1
- Autocomplete attribute value to indicate form input is third-party data
- Improve API of `insertAdjacent*()` methods HOT 2
- Why does popover hide when the popover attribute changed HOT 4
- Read-only state for buttons? HOT 6
- Upcoming WHATNOT meeting on 2/22/2024 HOT 5
- attribute change steps for popover may fire events synchronously HOT 6
- Update UA stylesheet rules to use `:any-link` instead of `:visited` or `:link` HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from html.