firefox-devtools / profiler

Firefox Profiler — Web app for Firefox performance analysis
https://profiler.firefox.com
Mozilla Public License 2.0
1.14k stars 373 forks source link

Can't record audio workloads for a long time #4021

Open KnappSas opened 2 years ago

KnappSas commented 2 years ago

I'm using Firefox 99.0.1 .

Right now I have the problem that I can’t record profiles for a long time in Firefox (< 10s) anymore, when recording audio workload. It used to work better in the past (I think).

When I try, I get the following error when the FF Profiler opens:

Error: DataCloneError: JSWindowActorParent.sendAsyncMessage: JSWindowActorParent serialization error: data too large, in actor 'WebChannel'

In his blog post Profiling real-time audio workloads in Firefox padenot mentioned that his configuration of the FF Profiler allows to record for a very long time. I also tested with karplus-stress-tester (https://jackschaedler.github.io/karplus-stress-tester/) like he did, but it doesn't work for me anymore.

Repro: Open karplus-stress-teste Select a high number of strings like 600 Click start audio Click strum all Start recording in Performance tab Wait about 15 seconds Capture recording

-> FF Profiler opens and shows the error message.

I configured the Profiler like it is described in the last video of the blog post. The options that are new since then I tried enabled and disabled, but it didn't show an effect for me.

It would be interesting if anyone else runs into this problem.

┆Issue is synchronized with this Jira Task

padenot commented 2 years ago

Hi, thanks for the report. This is caused by a recent and useful change in the profiler, which is to record IPC message between the different process Firefox uses. It's not very useful for real-time audio workloads, so it can be desactivated without problem, allowing the recording of longer profiles.

If you choose the media preset, you can then click on Edit settings..., and untick the item IPC Messages like so:

Screenshot from 2022-04-29 14-22-43

It should then be possible to make longer recordings. Keep in mind that there is a lot of data in real-time audio profiles, so it will take a long time to process and display. It should eventually work though. For a 30s profile on this stress test page, it takes about 30 to 45 second to process before display on my MacBook Pro M1 Max, which is ridiculously powerful in the first place.

We're currently investigating how to make this better -- recording IPC message is really useful (but not so much for what you want to do here), but rather expensive. There must be a better way to do this.

julienw commented 2 years ago

@padenot should we remove recording IPC messages from the Media preset?

KnappSas commented 2 years ago

Thanks for your response @padenot I'm not sure if this is correct now... I had the IPC Messages box unticked already. The FF Profiler UX is a bit confusing, because I get the error message first after a very short time and shortly after it I get the message:

We were unable to connect to the browser within thirty seconds. This might be because the profile is big or your machine is slower than usual. Still waiting...

So I don't know if after some time, the profile will be successfully imported or not... I doubt it a little bit.

I have no M1 but my machine is still quite powerful (8-Core Intel MacBook Pro).

julienw commented 2 years ago

Thanks for your response @padenot I'm not sure if this is correct now... I had the IPC Messages box unticked already.

Interesting, thanks. I guess we need to look further. By chance, can you have a look whether you reproduce this with other versions of Firefox (especially Nightly) with IPC disabled?

The FF Profiler UX is a bit confusing, because I get the error message first after a very short time and shortly after it I get the message:

We were unable to connect to the browser within thirty seconds. This might be because the profile is big or your machine is slower than usual. Still waiting...

So I don't know if after some time, the profile will be successfully imported or not... I doubt it a little bit.

I doubt it also, this looks like racy code rather 🙈

KnappSas commented 2 years ago

I just tested with Nightly and I'm afraid it's the exact same behavior on my system. 😐

julienw commented 2 years ago

Thanks for trying at least. How long are you trying to profile here?

KnappSas commented 2 years ago

Depends on the load, but when I select 250 strings in the stress-tester (which has peak loads of 0.7 but most of the time around 0.3), 15 seconds seems to be the limit on my system. When I try to record for longer times I get the error again. Is there something else I can try?

These are my settings for the profiler, does anything look wrong?

Interval: 1 ms Threads: cubeb, audio, camera, capture, Compositor, GeckoMain, gmp, graph, grph, InotifyEventThread, IPDL Background, media, ModuleProcessThread, PacerThread, RemVidChild, RenderBackend, Renderer, Socket Thread, SwComposite, webrtc No Periodic Sampling CPU Utilization Audio Callback Tracing Process CPU Utilization

julienw commented 2 years ago

On my computer, strangely I get a different message:

[Exception... "Out of Memory" nsresult: "0x8007000e (NS_ERROR_OUT_OF_MEMORY)" location: "JS frame :: https://deploy-preview-4015--perf-html.netlify.app/039737426e05c900fb71.bundle.js :: ch :: line 162" data: no]

To avoid crashing you can try reducing the buffer size in about:memory. At least this could let you capture profiles, keeping only the most recent data.