Repository navigation
Conversation
| changed, and it cannot have a rendering context. The content of the placeholder canvas is | ||
| updated by calling the <code data-x="offscreencontext-commit">commit()</code> method of the | ||
| <code>OffscreenCanvas</code> object's rendering context. | ||
| updated on the rendering updated step of the current scope. |
There was a problem hiding this comment.
What are you trying to say here? It's updated whenever the browser chooses to update the rendering as per the event loop section? If so, maybe we should make it explicit when that happens relative to the events.
There was a problem hiding this comment.
(What's also important here, does the user have to update it at that point or can they skip canvas updates while still performing layout?)
There was a problem hiding this comment.
I meant to say: whenever the browser chooses to update the rendering of the OffscreenCanvas as per the event loop section. By "make it explicit" you mean on the rendering update section?
I'm not sure what you mean by your question. Could you clarify it?
The overall idea is:
- canvas gets transferred to an offscreenCanvas.
- OffscreenCanvas gets sent to a Worker.
- During the rendering update of the Worker, the current OffscreenCanvas gets redraw (updated) AND the content of the original canvas (the placeholder canvas) gets updated.
Notice that the rendering update of the main document doesn't play a part here at all.
There was a problem hiding this comment.
Yeah, by making it explicit I meant having this be a step in the "update the rendering" algorithm that does the drawing.
The placeholder canvas isn't in the "main thread" document?
There was a problem hiding this comment.
The placeholder canvas is, but the update comes from the rendering of the offscreencanvas associated with it. I'll update the rendering algorithm to explicit "update placeholder canvases associated with..."
There was a problem hiding this comment.
There is no rendering update of the worker though, right? That only appears once #3677 lands. I guess this PR is blocked on that one?
| data-x="offscreencontext-commit">commit()</code> method of the <code>OffscreenCanvas</code> | ||
| object's rendering context.</p> | ||
| <span data-x="intrinsic dimensions">intrinsic size</span> will only be updated during the | ||
| rendering update.</p> |
|
So the placeholder canvas, which is on the main thread, gets updated based on the rendering update timing in the worker thread? Is that not problematic for developers that it's not synchronized with the main thread's rendering updates? What if they have an animation going on as well? |
|
Your first phrase is correct. There's no expectation of synchronization between the main thread and the worker thread's rendering/animation. That's a feature of having OffscreenCanvas on a worker: if the main page is blocked/slow/hanging on something, the animation driven by OffscreenCanvas stays as smooth as the browser's rendering can make it. They are supposed to be time-independent and not synchronizable (at least not easily animation synchronizable). |
|
Marking as "do not merge yet" as this seems to be blocked on #3677 which defines the concept of "rendering updates" for workers. Once that lands we can fix up the phrasing. Otherwise the patch seems good. |
|
Rebaselined since #3677 was pushed. |
|
@fserb thanks, but it seems you still haven't made the relationship explicit. It also relies on an undefined term "scope". Basically, the specification needs to define everything from first principles. |
|
@fserb to get this moving again, replace
and
and
all with with
|
|
If you'd like to take over the PR and address the comments and merge conflicts, I think that would be great. I suspect @fserb has become busy. |
|
I'd like to note that there are some edge cases that are being made weird when relying only on Example 1 and related: That user wanted to record the stream from a placeholder canvas, on which they draw from a Worker. Example 2: That user did create a Worker only to render one image and then killed the Worker as soon as it performed the drawing operations. This caused an issue where the drawings weren't committed to the placeholder canvas yet, because rAF didn't fire before the Worker got terminated. I know creating a Worker for just one drawing is a very bad design, but that same issue could have happened even in more usual circumstances, if the user doesn't wait for after the next painting frame before terminating the Worker. (Somehow Firefox's current implementation seems to be able to handle that one, I'm curious how it is done). I'm not saying we should absolutely keep |
|
Example 1: How does that compare to video? To me, canvas from a worker is similar to video. You don't get much synchronization by default. To sync the main thread with canvas work from a worker AFAIK the solution is supposed to be that you call Example 2: sounds basically the same. If you want to synchronize, transfer an imagebitmap. It's not clear how |
Yes that was the purpose of
This is mainly irrelevant. The point is not about having anything synced to some timer, the point is that the image never ever reaches the placeholder canvas nor the captured stream.
They don't want to synchronize, they want their drawings to be rendered on their placeholder canvas. Using a bitmaprender might workaround these issues, just like waiting for |
All of that just sounds like bugs in the browser. You shouldn't need A similar issue has come up in WebGPU where people were adding calls to The difference between |
I don't think this is true. Currently you need to wait for a rendering opportunity for this commit to happen. In current specs texts for the Worker event loop it's if "the user agent believes that it would benefit from having its rendering updated at this time". But terminating a worker also disregards all queued tasks*, so calling |
|
This is the wrong place to address this. Each type of context has it's own needs. If As one solution, you could make it so that all |
|
I'll have to disagree, here seems like the exact place we need to handle that. For the closing Worker case, queuing a task doesn't work, tasks are disregarded. But I guess it could be as simple as adding a clause "or if the closing flag is set to true" when determining if this update the rendering step should be ran, though maybe it needs to be more complex to avoid the animation frame callbacks. But I'm not even sure that would be correct either. |
|
It is not the place to handle it. You can not go forcing an API call across contexts. CanvasRenderingContext2D, WebGLRendingingContext, WebGL2RenderingContext, OffscreenCanvasRenderingContext2D, WebGPURenderingContext, ImageBitmapRenderingContext. They are all disparte APIs. At this level you don't know what implications will be there for the other APIs. For example what if the user calls commit 10 times in a row, 10 times in a row with draw calls between each both of those would make zero sense in WebGPU and all the issues around how to handle it would require a bunch of specification unrelated to any other context. So no, it does not belong here. Also tasks may not run after close but microtasks do |
|
Did you read the changes made in that PR? They are about when to update the content of the placeholder canvas, so that it happens in the OffscreenCanvas's scope's "update the rendering" step. That concerns the placeholder canvas, the one that stays in the main thread. |
|
I've got a fix ready for this, but I can't push a new commit on top of this PR. |
|
A new PR is probably the right way to do this, given that it's so old :) |
Takes over whatwg#3872 This removes the `OffscreenCanvas.commit()` method which has became obsoleted by whatwg#3677 This mainly handles the review comments left on the original PR. Note that I "hide" the merge-commit to make it clear what's changed from current upstream.
This goes beyond whatwg#3872 and removes the OffscreenCanvas contexts' commit(), method which has been superseded by requestAnimationFrame() since whatwg#3677 and is thus not strictly necessary anymore and might conflict with this new model. Closes whatwg#3872.
This is a follow up of: #3677
Also part of: #3587
@domenic I'm not very sure about the "current scope" language. Please advice.
💥 Error: Wattsi server error 💥
PR Preview failed to build. (Last tried on Jan 15, 2021, 7:58 AM UTC).
More
PR Preview relies on a number of web services to run. There seems to be an issue with the following one:
🚨 Wattsi Server - Wattsi Server is the web service used to build the WHATWG HTML spec.
🔗 Related URL
If you don't have enough information above to solve the error by yourself (or to understand to which web service the error is related to, if any), please file an issue.