Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block background throttling of video processing #2747

Merged
merged 5 commits into from
Nov 2, 2023
Merged

Conversation

hunnorth
Copy link
Contributor

@hunnorth hunnorth commented Sep 5, 2023

Description of changes:
Frames per second of video stream was being processed on the main thread using setTimeout. However, when a meeting window gets moved into the background, the main thread timer used in setTimeout gets throttled and the fps drops dramatically. To overcome this issue, this PR will move the setTimeout call into a worker thread that does not get throttled.

Testing:

Can these tested using a demo application? Please provide reproducible step-by-step instructions.
Yes, start a meeting with at least one other attendee. Enable a video filtered and then hide the window (switch tabs). The other attendee should then observe no fps degradation in filter-enabled attendee.

Checklist:

  1. Have you successfully run npm run build:release locally?
    yes

  2. Do you add, modify, or delete public API definitions? If yes, has that been reviewed and approved?
    no

  3. Do you change the wire protocol, e.g. the request method? If yes, has that been reviewed and approved?
    no

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@hunnorth hunnorth requested a review from a team as a code owner September 5, 2023 23:36
@kenpp
Copy link

kenpp commented Oct 23, 2023

Thank you for the development work. We have also encountered a similar issue in our service, as described by hunnorth.

Furthermore, we have verified that the problem is resolved when launching the demo application on the "video-ml/release" branch.

Could you please provide an estimate for when this release is expected? We would greatly appreciate it if you could release it as soon as possible.

this.pipe = new DefaultVideoFrameProcessorPipeline(
this.logger,
this.processors,
new DefaultVideoFrameProcessorTimer()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This explicit passing is not needed as you create one by default when instantiating.

}
}

destroy(): void {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary but the assigned callback could also be set back to undefined.

/**
* [[VideoFrameProcessorTimer]] defines a timer used in the context of video frame processing.
*/
export default interface VideoFrameProcessorTimer {
Copy link
Contributor

@devalevenkatesh devalevenkatesh Oct 31, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Should we make start and destroy promise based? We can make this interface destroyable by extending existing Destroyable interface:

destroy(): Promise<void>;

If any async processing goes in them in future, the consuming code will not be able to use await on them and thus async programming may become harder.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, will change! I wish js had a better way of transitioning from sync -> async APIs in a backwards compatible way.

ltrung
ltrung previously approved these changes Oct 31, 2023
@hensmi-amazon
Copy link
Contributor

hensmi-amazon commented Nov 1, 2023

@kenpp unfortunately even after this is merged it may be until December until we do another release. On a related note, I and others are no longer able to reproduce the original issue, but not sure why. Is it still reproducible on your machine? Turns out tab throttling is selectively enabled. With current version of chrome it will not start throttling if audio playback (i.e. speakers) are enabled.

@hensmi-amazon hensmi-amazon merged commit 9c54b6f into main Nov 2, 2023
10 checks passed
@hensmi-amazon hensmi-amazon deleted the video-ml/release branch November 2, 2023 22:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants