-
Notifications
You must be signed in to change notification settings - Fork 114
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
RTCSessionDescription parameters should be readonly. #573
Comments
"which would be a travesty (an interface as an attribute is by reference)." The localDescription and remoteDescription parameters of the PC are already readonly, which makes the code you suggest illegal (unless I've misunderstood the properties of a readonly attribute). 4.7.2 says "Attributes on this interface are mutable for legacy reasons." I see no compelling reason to change it. |
The type attribute was readonly to begin with, but we changed it to allow scripts to, for example, switch from an "answer" to a "pranswer" before setting. |
I checked with our DOM guys, and If we do what I suggest then there's no reason to leave them for legacy reasons, since createOffer would return |
Also, dictionaries have copy semantics, whereas interfaces do not. So a conforming implementation of the current webidl MUST work like this: var pc = new RTCPeerConnection();
pc.createDataChannel("dummy");
pc.createOffer().then(offer => pc.setLocalDescription(offer))
.then(() => {
console.log(pc.localDescription.type); // offer
pc.localDescription.type = "answer";
console.log(pc.localDescription.type); // answer
})
.catch(log); Luckily, neither Firefox nor Chrome are compliant. |
You can't have an attribute with a dictionary type. The right solution is to make |
Yes I just meant remove the legacy mutability. The interfaces are needed forever for the attributes. |
https://crbug.com/662898 is a bug originating from @philn with Igalia where they (I presume) they tried to follow the spec but ran into trouble. @philn, if you think the spec should change, can you file a new issue describing the compat constraints? |
Somewhat relevant is also whatwg/webidl#213, but compat demands what it demands. I've asked on the Chromium issue if appear.in might change in the meantime. @ShijunS, do you know what the Edge behavior is here? |
In WebKit we're following what the spec defined: https://github.com/WebKit/webkit/blob/master/Source/WebCore/Modules/mediastream/RTCSessionDescription.idl#L41 |
Somewhat related is that RTCSessionDescriptionInit's type is required in the spec but not in Gecko or Blink. I'll sprinkle some use counters in Blink, not sure whether reverting the spec change or trying to match the spec is better overall. |
I'm 90% sure that both Gecko and Blink implemented RTCSessionDescriptionInit before IDL "required" syntax existed, which is why they're not using it yet... |
Indeed, no surprise there. Per https://twitter.com/pnormand/status/795938320224309249 appear.in changed their code, so let's hope that most other usage in the wild doesn't depend on the current behavior. (Use counters in https://codereview.chromium.org/2490543002/) |
Re Edge behavior, we have tried to follow the spec before this change. However, in our implementation, both localDescription and remoteDescription are new interface objects copied from the media stack. They can change when app calls setLocalDescription() and setRemoteDescription(). But, we don't pass down any app-level change to the lower level. There is no major conflict to the change of "type" and "sdp" to readonly. At this point, setLocalDescription() and setRemoteDescription() still require RTCSessionDescription interface object as input, and will throw exception on RTCSessionDescriptionInit. Similarly, createOffer() and createAnswer() will return RTCSessionDescription interface object rather than RTCSessionDescriptionInit dictionary. I expect this option will stay until all major browser implementations and websites have migrated according to the latest spec. |
Looks like we missed a common use-case when we made this read-only: new RTCSessionDescription().sdp = "v=0\no=- 627673561523047307..."; I suppose we could solve it by using a different interface for the attribute... |
@foolip Or maybe make |
Freeze which attributes? What are their types? |
@bzbarsky pc.localDescription and friends. |
I don't see how freezing them would do any good. What would be the goal? |
@bzbarsky To prevent |
Freezing it won't prevent that, because the setter isn't mutating any state the freezing freezes. |
The current language implies that content can modify the local description like this:
which would be a travesty (an interface as an attribute is by reference).
In light of #302 I propose we solve this by changing
RTCSessionDescription
's parameters toreadonly
, and changecreateOffer
andcreateAnswer
to resolve withRTCSessionDescriptionInit
instead.The text was updated successfully, but these errors were encountered: