Temasys / AdapterJS

AdapterJS Javascript Polyfill and Tools for WebRTC - Skylink WebRTC
http://skylink.io/web
Other
429 stars 100 forks source link

Error: Error calling method on NPObject on Safari 9.1.2 #252

Closed IagoLast closed 7 years ago

IagoLast commented 7 years ago

This code snippet allows to reproduce the issue, open it on a browser and click the button.

The "select media device" dialog is shown and after allowing the following error is logged:

Error: Error calling method on NPObject

Code:


<html>

    <body>
        <div id='log'></div>
        <input type='button' id='run'>
        <script type='text/javascript' charset='UTF-8' src="https://cdn.temasys.io/adapterjs/0.14.x/adapter.debug.js"></script>
        <script type='text/javascript'>
        document.getElementById('run').onclick = function() {
            function log(msg) {
                document.getElementById('log').innerHTML += msg.replace(/\n/g, '<br/>') + '<br/>';
            }
            var pc = new RTCPeerConnection();
            navigator.mediaDevices.getUserMedia({
                video: true,
                audio: true
            }).then(function(stream) {
                pc.addStream(stream)
            });
            pc.onicecandidate = function(e) {
                if (e.candidate) {
                    log('got candidate ' + e.candidate.sdpMid + ' ' + e.candidate.candidate);
                } else {
                    log('end of candidates, sdp: ' + pc.localDescription.sdp);
                }
            }
            pc.onnegotiationneeded = function() {
                pc.createOffer().then(function(d) {
                    log('got offer, sdp is ' + d.sdp);
                    pc.setLocalDescription(d);
                });
            }
        }
        </script>
    </body>

</html>

Safari: 9.2.1 OS: El Capitan 10.11.6

johache commented 7 years ago

CreateOffer does not support the Promises API in the plugin. Please use the callback style call: pc.createOffer(successCb, failureCb, constraints)

yaynick commented 7 years ago

@johache Will there be any support for promises in the future? Seems like callbacks will eventually be removed. https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/setLocalDescription

On another note, if we utilize the callback variations of the APIs on browsers that already natively support WebRTC (Chrome, Firefox, e.g ones that don't require the plugin), my understanding is that adapter.js will ensure the methods still function as intended even after the deprecated versions are completely removed from the WebRTC API, correct?

johache commented 7 years ago

We have not yet found a good way to support promise based functions. This is something that we regularly come back to, but if we are to do it, we want to do it right.

Regarding Chrome, FF etc, we only embed Google's webrtc/adapter. Assuming they maintain support for callback prototypes, then no problem. If they don't, we will have to consider supporting that ourself.