Search Support

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

High CPU when trying to get my camera with getusermedia

  • 16 replies
  • 8 have this problem
  • 25 views
  • Last reply by joydragon

more options

I'm trying to develop an application that uses the camera and microphone, and it all works well on different browsers that I've tested, but when I get to Firefox on Linux I get this weird problem that it makes Firefox CPU usage to soar to around 100% (between 96% and 103%) and it'll never actually displays the classic popup with the confirmation to share camera and mic. Do you have this issue contemplated? I've tested this application on Chrome on Windows and on Linux and no problem, also I've tested on the Windows Firefox (23) and it has no issues, it's only on the Linux version (23 also) that I'm currently having this issue. And it is not only on my "probably poorly constructed app" that I'm getting this issue, if I go and test on either www.simpl.info/gum or iambrandonn.github.com/WebcamSwiper I get the same behaviour This is my system info just in case OS: Gentoo Linux Firefox: www-client/firefox-bin-23.0 Extra add-ons: NoScript and Firebug Tried with cleaning up and starting with a fresh version of Firefox? Yes

Let me know if I can give any more info on this. Thanks!

I'm trying to develop an application that uses the camera and microphone, and it all works well on different browsers that I've tested, but when I get to Firefox on Linux I get this weird problem that it makes Firefox CPU usage to soar to around 100% (between 96% and 103%) and it'll never actually displays the classic popup with the confirmation to share camera and mic. Do you have this issue contemplated? I've tested this application on Chrome on Windows and on Linux and no problem, also I've tested on the Windows Firefox (23) and it has no issues, it's only on the Linux version (23 also) that I'm currently having this issue. And it is not only on my "probably poorly constructed app" that I'm getting this issue, if I go and test on either www.simpl.info/gum or iambrandonn.github.com/WebcamSwiper I get the same behaviour This is my system info just in case OS: Gentoo Linux Firefox: www-client/firefox-bin-23.0 Extra add-ons: NoScript and Firebug Tried with cleaning up and starting with a fresh version of Firefox? Yes Let me know if I can give any more info on this. Thanks!

Chosen solution

I experiencing same problem here.

I have found an old bug in alsa-lib project that had been updated recently.

https://bugs.launchpad.net/ubuntu/+source/alsa-lib/+bug/1008600

It is related to snd_device_name_hint and probably to this topic. Also there is a commit in alsa-lib repo that points to that bug.

commit 23bf1dce9438c0cf74357928289aa8f06957c283 Author: David Henningsson <david.henningsson@canonical.com> Date: Fri Sep 13 13:21:44 2013 -0400

   Fix access of freed memory in namehints
   
   Sometimes a hook manipulates the config tree, which makes currently
   running iterators point to freed memory. As a workaround, make two
   copies, one for the iterators and another for the hooks.
   
   BugLink: https://bugs.launchpad.net/bugs/1008600
   Signed-off-by: David Henningsson <david.henningsson@canonical.com>
   Signed-off-by: Takashi Iwai <tiwai@suse.de>

I'm trying to get a patch working on my system to know if these solves the firefox crash.

BTW Im using gentoo 3.10.0-rc2+ and pulseaudio-2.1-r1

Read this answer in context 👍 1

All Replies (16)

more options

Not sure what your problem may be. I tried using Ubuntu 12.04 on Firefox Canonical 24. With Noscript and Firebug installed and enabled. I stayed under 100% CPU with four windows open in Fifefox. Multi tab browsing, 2x the www.simpl.info/gum & 1x http://iambrandonn.github.com/WebcamSwiper. The camera worked, the picture dispalyed and the page swiping worked.

Having said it works-for-me no script is quite likely to block scripts and cause hangs and Firebug is something I only enable when it is actually needed.

As you have written an app are you able to produce some simple reduced testcase that demonstrates the problem ? If so you could then consider discussing in AMO prior to filing a bug

You may also wish to checkout Gentoo support in case the issue relates to the OS or to the distro build of Firefox.

more options

It's weird that you can simply get to that page. I just tried to get to http://www.simpl.info/gum on a fresh and new version of the Mozilla build. I removed the binary build for Gentoo (and I'm guessing is the same thing because it's not compiling the source, but just in case) from my system, removed my profile folder, then I downloaded the build from the site and the first thing that I did is to put that link on the browser and it crashed. I submitted the crash to Mozilla, but it's still weird.

more options

If you have submitted crash reports then please post the IDs of one or more recent crash reports that have a "bp-" prefix:

  • bp-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

You can find the IDs of the submitted crash reports on the about:crashes page.

  • You can open the about:crashes page via the location bar, like you open a website, or open the crash reports page via "Help > Troubleshooting Information".

See:

more options

Yeah sorry, I forgot, this is the id of the crash: bp-6c7e4e92-93f2-4aca-a809-eb59c2130812

https://crash-stats.mozilla.com/report/index/bp-6c7e4e92-93f2-4aca-a809-eb59c2130812

Thanks!

more options

Sorry, No idea, so if no one else answers by next week bump the question or pm me.

more options

I think the current version of libc-bin is 2.17, can you try updating that?

more options

I've updated to 2.17 and it still crashed, now the crash is this: bp-0ed40596-521c-4f65-b9c3-13c262130814 https://crash-stats.mozilla.com/report/index/bp-0ed40596-521c-4f65-b9c3-13c262130814 Can you give me any more pointers on how to solve this?

Thanks

more options

Sorry no ideas at present I will leave it to others.

I did earlier ask if you trying Gentoo support may help,as it is only crashing on that particular OS. Presumably the libc-bin used is 32bit to match your OS and Firefox, I also note Gentoo returns a lot of search results for glibc.


For forum cross referencing purposes

  1. Report for Crash ID bp-6c7e4e92-93f2-4aca-a809-eb59c2130812
  2. Report for Crash ID bp-0ed40596-521c-4f65-b9c3-13c262130814
more options

This looks like a problem with ALSA (libasound.so.2.0.0)

Here is a bug where this library is involved:

  • Bug 833161 - Firefox crashes upon receiving Facebook messages in the background.
more options

Hi,

Thanks for answering with the alsa stuff, I tried the workaround mentioned on that bug but still nothing, i've updated all the libraries that I can find related to alsa and still no clues. I have another crash with the new Firefox 23.0.1 and my "updated system", just in case bp-c9b53456-7c44-48cf-bbb4-9a2bf2130819 But still I find it very weird

https://crash-stats.mozilla.com/report/index/c9b53456-7c44-48cf-bbb4-9a2bf2130819

Thanks.

more options

Sorry I have not got any ideas. The new Crash IDs link to reports with the crash signature we have already seen.

more options

Hi,

I just got back to the issue and I think I found a lead to the problem. As cor-el was saying I guess there's some issues with libasound, and there's the comment on the actual code

http://mxr.mozilla.org/mozilla-release/source/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc#1844

There it says that you shouldn't use -1 because of an access violation and it's still there. If I change that to 0 it gets my camera without any issues and goes through. Is that the problem?

Cheers!

more options

Nope, that was not a solution, the check for the -1 is inside and it's all right. If I change that only makes it that somehow the audio is not being recognized (it skips the initial and only sound device) and on the simpl.info page only uses the video, so that works. The problem is in the call on the line 1847 though: http://mxr.mozilla.org/mozilla-release/source/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc#1847 I've been trying to test that with gdb and here's the bt before the call when the problem arises:

Breakpoint 1, webrtc::AudioDeviceLinuxALSA::GetDevicesInfo (this=0x9ac02e70, function=0, playback=false, enumDeviceNo=0, enumDeviceName=0x0, ednLen=0, enumDeviceId=0x0, 
    ediLen=0) at /src/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc:1861
1861            err = LATE(snd_device_name_hint)(card, "pcm", &hints);
(gdb) bt
#0  webrtc::AudioDeviceLinuxALSA::GetDevicesInfo (this=0x9ac02e70, function=0, playback=false, enumDeviceNo=0, enumDeviceName=0x0, ednLen=0, enumDeviceId=0x0, ediLen=0)
    at /src/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc:1861
#1  0xb3cb6fa4 in webrtc::AudioDeviceLinuxALSA::SetRecordingDevice (this=0x9ac02e70, index=0)
    at /src/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc:1007
#2  0xb3cb3d4b in webrtc::AudioDeviceModuleImpl::SetRecordingDevice (this=0xa5664000, index=0)
    at /src/media/webrtc/trunk/webrtc/modules/audio_device/audio_device_impl.cc:1581
#3  0xb3c3b28e in webrtc::VoEBaseImpl::Init (this=0x9af2d13c, external_adm=0x0, audioproc=0x0) at /src/media/webrtc/trunk/webrtc/voice_engine/voe_base_impl.cc:443
#4  0xb1ff86fe in mozilla::MediaEngineWebRTC::EnumerateAudioDevices (this=0x9adb6be0, aASources=0x99aff108) at /src/content/media/webrtc/MediaEngineWebRTC.cpp:268
#5  0xb227e244 in mozilla::GetSources<mozilla::MediaEngineAudioSource> (engine=0x9adb6be0, aConstraints=..., 
    aEnumerate=&virtual mozilla::MediaEngine::EnumerateAudioDevices(nsTArray<nsRefPtr<mozilla::MediaEngineAudioSource> >*)) at /src/dom/media/MediaManager.cpp:677
#6  0xb22822e2 in mozilla::GetUserMediaDevicesRunnable::Run (this=0x9adb6b20) at /src/dom/media/MediaManager.cpp:1027
#7  0xb36ccb34 in nsThread::ProcessNextEvent (this=0xa4ced390, mayWait=true, result=0x99aff2cf) at /src/xpcom/threads/nsThread.cpp:622
#8  0xb3652e0a in NS_ProcessNextEvent (thread=0xa4ced390, mayWait=true) at /src/xpcom/glue/nsThreadUtils.cpp:238
#9  0xb36cbacb in nsThread::ThreadFunc (arg=0xa4ced390) at /src/xpcom/threads/nsThread.cpp:250
#10 0xb7b7ce19 in _pt_root (arg=0x9b08b140) at /src/nsprpub/pr/src/pthreads/ptthread.c:204
#11 0xb7fa2e15 in start_thread () from /lib/libpthread.so.0
#12 0xb7d8fa7e in clone () from /lib/libc.so.6


And sometimes I get a segfault that has the following bt: 
Program received signal SIGSEGV, Segmentation fault.
0xb7ce620d in vfprintf () from /lib/libc.so.6
(gdb) bt
#0  0xb7ce620d in vfprintf () from /lib/libc.so.6
#1  0xb7da38ec in __vsprintf_chk () from /lib/libc.so.6
#2  0xb7da37ff in __sprintf_chk () from /lib/libc.so.6
#3  0xb0c63227 in ?? () from /usr/lib/libasound.so.2
#4  0xb0c64017 in ?? () from /usr/lib/libasound.so.2
#5  0xb0c644f7 in snd_device_name_hint () from /usr/lib/libasound.so.2
#6  0xb3cb8d38 in webrtc::AudioDeviceLinuxALSA::GetDevicesInfo (this=0x9ac02e70, function=0, playback=false, enumDeviceNo=0, enumDeviceName=0x0, ednLen=0, 
    enumDeviceId=0x0, ediLen=0) at /src/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc:1861
#7  0xb3cb6fa4 in webrtc::AudioDeviceLinuxALSA::SetRecordingDevice (this=0x9ac02e70, index=0)
    at /src/media/webrtc/trunk/webrtc/modules/audio_device/linux/audio_device_alsa_linux.cc:1007
#8  0xb3cb3d4b in webrtc::AudioDeviceModuleImpl::SetRecordingDevice (this=0xa5664000, index=0)
    at /src/media/webrtc/trunk/webrtc/modules/audio_device/audio_device_impl.cc:1581
#9  0xb3c3b28e in webrtc::VoEBaseImpl::Init (this=0x9af2d13c, external_adm=0x0, audioproc=0x0) at /src/media/webrtc/trunk/webrtc/voice_engine/voe_base_impl.cc:443
#10 0xb1ff86fe in mozilla::MediaEngineWebRTC::EnumerateAudioDevices (this=0x9adb6be0, aASources=0x99aff108) at /src/content/media/webrtc/MediaEngineWebRTC.cpp:268
#11 0xb227e244 in mozilla::GetSources<mozilla::MediaEngineAudioSource> (engine=0x9adb6be0, aConstraints=..., 
    aEnumerate=&virtual mozilla::MediaEngine::EnumerateAudioDevices(nsTArray<nsRefPtr<mozilla::MediaEngineAudioSource> >*)) at /src/dom/media/MediaManager.cpp:677
#12 0xb22822e2 in mozilla::GetUserMediaDevicesRunnable::Run (this=0x9adb6b20) at /src/dom/media/MediaManager.cpp:1027
#13 0xb36ccb34 in nsThread::ProcessNextEvent (this=0xa4ced390, mayWait=true, result=0x99aff2cf) at /src/xpcom/threads/nsThread.cpp:622
#14 0xb3652e0a in NS_ProcessNextEvent (thread=0xa4ced390, mayWait=true) at /src/xpcom/glue/nsThreadUtils.cpp:238
#15 0xb36cbacb in nsThread::ThreadFunc (arg=0xa4ced390) at /src/xpcom/threads/nsThread.cpp:250
#16 0xb7b7ce19 in _pt_root (arg=0x9b08b140) at /src/nsprpub/pr/src/pthreads/ptthread.c:204
#17 0xb7fa2e15 in start_thread () from /lib/libpthread.so.0
#18 0xb7d8fa7e in clone () from /lib/libc.so.6

So it's definetly at the "snd_device_name_hint" method, but I have no idea how that libasound works and I guess I'm getting way too deep in something that I don't know anything about. Can you guys help me? Or do you know where can I get some help?

Cheers!

Modified by cor-el

more options

Chosen Solution

I experiencing same problem here.

I have found an old bug in alsa-lib project that had been updated recently.

https://bugs.launchpad.net/ubuntu/+source/alsa-lib/+bug/1008600

It is related to snd_device_name_hint and probably to this topic. Also there is a commit in alsa-lib repo that points to that bug.

commit 23bf1dce9438c0cf74357928289aa8f06957c283 Author: David Henningsson <david.henningsson@canonical.com> Date: Fri Sep 13 13:21:44 2013 -0400

   Fix access of freed memory in namehints
   
   Sometimes a hook manipulates the config tree, which makes currently
   running iterators point to freed memory. As a workaround, make two
   copies, one for the iterators and another for the hooks.
   
   BugLink: https://bugs.launchpad.net/bugs/1008600
   Signed-off-by: David Henningsson <david.henningsson@canonical.com>
   Signed-off-by: Takashi Iwai <tiwai@suse.de>

I'm trying to get a patch working on my system to know if these solves the firefox crash.

BTW Im using gentoo 3.10.0-rc2+ and pulseaudio-2.1-r1

Modified by nanocity

more options

Quick follow up.

I have just apply a patch with that commit on pulseaudio, and now firefox nightly seems to work. Firefox 23.0 complains about AudioContext functions though.

Also, neither Nightly nor Firefox 23.0 work if I have WebRTC already running in a Chromium browser but I think that is not related to this topic. Alsa log is following:

ALSA lib pcm.c:7889:(snd_pcm_set_params) Broken configuration for CAPTURE: no configurations available ALSA lib pcm.c:7913:(snd_pcm_set_params) Channels count (1) not available for CAPTURE: Argumento inválido ALSA lib pcm.c:7913:(snd_pcm_set_params) Channels count (1) not available for CAPTURE: Argumento inválido ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave ALSA lib pcm_dsnoop.c:618:(snd_pcm_dsnoop_open) unable to open slave

And repeat last lines over and over.

more options

Excellent !! Sorry to get back to you so late but, yep that solved the problem completely. Thanks a lot.