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

fix: high CPU on Chrome with low fps screen sharing #1570

Merged
merged 3 commits into from
Apr 21, 2021

Conversation

paweldomas
Copy link
Member

It turns out that if 5 fps is set on the track constraints,
Chrome will capture the original video in 30 fps and only
further down the pipeline will downsample it to 5 fps.
This results in very high CPU usage. Specify max FPS in
getDisplayMedia to fix the problem.

Getting rid of track.applyConstraints should also fix another
issue on Firefox where it reports 0x0 screen size after this call.

It turns out that if 5 fps is set on the track constraints,
Chrome will capture the original video in 30 fps and only
further down the pipeline will downsample it to 5 fps.
This results in very high CPU usage. Specify max FPS in
getDisplayMedia to fix the problem.

Getting rid of track.applyConstraints should also fix another
issue on Firefox where it reports 0x0 screen size after this call.
@paweldomas paweldomas requested a review from jallamsetty1 April 21, 2021 15:05
Copy link
Member

@jallamsetty1 jallamsetty1 left a comment

Choose a reason for hiding this comment

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

LGTM! Good find about the gDM constraint vs track constraint.

@paweldomas paweldomas merged commit ada0f5e into master Apr 21, 2021
@paweldomas paweldomas deleted the fix-low-fps-screen-high-cpu branch April 21, 2021 18:36
@saghul
Copy link
Member

saghul commented Apr 21, 2021

Btw, I brought this up with Google and will be sending them some details, according to them this shouldn't happen, just when scaling fps.

@paweldomas
Copy link
Member Author

@saghul You know thinking about it the current state of things makes sense to me. When a MediaStream is created via getDisplayMedia there's tons of different ways on how it can be used. You can put it on a canvas, you can send it via different peerconnections at the same time etc. A behavior where the pipeline is optimized to select the lowest fps used by all components is more of an optimization rather than expectation. Even to show local preview of this screen you need to decide on the fps and the most intuitive would be the one passed to get display media.

@paweldomas
Copy link
Member Author

But then thinking about it some more, this was the constraint applied on a track which is the shared object here, so maybe it should be respected better.

@paweldomas
Copy link
Member Author

🤷‍♂️

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.

3 participants