Skip to content
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

Firefox: do not attempt to modify read-only property in ice candidate shim #1123

Merged
merged 2 commits into from
Mar 12, 2023

Conversation

fippo
Copy link
Member

@fippo fippo commented Feb 22, 2023

fixes #1122

src/js/common_shim.js Outdated Show resolved Hide resolved
@fippo
Copy link
Member Author

fippo commented Feb 23, 2023

Sadly the patch doesn't apply clean to v7 or v6 (that one is still ES5) but it is easy enough to backport.


// Add a serializer that does not serialize the extra attributes.
augmentedCandidate.toJSON = function toJSON() {
// Override serializer to not serialize the extra attributes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this should be unnecessary, since enumerable defaults to false. Did it not work in ES5? If the default changed, does the following help?

Object.defineProperty(nativeCandidate, key, {
  value: parsedCandidate[key],
  enumerable: false
});

Copy link
Collaborator

@jan-ivar jan-ivar Feb 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If anything, my pilot error was caused by the custom toJSON on the native object persisting, causing me to mistakenly think the properties hadn't been copied, because I was using JSON.stringify to dump things to console in my first fiddle attempts, and even new enumerable properties weren't showing up for me.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify, I believe even with enumerable: true I would not expect new properties to appear in JSON, because of the native toJSON for RTCIceCandidate is already custom and limited.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True but this code still has to deal with the theoretical possibility of Chromes native toJSON predating the right thing

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I missed that this was fixing up existing code. LGTM!


// Add a serializer that does not serialize the extra attributes.
augmentedCandidate.toJSON = function toJSON() {
// Override serializer to not serialize the extra attributes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I missed that this was fixing up existing code. LGTM!

@fippo fippo merged commit 5137c44 into master Mar 12, 2023
@fippo fippo deleted the fix-fox branch March 12, 2023 08:25
@fippo fippo mentioned this pull request Mar 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RTCIceCandidate constructor shim throwing error if ufrag given for Firefox beta (111)
2 participants