-
Notifications
You must be signed in to change notification settings - Fork 73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
video.requestVideoFrameCallback() #250
Comments
cc @jyavenard @padenot for their opinions. |
webkit-dev thread: https://lists.webkit.org/pipermail/webkit-dev/2020-January/031030.html |
This link has the latest information: |
Some assorted comments on this, sorry for the delay:
Also it feels a bit weird to have capabilities like this that tie frame availability (at the decoding and/or network level) with info about presentation, without a way to handle back-pressure or under-runs. In terms of extensible web, this would go alongside web codecs (but probably wouldn't be needed if web codecs existed), and not be on Generally, having a way to observe the fact that new frames are available on a video element is a good idea, and is necessary for the platform, but there are a number of initiatives that can solve this, are also underway (Web Codecs, Video Editing), and allow doing more than observing video frame availability, in a way that is useful. It would be best to coordinate so that we end up with multiple ways of solving the same problem at different layers. The simplicity of this new API is appealing however, but I'm afraid it's a bit ad-hoc to solve a particular problem. This is |
@padenot were the "update the rendering" bits in https://wicg.github.io/video-raf/#video-raf-procedures when you reviewed this? I think that implicitly answers certain questions like "what happens if the main thread has a high load" although it doesn't say anything about back pressure. |
Yes I had indeed a lot of this written in the previous state of the proposal (when it was an explainer in a markdown file), but updated everything this morning, looking at the newer proposal, where the intent seem to have been a reduction in scope, but maybe not, since this is still before The back-pressure is the important bit, it is clear what happens, but it is not clear if what happens is desirable, the question is mostly rhetorical. This all depends on the purpose of the API: observation of frame compositing vs. scheduling of frame compositing vs. both, and the current text doesn't make this clear, it has a bit of everything. The problem is that both goals are useful, so I don't know that this reduction in scope was intentional, incidental, or exists at all: it's possible that the author implicitly relies on the fact that everything will happen on the main thread, as part of the algorithm |
Thanks for the thorough comments. I've tried to address them as best I can inline below.
The original "explainer API" had some push characteristics. I don't think the current API does. It runs like
Yes.
It's useful to trigger texture uploads at the video frame-rate. There is timing information, but there are no timing guarantees.
I don't fully understand this example, but from what I understand, yes. For example, WebRTC applications could use the metadata from
I will be updating the abstract/intro text to be more consistent, and closer to "runs after a frame has been presented".
If the main thread has a high load, the video will still play smoothly, and we will get fewer callbacks. Web authors can detect how many frame's info they've missed. I am not following what you mean by signalling back-pressure from the compositor to the decoder.
I was considering renaming presentationTime to timePresented, and expectedPresentationTime to expectedDisplayTime (keeping presentationTime the same). Any thoughts?
Are you referring to the mention of WebGLVideoTexture in the original explainer (e.g. here's the commit that removes it)?
The API is about observing composition events, but work can be done in the callbacks. The current implementation isn't perfect (when drawing from a 25fps video to a canvas, the canvas is sometimes 1 v-sync behind the video), but it's less wasteful than doing unnecessary work via window.requestAnimationFrame.
Callbacks will never be fired more often than the "brower's frame rate". 120fps video on a 60hz screen should fire video.rAF callbacks at 60hz.
I haven't looked into this, nor do I have a way of testing this. Video.rAF should behave the same as window.rAF in those cases.
One of the intended uses of the API is still WebGL and canvas applications. We considered making the API an event that runs as a microtask. Painting a 60fps video on a 60hz screen from microtasks was definitively not as smooth as running callbacks in the rendering steps.
It should work as expected. There is nothing directly dependent on
E.g. pulling info from the compositor to the main thread during the rendering might have a performance impact?
Could you expand on what back-pressure/under-runs would look like for this API? The API isn't proposing any scheduling of frame compositing (unless you include drawing to a canvas from inside a callback). Whether the callbacks run on time or not does not affect the smoothness of the HTMLVideoElement. If the main thread is under a heavy load and there are fewer rendering steps, the callbacks won't be run as often, and won't be re-registered as often (if the callbacks queue up another video.rAF). |
I'm copying here (reformatted/rewritten/added something so it makes sense in context and because I've thought a bit more about this) the important points I had in private.
This is the main problem with this proposal. This is also a fundamental contradiction with the way rendering works on the web. The text says that there are no guarantees when it comes to scheduling, but there is, and it's quite central, it allows a synchronization of canvas and CSS, for example (the general term is something like "atomicity of rendering", I'm finding Chromium docs when I search for this). Roughly, everything that happens in the same The problem here is the contradiction in goal vs. approach: it is said that this API is to observe composition events of videos, but those callbacks happen before
It feels really weird to tie everything together here. As an author, what choice would you make based on those numbers? Deciding to drop a frame because it's too late?
I've answered above, let me know if it's unclear. It's not confusing anymore, it's now clear what happens, but it's technically problematic for the reasons outlined above.
How can one tell that the decoder is struggling, vs. the compositor? This can be observed via the video quality metrics, but how can authors decide what to do here?
The current version of the description of the attribute is good (and solve the ambiguity for sure), but the names are not uniform. Depending non other factors, such as the scheduling of the callbacks, they will need to be renamed.
Yes, this was nice and useful.
It's problematic to ship an API while stating that one of it's core use-cases cannot be properly solved. I certainly agree with not doing any wasteful work however. We can make it so that the video and canvas are perfectly in sync. The video frame is already in memory anyways, when that happens (video memory or regular memory, depending).
Sounds good.
Adaptive sync is the most important thing that has happened to video playback since battery-powered video playing devices exist. We can't simply ignore it here. We might find that it just works however, but we need to look into it and to allow for it to kick-in.
I don't understand what microtask have to do with this or how they can help. We can't artificially reduce the usefulness of the API at the design stage for one of it's intended use-cases.
Sounds good but maybe this needs to be said.
Not if it's just signaling composition, but just signaling composition is in opposition with the stated use-case of the API.
Yes this is the main contradiction again, this API, as it stands, has artificial limitations for one of its use-cases, and it doesn't have to be like that. Having this in a worker with an Changing the semantic to be an event that signals when a new frame is available is about to be submitted to the compositor for display (i.e. would be after the next In any way, it's better to work on this in the |
We had a call just now with the Chromium people involved in this. Most of my criticism here was about the presence of a non-compressible frame of latency, that seemed to be implied by wording like this (the text at https://wicg.github.io/video-raf/#introduction as of commit WICG/video-rvfc@97577fb):
In particular the use of past tense seemed to implied that this happens after the video frame has been sent ("presented") for composition. In fact this is not quite what happens in practice. This callback happens before We discussed about the naming of the main callback of the API. I don't like it, because I think it expresses something else than Some attributes names are not aligned with what we usually see on the web platform: something with required DOMHighResTimeStamp timePresented;
required DOMHighResTimeStamp expectedDisplayTime; are constructed differently from each other. It wasn't clear what the three last attribute precisely means, they were lifted from WebRTC: DOMHighResTimeStamp captureTime;
DOMHighResTimeStamp receiveTime;
unsigned long rtpTimestamp; I think first and second are extremely useful in live-stream scenarios (twitch, mixer, periscope, etc.), the last one I'm not sure, I'm not familiar enough to comment. Those should be defined with enough care to allow another implementation to work in a compatible manner, as usual. We talked about scriptable extension points to be able to do this from a worklet-like scope, which would free it from main thread scheduling hazard, and about worker uses, which need not block this, because it's a separate API. I'll now move to the repo there (https://github.com/wicg/video-raf/) to continue feedback and bikeshedding on naming etc. |
Thanks Paul! Per our VC it seemed you were okay with Chrome shipping with the name as is, but now it sounds like you want to discuss the naming more. Can you confirm you stance? Sorry if we misunderstood and happy to continue discussion in an issue on the video.rAF spec; the salient points from our discussion which I thought swayed you were:
Let me know if I missed anything. |
Did you mean neither video.rAF nor window.rAF always request something? window.rAF does always request something. It triggers an "update the rendering" step, which causes the rAF callback to fire (even if there is no other rendering to do). This is not true of video.rAF. |
Yes I did mean neither. Thanks for the correction! Both window.rAF and video.rAF trigger the "update the rendering" step per current spec language. My statement was more in the vein of a conceptual description since that's how Paul was discussing it. |
My argument is the following:
I'd prefer if the name of this new feature would convey what it does, but I can live with the current name (we're discussing other naming issues on the |
I opened an issue on the WICG repo. I propose we move the API naming discussion there. |
Link? |
Sorry: WICG/video-rvfc#44 |
@padenot do you think we can make a statement now about whether this is something that is valuable to add to the web, or that it is likely harmful? Or do you think we need to wait for more spec discussion to happen before we can make that call? |
It's best to wait, the discussion is ongoing. |
@padenot is there any discussion remaining besides the naming (which now seems resolved)? |
Yes indeed, I should have written here after reading the other thread and agreeing. I'd say this is |
@padenot The one thing that would be helpful to me (for adding this to the positions table) is a one or two sentence explanation of why this would be a useful addition to the web platform, i.e., what value it adds. |
FIXME: Needs a mozPositionDetail. Closes mozilla#250.
Updated repo link if anyone is looking for it: https://github.com/WICG/video-rvfc |
Historically, there has been no way of knowing the frame rate of an This means that authors that want to do any processing on a video are bound to do any of the following (depending on the scenario):
And there is no real answer for variable-frame rate video, or any sensible handling of dropped frame. Some quick examples of scenario enabled by this new API (not exhaustive of course):
Those scenarios are ubiquitous on platforms other than the web platform, especially (not not only) in the mobile application ecosystem. |
Hi Mozilla devs, |
+1 any update on this one ??? |
Now that Safari has already provided this feature, only Firefox is missing... Is there a way to test the feature? Firefox Nightly does not deliver the feature yet. |
Any update? This is really critical for applications that need to accurately sync a canvas with a video, and now that the API is provided by both Chrome and Safari it's not practical to be working around the missing API for Firefox alone ... |
I could note there isn't a proper spec for this, so it implementing is a tad hard. |
The currently working WICG spec link is https://wicg.github.io/video-rvfc/. |
I created a polyfill for this! https://github.com/ThaUnknown/rvfc-polyfill/ this runs closely to the video framerate, but can sometimes be off by a few milliseconds or up to a frame, but is still better than not being able to use this API at all, and is way better than just running |
I have started using requestvideoframecallback on Chrome to convert video to GIFs. Is that possible with the proposed solutions above? Here's a working version for Chrome: thx! |
requestVideoFrameCallback does not guarantee that you will get a callback for every frame of your video. You should consider using the WebCodecs API instead, if this is one of your requirements. WebCodecs also allows convert videos into gifs faster than in realtime. |
Request for Mozilla Position on an Emerging Web Specification
Other information
HTMLVideoElement.requestAnimationFrame() provides a reliable way for web authors to know when a frame has been presented for composition, and to provide metadata for that frame.
The text was updated successfully, but these errors were encountered: