Flickering desktop track

after sharing desktop screen its flickering on both side (receiver & sender)
i actually use “Jitsiconference.replaceTrack” function to share desktop screen is it the good way to share screen ?? or what i am doing wrong in this scenario there is my functions of share desktop screen and camera

   async camera() {
      try {
        let desktopVideo =
          this.localTracks[1]?.type === "video"
            ? this.localTracks[1]
            : this.localTracks[0];
        const videos = await JitsiMeetJS.createLocalTracks({
          devices: ["video"],
          resolution: this.resolution,
        });
        const video = videos[0];
        if (video && desktopVideo) {
          await this.JitsiConference.replaceTrack(desktopVideo, video);
          if (this.localTracks[1]?.type === "video") {
            this.localTracks.splice(1, 1);
            this.localTracks.splice(0, 0, video);
          } else {
            this.localTracks.splice(0, 1);
            this.localTracks.splice(0, 0, video);
          }
        }
      } catch (error) {
        Console.danger("error in camera function", error);
      }
    },
    async shareScreen() {
      try {
        let video =
          this.localTracks[1]?.type === "video"
            ? this.localTracks[1]
            : this.localTracks[0];
        if (JitsiMeetJS.isDesktopSharingEnabled()) {
          const desktop = await JitsiMeetJS.createLocalTracks({
            devices: ["desktop"],
            resolution: this.resolution,
          });
          const desktopVideo = desktop.length === 1 ? desktop[0] : desktop[1];
          const desktopaudio = desktop.length === 2 ? desktop[0] : null;
          if (desktopaudio) {
            //TODO
          }
          if (video && desktopVideo) {
            await this.JitsiConference.replaceTrack(video, desktopVideo);
            if (this.localTracks[1]?.type === "video") {
              this.localTracks.splice(1, 1);
              this.localTracks.splice(0, 0, desktopVideo);
            } else {
              this.localTracks.splice(0, 1);
              this.localTracks.splice(0, 0, desktopVideo);
            }
          }
        }
      } catch (error) {
        Console.danger("error in shareScreen function", error);
      }
    },