client-sdk-js icon indicating copy to clipboard operation
client-sdk-js copied to clipboard

The stream is not restored when the shared window page is minimized and then zoomed in on the NW.js

Open zesun96 opened this issue 1 year ago • 11 comments

Describe the bug

expect: the stream track unmute and re-publish;

Reproduction

A share a window page; B view it good; then the window of A is minimized; B look black picture; then the window of A is zoomed in;

Logs

I add some logs at client-sdk-js:

  private handleTrackMuteEvent = () =>
    this.debouncedTrackMuteHandler().catch(() =>
      this.log.debug('track mute bounce got cancelled by an unmute event', this.logContext),
    );

  private debouncedTrackMuteHandler = debounce(async () => {
    this.log.debug('track mute event', this.logContext),
    await this.pauseUpstream();
  }, 5000);

  private handleTrackUnmuteEvent = async () => {
    this.log.debug('track unmute event', this.logContext),
    this.debouncedTrackMuteHandler.cancel('unmute');
    await this.resumeUpstream();
  };


but only recived "track mute event" on window  is minimized;

System Info

OS: Windows 10
NWjs version: 0.82.0
livekit client-sdk-js version: v1.15.13

Severity

annoyance

Additional Information

No response

zesun96 avatar Jul 05 '24 07:07 zesun96

I found that the following code was affected track unmute event: room/track/LovalTrack.ts

async pauseUpstream() {
    const unlock = await this.pauseUpstreamLock.lock();
    try {
      ...
      **await this.sender.replaceTrack(null);**
    } finally {
      unlock();
    }
  }

When I skip this code and run it again, it's fine.

zesun96 avatar Jul 05 '24 07:07 zesun96

Can you confirm that you don't receive a unmute event when maximising the window again?

Which browser are you on? Does the same behaviour reproduce with other browsers?

lukasIO avatar Jul 05 '24 07:07 lukasIO

I didn't receive unmute event. It is ok on google browser.

zesun96 avatar Jul 05 '24 07:07 zesun96

image

this is google logs when share window is minimized. google version: 126.0.6478.127

zesun96 avatar Jul 05 '24 07:07 zesun96

When I commented out the following code in nwjs: await this.sender.replaceTrack(null); I can receive unmute event.

zesun96 avatar Jul 05 '24 07:07 zesun96

are you able to reproduce this in the sample app using pnpm sample in this repo?

lukasIO avatar Jul 05 '24 10:07 lukasIO

no, adaptation is required to used sample in nwjs env.

zesun96 avatar Jul 05 '24 10:07 zesun96

I see. I'm not very familiar with NW.js, but then probably this should be reported to NW.js as a bug as it seems to be not emitting the unmute event on the track when a window is restored.

lukasIO avatar Jul 05 '24 10:07 lukasIO

I only use nwjs run webrtc sample, the unmute event is emitted.

zesun96 avatar Jul 05 '24 10:07 zesun96

I see. I'm not very familiar with NW.js, but then probably this should be reported to NW.js as a bug as it seems to be not emitting the unmute event on the track when a window is restored. @lukasIO I thought the unmute event is emitted by webrtc, isn't it?

aimin-git avatar Jul 06 '24 01:07 aimin-git

I'm guessing NW.js needs to wrap get display media APIs, similar to how electron has to. That could potentially explain why it works as expected in Chrome, but doesn't in NW.js.

lukasIO avatar Jul 08 '24 07:07 lukasIO