-
Notifications
You must be signed in to change notification settings - Fork 137
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
VideoEncoder configure does not return a promise #242
Comments
There are a lot of competing goals in the design. One of the primary goals was to allow implementations to defer applying configurations until they also have a frame, either to conserve resources that may never be used, or to resolve ambiguities that a configuration alone doesn't answer. In this case a There are platforms where it is difficult to determine whether a configuration is acceptable without also decoding a frame, and in this case the only reasonable feedback mechanism is the In general we have also strived to remove
The second prototype in Chrome was |
Here is some documentation of the design discussions that took place around this in October of last year In reply to these points:
Apps should detect this by first querying There will be very very narrow cases where configure() may still fail (say your stream has some quirk that your hardware doesn't like), and those will trigger the error callback as Dan points out. Using a promise doesn't make those (rare) edges any softer.
This is another topic discussed at length last year. We arrived at the current design for similar reasons of massively simplifying the usage pattern. Making errors fatal removes any ambiguity about what state the control message queue is in, which decodes were accepted vs aborted, which configure() was most recently applied, etc., etc... The answer is instead very simple: everything is dropped, please make a new codec. Also, I want to add emphasis to Dan's comment:
+1000. Removing promises from these APIs was a hugely simplifying for apps. |
Triage notes: marking 'extension' as the request is to change the return type from one that is currently Note: My stance on actually taking up this extension (opposed) is given in the prior comment. |
If need be API users can call flush() after configure() to achieve a similar result. |
I understand this is a simplification from an implementation point of view, but it seems that this is at odds with the desire to build a generic purpose encoder/decoder API. |
Sorry, I'm not able to connect the dots. Why is this at odds?
I think the explainer covers this pretty well. I'm not sure what assumptions you mean. |
Codecs may have non fatal errors. Dropping a frame is for instance a non fatal error. Ditto for trying to decode bad data, or decode data that is missing reference frames. By making them fatal errors, the web application can no longer have specific error handling for those cases.
I was confused by the fact that supporting realtime mode (with the ability for encoders to drop frames) was not totally part of the API design, so I was assuming not part of the requirements. According the explainer and #240, it seems there is rough consensus to have that support in V1. |
For encoders, it is hard to think of a non fatal error, except for the most trivial ones, like a frame format is not supported by the encoder's. Such trivial errors are easy to avoid for API users, they usually indicate bugs in the code.
If an encoder drops a frame because it can't meet bitrate constraints, it is not an error. It is a completely normal situation. |
@Djuffin said: "If an encoder drops a frame because it can't meet bitrate constraints, it is not an error. It is a completely normal situation." [BA] That makes sense to me, but in Issue 240, it is noted that dropping if disallowed (even with a bitrate constraint??) would be considered an implementation bug. Seems to me like it shouldn't be permitted to simultaneously disallow frame drops and set a bitrate constraint. |
Bad data could be a fatal error for some impls.
The error callback can provide specific errors. For instance, bad data would be EncodingError.
Lets move this discussion to #269. We should consider these points there. |
VideoEncoder configure can succeed or fail but it is unclear when the web page will know for sure that it succeeded or failed.
It seems that returning a Promise would help.
One example where it could potentially fail is if H264 is used with a low level but a very high image resolution, or hardware requirements.
Another small issue here is that configure can be called and frames can be enqueued as soon as configure is called, even though in practice, configure might fail. If configure actually fails, the web application would need to either store the frames, which is bad, or agree to forget about the frames.
It also seems that, if an encoder is successfully configured, configure can be called again. If so, it could stick with the old configuration if the second configure fails instead of going to an error state.
It also seems that, if the encoder is in an error state, it cannot recover even with configure. Is there a reason for that design?
This might also apply to decoders or audio encoder.
The text was updated successfully, but these errors were encountered: