Replace track to switch camera loses sound

So i decided to change to using replaceTrack to switch cameras on mobile devices which works a lot better than removing a publisher, removing the publisher messes up the subscriber side.

However i have noticed now that when replacing the track for the camera, the sound gets lost. In my initial publish the sound works, i then get the front and back camera id and the audio id :

this.OVPublisher.once('accessAllowed', (event) => {
          console.log("ACCESS ALLOWED")

          this.OV.getDevices().then((devices)=> {

            let videoDevices = devices.filter(device => device.kind === 'videoinput' && device.label !== 'Snap Camera');
            if (videoDevices && videoDevices.length > 1) {
              this.canSwitchCam = true;
              this.frontDeviceId = videoDevices[0].deviceId;
              this.backDeviceId = videoDevices[0].deviceId;
            }

            let audioDevices = devices.filter(device => device.kind === 'audioinput');
            if(audioDevices && audioDevices.length >= 1){
              this.audioDeviceId = audioDevices[0].deviceId;
            }
          })

        })

Then to switch camera

this.OV.getUserMedia(<any>{
        videoSource: this.OVCurrentCamera === 'front' ? this.backDeviceId : this.frontDeviceId,
        audioSource: this.audioDeviceId
      }).then((mediaStream) =>  {

        let track = mediaStream.getVideoTracks()[0];

        console.log("USING TRACK FOR",track)
        this.OVPublisher.replaceTrack(track).then(() => {
          this.OVCurrentCamera = this.OVCurrentCamera === 'front' ? 'back' : 'front';
        }).catch(() => {
          this.toast.error('There was a problem switching cameras.');
        })
      }).catch(() => {
        this.toast.error('Could not access devices');
      })

The camera switches fine but yeh, the audio is lost? So basically the microphone on my iphone stops taking sound input?

I have posted again about this but from a different angle: https://openvidu.discourse.group/t/replace-track-to-switch-camera-causes-audio-input-to-stop-working-or-echo/4096/2

Ok so i found out that this only happens on iphone, on an android device the sound input still works.

So can anyone help me here? Why is it on the iphone when i switch video track there is no sound input? It happens to stay that way even when flipping the camera back to the original.

Also in the console from iphone when switching video track i get this error, so something isn’t right:

Another update, i have determined this line of code is the problem:

document.body.removeChild(_this.videoReference);

openvidu-browser-2.20.0.js line 6485

(same thing happens on 2.22.0)

_this.videoReference if i log it to the console is outputting a html video element with style: display:none;

This causes that error i posted previously, and when i look at the video element for some reason the id has -undefined on the end and i’m wondering if that’s the cause?