Skip to content

Twilio ERROR: pluginMediaStream with id= already exist #685

@ac1dev

Description

@ac1dev

YOU MUST read first!

Please use Community Forum for general technical discussions and questions.

  • I have used Google with the error message or bug in association with the library and Cordova words to make sure the issue I'm reporting is only related to iOSRTC.
  • I have provided steps to reproduce (e.g. using sample app code https://github.com/cordova-rtc/cordova-plugin-iosrtc-sample or updated extra/renderer-and-libwebrtc-tests.js file).
  • I have provided versions of third party library name, ios, Xcode and plugin version and adapter.js version if used.

Note: If the checkboxes above are not checked (which you do after the issue is posted), the issue will be closed, removing this checkbox will result in automatic closed issue.

Versions affected

  • Capacitor version (e.g 7.1.0): 2.4.6
  • Plugin version (e.g 6.0.12): 6.0.12 & 6.0.21 (tried both)
  • Ionic/React version: 5.5.0
  • iOS version (e.g 10.2): 14.5.1
  • Xcode version (e.g 11.1 - 11A1027): 12.5 - 12E262
  • WebRTC-adapter version (e.g. 7.4.0): /
  • WebRTC Framework version (e.g. JSSip 3.1.2): Twilio Video 2.13.1

Description

I have issue with plugin throwing error:

ERROR: pluginMediaStream with id=298A7E66-EDC5-4CC7-B367-8656213E3C0C already exist

I tried multiple things to fix this, all from GitHub issues that were previously open on this project, but nothing worked, unfortunately.

I found similar problem on another older issue, and I downloaded 6.0.12 specific commit that was shown there, and I also modified PluginMediaStream.swift line 25, changed it to this: self.id = rtcMediaStream.streamId + "_" + UUID().uuidString + String(rtcMediaStream.streamId.count);

but it still won't work.

Steps to reproduce

Setup twilio video
Install cordova-plugin-iosrtc

Try the following:

Example code:

  const registerRTC = () => {
    if (window.cordova.plugins.iosrtc) {
      window.cordova.plugins.iosrtc.registerGlobals();

      MediaStreamTrack.prototype.clone = function () {
        return this;
      };

      window.cordova.plugins.iosrtc.debug.enable('*', true);
    }
  };
  useEffect(() => {
    registerRTC();
    MediaStreamTrack.prototype.clone = function () {
      return this;
    };
    
    Video.connect(token, {
      name: chatDocument.id,
      audio: true,
      maxAudioBitrate: 16000,
      video: { height: 720, frameRate: 24, width: 1280 },
    })
      .then((room) => {
        setRoom(room);
        room.on('participantConnected', participantConnected);
        room.on('participantDisconnected', participantDisconnected);
        room.participants.forEach(participantConnected);
      })
      .catch((err) => {
        console.log(err, { message: err.message });
      });

    return () => {
      setRoom((currentRoom) => {
        if (currentRoom && currentRoom.localParticipant.state === 'connected') {
          currentRoom.localParticipant.tracks.forEach(function (trackPublication) {
            trackPublication.track.stop();
          });
          currentRoom.disconnect();
          return null;
        } else {
          return currentRoom;
        }
      });
    };
  }, []);

Expected results

To work

Actual results

Doesn't work, throws error

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions