[Proposal] Require a httpCode for MediaError
Categories
(Core :: Audio/Video: Playback, enhancement)
Tracking
()
People
(Reporter: vicysb, Unassigned)
Details
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
Steps to reproduce:
This is a proposal. Original issue links here https://github.com/whatwg/html/issues/4999
Actual results:
Problem
When a video error occur, we can get the error code through MediaError. The code defines here:
interface MediaError {
const unsigned short MEDIA_ERR_ABORTED = 1;
const unsigned short MEDIA_ERR_NETWORK = 2;
const unsigned short MEDIA_ERR_DECODE = 3;
const unsigned short MEDIA_ERR_SRC_NOT_SUPPORTED = 4;
readonly attribute unsigned short code;
};
The problem is, when it comes to MEDIA_ERR_SRC_NOT_SUPPORTED, developer can't confirm what had happened. It could be one of the following issues:
The src request returned a 403, 403 or 5xx.
The src request returned a 200, but it's a html page instead of video. Most likely the request has been blocked.
The src request returned a video but the encode was not supported.
Other exceptions.
In these cases the "error.message" is empty or just "Format error", no further information.
Proposed API: a httpCode on MediaError
We propose an addition attribute, httpCode, on MediaError. So developers can figure out what happened and report the issue. Here's a example:
let video = document.createElement('video');
video.addEventListener('error', function() {
console.log(this.error.httpCode);
}
Other consideration
By getting the httpCode, we need to follow the CORS specification. Only When the request pass the CORS successfully(or in the same domain), it's allowed to read the httpCode, otherwise throw an exception.
Besides video element, audio can share the httpCode too.
Comment 1•5 years ago
|
||
Bugbug thinks this bug should belong to this component, but please revert this change in case of error.
Comment 3•5 years ago
|
||
Hi vicysb, have you used Tools > Web Developer > Network
? This panel provides all sorts of info about network requests in Firefox, and should show the HTTP response/status code, among others, for developers to check whether there are network related issues. Please let us know if that's not sufficient for your needs and what we can add to help. Thanks!
Hi John,
Actually this issue is for collecting error from end users, and given more detail for the error info.
There's an issue in chromium that provide more detail from mediaerror(including httpcode likely). https://bugs.chromium.org/p/chromium/issues/detail?id=1043289
Hope mozilla can provide such info.
Thanks!
It's not clear to me from the bug on Chromium that they intend to include the http status code -- please let me know if I'm overlooking something. It looks they're plumbing richer error information, but without changes to the MediaError interface. I imagine the message on the MediaError could be used to expose this information. Is there a reason that a status code would be more useful than the currently provided error message field?
You're right. The 'httpcode' message will be included in MediaError(Maybe extend some more err code), instead of making a new attribute, after I discussed with Chromium.
Closing this based on the above. We may be able to raise better messages in our error strings, but we won't need an extra field to do so.
Description
•