-
Notifications
You must be signed in to change notification settings - Fork 24
Make Error Event go after ondataavailable. #118
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
base: main
Are you sure you want to change the base?
Make Error Event go after ondataavailable. #118
Conversation
…alled stop and then an Event called Error
|
@foolip tiny change to write what we agreed upon in the bug, ptal. |
MediaRecorder.bs
Outdated
| far; after raising the error, the UA will <a href="#to-fire-a-blob-event">fire a | ||
| dataavailable event</a> with <var>blob</var>; immediately after the UA will then | ||
| <a>fire an event</a> named <code>stop</code>. | ||
| far; before raising the error, the UA will <a href="#to-fire-a-blob-event">fire a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of "will" here makes this sound not normative but rather descriptive. If this is the only place that ensures the order of things, can it say "must" more?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, in normative requirements, I would expect to see something like "queue a task to..." or clearly requiring that something happens synchronously. I'm not sure if the difference is observable, but basically I would expect the words here to map 1:1 to what an implementation actually does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(After some offline chatting, we've decided that is best to beef up this subsection and make it normative with the appropriate writing, otherwise is quite misleading. New PS coming imminently.)
…b.com:miguelao/mediacapture-record into prA03__send_error_event_after_ondataavailable
|
Ready for review @foolip |
foolip
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM % nits, if some other implementers takes a look that'd be good.
MediaRecorder.bs
Outdated
| If at any moment the UA finds an error condition, the UA MUST run the following | ||
| steps: | ||
| <ol> | ||
| <li>If {{state}} is {{inactive}} throw an {{InvalidStateError}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error probably happens in the background, so there isn't anywhere to throw the exception. Can there even be an error when inactive? Is it because state becomes inactive before it's really inactive?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was some legacy from before where the general principles of error handling stated that we should try to throw synchronously a DOMException if possible at all before having to fire the error event. The first part is kind-of obvious and is anyway stated individually in each of the commands (start(), stop() etc), so I'll remove it and go for the meat of the section.
MediaRecorder.bs
Outdated
| <li><a href="#to-fire-a-blob-event">Fire a blob event</a> named | ||
| <a>dataavailable</a> at <var>target</var> with <var>blob</var>.</li> | ||
| <li><a>Fire an event</a> named <a>stop</a> at <var>target</var></li> | ||
| <li><a>Fire an error event</a> named {{MediaRecorderErrorEvent}} at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MediaRecorderErrorEvent is the name of the interface, I guess the event type is just "error"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, changed.
MediaRecorder.bs
Outdated
|
|
||
| <li><a>Fire an event</a> named <a>stop</a> at <var>target</var></li> | ||
|
|
||
| <li><a>Fire an error event</a> named <var>event</var> at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be "error"? Apart from the name, the italics would also cause me to go looking for a variable named event which has a string value.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooops, my bad, I mean named {{UnknownError}}, next PS coming.
MediaRecorder.bs
Outdated
|
|
||
| <li><a>Fire an event</a> named <a>stop</a> at <var>target</var></li> | ||
|
|
||
| <li><a>Fire an error event</a> named {{UnknownError}} at <var>target</var>. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, now I see why this is confusing. https://w3c.github.io/mediacapture-record/MediaRecorder.html#errorevent-section is an event interface where the member is a DOMException.
The event type (the string that is the first argument to addEventListener) should be "error", so this should say 'Fire an error event named "error" with an UnknownError at target'.
I see that the two existing uses of "fire an error event" also has a slightly wrong incantation. It would be possible to just bake the type ("error") into the definition of "fire an error event", but that's an editorial decision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll write something in all three cases like:
<a>Fire an error event</a> named <a>error</a> with an {{UnknownError}} at <var>target</var>
(where <a>error</a> links to the error entry in the Event Summary section)
That should do the trick IIUC :-)
|
@jan-ivar this should be an easy review, PTAL |
|
@jan-ivar ping |
jan-ivar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So sorry for missing this request for so long! Hopefully it is not too late to provide feedback—thanks @Pehrsons for bringing to my attention.
I agree dataavailable should fire before error, unsure about stop. Also, we seem to have normative steps already that need to be fixed.
| It will signal a fatal error if these limits are exceeded. | ||
|
|
||
| If at any moment the UA finds an error condition, the UA MUST queue a task, | ||
| using the DOM manipulation task source, that runs the following steps: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I worry this is a bit broad.
But more importantly, it looks like we already have normative steps for this as mentioned above, so with this PR there would be two competing normative steps for this condition, which I think is confusing (do we fire twice?) - I'd vote we fix the existing place instead and leave General Principles non-normative or remove it, it seems a bit redundant.
| <li><a>Fire an error event</a> named {{UnknownError}} at | ||
| <var>target</var>.</li> | ||
| <li><a>Fire an error event</a> named <a>error</a> with an | ||
| {{UnknownError}} at <var>target</var>.</li> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should fix the event order here instead.
It looks like these are the normative steps we already have for recording errors, here in step 5.4 under the start method: "If the UA at any point is unable to continue gathering data for reasons other than isolation properties or stream track set, it MUST stop gathering data, and queue a task, using the DOM manipulation task source, that runs the following steps".
|
|
||
| <li><a>Fire an event</a> named <a>stop</a> at <var>target</var></li> | ||
|
|
||
| <li><a>Fire an error event</a> named <a>error</a> with an {{UnknownError}} at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Do we really want to fire stop before error? It would make it harder to detect errors IMHO. Most code I've seen seem to treat reaching stop without error as success, and this would break that assumption.
How about this order: dataavailable, error, stop?
|
@YellowDoge is this documenting the way Chrome works now after https://crbug.com/693179 was closed (2017)? |
|
@Pehrsons do you know if Firefox works the same as Chrome here? Any objection to merging this? |
|
Firefox fires events in this order:
My only concern with swapping "error" and "stop" is that it could seem unclear which session the "error" comes from since there potentially could be another "start" in flight at this point. |
Upon an error condition, first fire an Event called
ondataavailable, then an Event calledstopand finally fire an error event.Addresses #52 .
Chrome update in progress in https://crrev.com/2697703003
Preview | Diff