aws / amazon-chime-sdk-js

A JavaScript client library for integrating multi-party communications powered by the Amazon Chime service.
Apache License 2.0
701 stars 473 forks source link

High CPU in Firefox #1960

Open timanderson opened 2 years ago

timanderson commented 2 years ago

Video meeting in Firefox with 4 users. Noticed fan roaring away. Task Manager showed high CPU in Firefox and GPU active. This is on a high-spec PC, Windows 11. Is this noise suppression kicking in, it is not configured as far as I know? Any way to monitor/tune this?

jing-chen1 commented 2 years ago

Hi @timanderson,

Thanks for your interest in Amazon Chime SDK for JavaScript. Could you please provide more details about your use case?

It would be great if you can complete the issue template form, so we can help you as much as we can.

timanderson commented 2 years ago

Thanks for your comment. Unfortunately I don't know if this occurs in other browsers and I don't have logs. I can tell you that if I run it now with only me in the meeting, I don't see the same level of CPU/GPU. So it is related to the number of people in the meeting. It is not the serverless demo, this is the singlejs demo plus our custom code. The video elements are quite small, just 200px wide. The code is fairly minimal.

jing-chen1 commented 2 years ago

Thanks for your response. Just want to make sure the 4 users come from different devices or just one device? My mac will have 200% CPU usage when I create 6 attendees, join in a meeting and turn on the video. Also would like to know what is your custom code. Would be appreciated it if you can provide some logs.

timanderson commented 2 years ago

The 4 users are from different devices. The PC is Core i7-7700 3.6 GHz, 16GB RAM and Nvidia RTX 2060 GPU. This is what I get:

image

If that is normal for 4 attendees then I have learned something! But I think I had four attendees with an earlier version of Chime SDK that did not show this level of CPU usage. The video elements are small about 200 x 200px.

What logs would be useful? This is not an error condition.

jing-chen1 commented 2 years ago

Please correct me if I am wrong. The 4 users are from different devices, and they all join the meeting through Firefox. One of the user(let's say A) with a high-spec PC experience high CPU usage during the meeting.

I suspected it related with video encode/decode since in most video conferencing software make the encoding/decoding video happens on CPU. You may want to ensure your users have hardware acceleration turned on and also consider profiling your app with the Chrome performance dev tools to see what part is taking up the majority of processing.

If you could provide some profiling results on how your app works, we may be able to offer some suggestions.

timanderson commented 2 years ago

Thanks. All 4 users turn on video but there is no other content sharing or other features like Voice Focus.

I will look at the Chrome performance tools though note this is on Firefox.

Tim

nainkunal933 commented 2 years ago

@timanderson Sorry for not replying back to you earlier. I did a little bit of local testing with 6 attendees in the meeting. I am using the serverless demo that @jing-chen1 mentioned in an earlier comment.

If I understand correctly your meeting looks similar to the following screenshot: Screen Shot 2022-05-06 at 3 51 47 PM

With those attendees, my CPU usage was 110 - 130% on a MacBook Pro. Please note that MacOs activity monitor works a little different than the Windows task manager. In MacBook the CPU usage is not cumulative. So, 110% means that Chrome as an application is using a bit more than 1 core on my 6 core machine. This is not bad performance with that many attendees. I have other tabs open on Chrome as well.

My MacBook has the following spec: Processor: 2.6 GHz 6-Core Intel Core i7 Memory: 16 GB DDR4 Graphics: AMD Radeon Pro 4 GB

Usage: Screen Shot 2022-05-06 at 4 02 55 PM

So, I will say that the CPU usage that you are getting is high for just 6 attendees. I will recommend trying out the serverless demo and gathering the data points for that on your machine: https://github.com/aws/amazon-chime-sdk-js/tree/main/demos/serverless. If there is a difference between serverless demo and your application then you will need to debug your application for high usage.

Please let me know if you have any other questions!!

nainkunal933 commented 2 years ago

@timanderson Sorry missed one thing in my previous comment. You are using Firefox and not Chrome. Sorry I used Chrome by habit. Following is the screenshot of usage on Firefox. You are correct Firefox is using a lot of CPU. It is spawning a bunch of FireFox CP Web Content processes. Screen Shot 2022-05-06 at 4 41 38 PM

My recommendation would be to try Chrome if you run into the same issue.

timanderson commented 2 years ago

Hi

Many thanks for looking into this, it is much appreciated.

It is not all that helpful though to suggest trying Chrome since our users have their own browser preferences and we do not want to tell them to use a different browser than the one they like. Do you have any ideas why this is happening in Firefox and not Chrome?

Tim

nainkunal933 commented 2 years ago

Hey @timanderson,

Currently, I do not know the reason for the high CPU consumption. I will log this as a bug and will track it in the backlog. After doing some research should be able to get back to you on the root cause of the high CPU consumption in Firefox.

achronop commented 2 years ago

Can you use Firefox profiler [1] to capture the CPU load and check the potential bottle neck? It is very simple and easy to use. Better to use "Media" in the settings. If you want to post the profile here upload it first (it is an option in the profiler) in order to create a permanent link. If you decide to share the profile be aware that you might share some custom code so double check if you want that. You can always use a private channel to share the profile with Chime's engineers.

[1] https://profiler.firefox.com/

PaulGobin commented 11 months ago

Hello, I understand this is an old issue, however, we are seeing the same CPU and Power Usage shot up to "Very High" when we turn on screen sharing, when we stop screen share, the CPU, GPU and Power Usage goes back down to normal.

Any suggestions on what "tweaks" we can do to resolve this would be much appreciated.