adapter icon indicating copy to clipboard operation
adapter copied to clipboard

TypeError: Cannot redefine property: ontrack

Open Fi1osof opened this issue 8 years ago • 18 comments

Browsers and versions affected Google Chrome Version 63.0.3239.132

[email protected]

Description 57 | unwrappedCb]); 58 | }; 59 | 60 | Object.defineProperty(proto, 'on' + eventNameToWrap, { 61 | get: function() { 62 | return this['_on' + eventNameToWrap]; 63 | },

I think requried check proto here: https://github.com/webrtc/adapter/blob/master/src/js/utils.js#L60

Steps to reproduce

Expected results

Actual results

Fi1osof avatar Jan 23 '18 02:01 Fi1osof

do you have steps to reproduce?

fippo avatar Jan 25 '18 08:01 fippo

Sorry, I think I did not correctly connect the component (via webpack).

Fi1osof avatar Jan 29 '18 02:01 Fi1osof

the same problem .. Chrome update fixes this (why??), and what about users with not latest Chrome version

mikhailtsai avatar Feb 03 '18 01:02 mikhailtsai

@fippo, hi!

Chrome 63.0.3239.132 version: There is no 'ontrack' property in window.PTCPeerConnection.prototype. Usually it's there, and with configurable: true, so your utils.js can redefine this.

And in this case, utils.js(line: 60) will create NEW property for this prototype, without configurable: true, I think it's wrong. And if something tries to redefine ontrack... you know, TypeError...

(Same problem in some Safari versions, I heared from my clients)

I used for testing: https://www.chrome-portable.com/ (GoogleChromePortable64_63.0.3239.132_online.paf.exe)

mikhailtsai avatar Feb 03 '18 05:02 mikhailtsai

@goldreich if problem is actual, i do reopen issue/

Fi1osof avatar Feb 03 '18 06:02 Fi1osof

And if something tries to redefine ontrack... you know, TypeError...

What is redefining ontrack?

fippo avatar Feb 03 '18 07:02 fippo

Same problem here:

screenshot 2018-02-15 10 25 27

iMacX avatar Feb 15 '18 09:02 iMacX

I have no idea what you are doing but looking at the chrome shim code https://github.com/webrtc/adapter/blob/650507360b2a57cea5e663cae1d27c78765cd3d2/src/js/chrome/chrome_shim.js#L21 it will only shim if it does not exist.

KaptenJansson avatar Mar 08 '18 09:03 KaptenJansson

I actually ran into this on a project using puppeteer for tests on chrome 62. It's not that line that causes it, it falls down to the else, here which does not have the same check.

xdumaine avatar Apr 13 '18 15:04 xdumaine

@xdumaine is shimOnTrack called twice?

fippo avatar Apr 14 '18 13:04 fippo

I'm having same problem on my production website. Any solutions to this issue?

topwebtek7 avatar Apr 19 '18 04:04 topwebtek7

@fippo yes, it's also called from here: https://github.com/webrtc/adapter/blob/master/src/js/adapter_factory.js#L73

xdumaine avatar May 07 '18 14:05 xdumaine

@xdumaine and where else?

fippo avatar May 07 '18 14:05 fippo

Sorry, yes, that's the only place. Error is if adapter is included twice on the page. But I do think that that call (https://github.com/webrtc/adapter/blob/master/src/js/chrome/chrome_shim.js#L122) will be problematic if it's ever hit - this is saying if ontrack is in the prototype, then call wrapPeerConnectionEvent, which redefines it. Any time that else block is hit, this error will occur.

xdumaine avatar May 07 '18 14:05 xdumaine

Optional solution is to use configurable: true here - https://github.com/webrtc/adapter/blob/master/src/js/utils.js#L60

xdumaine avatar May 07 '18 14:05 xdumaine

Error is if adapter is included twice on the page.

ah... that makes sense. I would not recommend doing this. Adding configurable: true seems like the right thing to do since

Object.getOwnPropertyDescriptor(RTCPeerConnection.prototype, 'ontrack')

shows both configurable and enumerable as true

fippo avatar May 09 '18 06:05 fippo

I have same error on adapter-6.3.0.min.js but not on chrome , just on electron's chrome

Talbot3 avatar Jul 18 '18 13:07 Talbot3

@orangebook can you open a new issue with steps to reproduce please?

fippo avatar Jul 18 '18 16:07 fippo