Closed Bug 1623852 Opened 5 years ago Closed 5 years ago

[Proposal] Require a httpCode for MediaError

Categories

(Core :: Audio/Video: Playback, enhancement)

76 Branch
enhancement
Not set
normal

Tracking

()

RESOLVED WONTFIX

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.

Bugbug thinks this bug should belong to this component, but please revert this change in case of error.

Component: Untriaged → Audio/Video: Playback
Product: Firefox → Core

It is belong to video playback

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!

Flags: needinfo?(vicysb)

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!

Flags: needinfo?(vicysb)

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?

Flags: needinfo?(vicysb)

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.

Flags: needinfo?(vicysb)

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.

Status: UNCONFIRMED → RESOLVED
Closed: 5 years ago
Resolution: --- → WONTFIX

Yes. Thank you!

You need to log in before you can comment on or make changes to this bug.