Duplicate remote tracks/streams only chrome

Hi,

I am trying to create a simple prototype with the jitsi lib and used the example script on github as a base. Everything is working fine, (re)join and leaving. Tracks are cleaned properly. But on chrome, after a user rejoins the conference, other user creating duplicate remote tracks. On firefox it does not happen. Can someone help me with that? Cleaning the cache in chrome, helps, but after a rejoin same issue.

Code for connect:

function joinConference() {
    JitsiMeetJS.init(initOptions);
    connection = new JitsiMeetJS.JitsiConnection(null, null, options);
   
    connection.addEventListener(
        JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED,
        onConnectionSuccess);
    connection.addEventListener(
        JitsiMeetJS.events.connection.CONNECTION_DISCONNECTED,
        disconnect);
   
    connection.connect();
}

Code for join conference:

function onConnectionSuccess() {
    room = connection.initJitsiConference('conferencename', confOptions);
    room.on(JitsiMeetJS.events.conference.TRACK_ADDED, onRemoteTrack);
    room.on(
        JitsiMeetJS.events.conference.CONFERENCE_JOINED,
        onConferenceJoined);

    room.on(JitsiMeetJS.events.conference.USER_LEFT, onUserLeft);

    JitsiMeetJS.createLocalTracks(localTrackOptions)
    .then(onLocalTracks)
    .catch(error => {
        throw error;
    });

    room.join();
}

Local Tracks

function onLocalTracks(tracks) {
    localTracks = tracks;

    for (let i = 0; i < localTracks.length; i++) {
        room.addTrack(localTracks[i])
            .then(track => {
                console.log("Local track added " + localTracks[i]);
                var streamElement;
                var type = localTracks[i].getType();

                if (type === 'video') {
                    streamElement = document.createElement('video');
                    streamElement.classList.add('video_stream');
                } else {
                    streamElement = document.createElement('audio');
                }

                const id = "local_" + type;

                streamElement.autoplay = true;
                streamElement.id = id;
                window.streamElements[id] = streamElement;

                localContainer.append(streamElement);
                localTracks[i].attach(streamElement);
            })
            .catch(error => {
                console.log("Duplicate track not allowed");
                throw error;
            });;
    }
}

Adding remote tracks

function onRemoteTrack(track) {
    if (track.isLocal()) {
        return;
    }

    const participant = track.getParticipantId();

    if (!remoteTracks[participant]) {
        remoteTracks[participant] = [];
    }

    remoteTracks[participant].push(track);

    var newContainer = $(`#${participant}_streamcontainer`);

    if (!newContainer.length) {
        var newContainer = $(`<div  id='${participant}_streamcontainer' class='video_stream_container remoteContainer'></div>`);
    }

    $('#videoStreamContainer').append(newContainer);
    var streamElement;

    if (track.getType() === 'video') {
        streamElement = document.createElement('video');
        streamElement.classList.add('video_stream');
    } else {
        streamElement = document.createElement('audio');
    }

    const id = participant + track.getType();

    streamElement.autoplay = true;
    streamElement.id = id;
    window.streamElements[id] = streamElement;
    newContainer.append(streamElement);

    track.attach(streamElement);
}

and the cleanup

function unload() {
    let localTracksCount = localTracks.length;
    for (let i = 0; i < localTracks.length; i++) {
        localTracks[i].dispose().then( value => {
            if((i + 1) == localTracksCount)
            {
                console.log("last removed success");
                room.leave().then(value => {
                    connection.disconnect();
                });
            }
        });
    }

    localContainer.empty();
}

function onUserLeft(id) {
    console.log('user left');

    if (!remoteTracks[id]) {
        return;
    }

    const tracks = remoteTracks[id];

    for (let i = 0; i < tracks.length; i++) {
        const key = id + tracks[i].getType();
        const streamElements = window.streamElements[key];
        tracks[i].detach(streamElements);
        delete window.streamElements[key];
        delete remoteTracks[id];
    }
    
    $(`#${id}_streamcontainer`).remove();
}