Assertion failed: (stream_params->channels >= mixer_params->channels && mixer_params->channels > 0), function cubeb_downmix

RESOLVED FIXED

Status

()

Core
Audio/Video: cubeb
P2
normal
Rank:
18
RESOLVED FIXED
9 months ago
a month ago

People

(Reporter: Alex_Gaynor, Assigned: achronop)

Tracking

({stale-bug})

Trunk
Unspecified
Mac OS X
stale-bug
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

9 months ago
I'm experiencing this with a locally compiled build on macOS, revision 07484bfdb96b. Filed against cubeb because the first assertion error message appears to be there

Steps to reproduce:

1) Browse to https://appear.in/
2) "Create new room"
3) Allow access to camera/microphone
4) Crash

This crashes reliably for me.

I'm experiencing a full browser crash, not just the content process -- so I suspect there's actually two bugs here. What follows are the stdout/stderr from my process. (Is there a way to use the crash reporter on a local dev build?)

2017-07-25 09:53:18.097 firefox[69438:1196695] IMKInputSession presentFunctionRowItemTextInputViewWithEndpoint:completionHandler: : [self textInputContext]=0x13021d160 *NO* NSRemoteViewController to client, NSError=Error Domain=NSCocoaErrorDomain Code=4097 "connection from pid 0" UserInfo={NSDebugDescription=connection from pid 0}, com.apple.inputmethod.EmojiFunctionRowItem
[Child 69443] WARNING: Cannot query channel count on a AudioSegment with no chunks.: '!mChunks.IsEmpty()', file /Users/agaynor/projects/mozilla-central/dom/media/AudioSegment.h, line 370
[Child 69443] WARNING: No audio tracks, but full-duplex audio is enabled!!!!!: file /Users/agaynor/projects/mozilla-central/dom/media/MediaStreamGraph.cpp, line 535
[Parent 69438] WARNING: NS_ENSURE_SUCCESS(rv, rv) failed with result 0x80070057: file /Users/agaynor/projects/mozilla-central/netwerk/base/nsChannelClassifier.cpp, line 316
Assertion failed: (stream_params->channels >= mixer_params->channels && mixer_params->channels > 0), function cubeb_downmix, file /Users/agaynor/projects/mozilla-central/media/libcubeb/src/cubeb_mixer.cpp, line 383.
[Parent 69438] WARNING: bad Shmem: file /Users/agaynor/projects/mozilla-central/ipc/glue/ProtocolUtils.cpp, line 527
[Parent 69438] WARNING: bad Shmem: file /Users/agaynor/projects/mozilla-central/ipc/glue/ProtocolUtils.cpp, line 527
[Parent 69438] WARNING: bad Shmem: file /Users/agaynor/projects/mozilla-central/ipc/glue/ProtocolUtils.cpp, line 527
Assertion failure: mDestroyed, at /Users/agaynor/projects/mozilla-central/gfx/layers/composite/ImageLayerComposite.cpp:44
#01: mozilla::layers::ImageLayerComposite::~ImageLayerComposite()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x107729e]
#02: mozilla::layers::ContainerLayerComposite::~ContainerLayerComposite()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x106d382]
#03: mozilla::layers::ContainerLayer::RemoveChild(mozilla::layers::Layer*)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xf62bbe]
#04: mozilla::layers::ContainerLayerComposite::~ContainerLayerComposite()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x106d33c]
#05: mozilla::layers::ContainerLayerProperties::~ContainerLayerProperties()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xf5b29e]
#06: nsTArray_Impl<mozilla::UniquePtr<mozilla::layers::LayerPropertiesBase, mozilla::DefaultDelete<mozilla::layers::LayerPropertiesBase> >, nsTArrayInfallibleAllocator>::RemoveElementsAt(unsigned long, unsigned long)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xf5ac25]
#07: mozilla::layers::ContainerLayerProperties::~ContainerLayerProperties()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xf5c0f3]
#08: mozilla::layers::ContainerLayerProperties::~ContainerLayerProperties()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xf5b29e]
#09: nsTArray_Impl<mozilla::UniquePtr<mozilla::layers::LayerPropertiesBase, mozilla::DefaultDelete<mozilla::layers::LayerPropertiesBase> >, nsTArrayInfallibleAllocator>::RemoveElementsAt(unsigned long, unsigned long)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xf5ac25]
#10: mozilla::layers::ContainerLayerProperties::~ContainerLayerProperties()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xf5c0f3]
#11: mozilla::layers::ContainerLayerProperties::~ContainerLayerProperties()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0xf5b29e]
#12: mozilla::layers::LayerManagerComposite::UpdateAndRender()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x107b363]
#13: mozilla::layers::LayerManagerComposite::EndTransaction(mozilla::TimeStamp const&, mozilla::layers::LayerManager::EndTransactionFlags)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x107af90]
#14: mozilla::layers::CompositorBridgeParent::CompositeToTarget(mozilla::gfx::DrawTarget*, mozilla::gfx::IntRectTyped<mozilla::gfx::UnknownUnits> const*)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x109d9b1]
#15: mozilla::layers::CompositorVsyncScheduler::Composite(mozilla::TimeStamp)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x10a61fe]
#16: mozilla::detail::RunnableMethodImpl<mozilla::layers::CompositorVsyncScheduler*, void (mozilla::layers::CompositorVsyncScheduler::*)(mozilla::TimeStamp), true, (mozilla::RunnableKind)1, mozilla::TimeStamp>::Run()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x10b731b]
#17: MessageLoop::RunTask(already_AddRefed<nsIRunnable>)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6ab72f]
#18: MessageLoop::DeferOrRunPendingTask(MessageLoop::PendingTask&&)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6abf93]
#19: MessageLoop::DoWork()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6ac30b]
#20: base::MessagePumpDefault::Run(base::MessagePump::Delegate*)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6ad166]
#21: MessageLoop::Run()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6ab333]
#22: base::Thread::ThreadMain()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6b7a7d]
#23: ThreadFunc(void*)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6b1f4a]
#24: _pthread_body[/usr/lib/system/libsystem_pthread.dylib +0x393b]
#25: _pthread_body[/usr/lib/system/libsystem_pthread.dylib +0x3887]
Hit MOZ_CRASH(Aborting on channel error.) at /Users/agaynor/projects/mozilla-central/ipc/glue/MessageChannel.cpp:2530
Hit MOZ_CRASH(Aborting on channel error.) at /Users/agaynor/projects/mozilla-central/ipc/glue/MessageChannel.cpp:2530
Crash Annotation GraphicsCriticalError: |[C0][GFX1-]: Receive IPC close with reason=AbnormalShutdown (t=19.1507) Crash Annotation GraphicsCriticalError: |[C0][GFX1-]: Receive IPC close with reason=AbnormalShutdown (t=17.4793) #01: mozilla::ipc::ProcessLink::OnChannelError()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6f9d4f]
#01: mozilla::ipc::ProcessLink::OnChannelError()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6f9d4f]
#02: event_process_active_single_queue[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6c8dd1]
#02: event_process_active_single_queue[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6c8dd1]
#03: event_base_loop[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6c606f]
#03: event_base_loop[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6c606f]
#04: base::MessagePumpLibevent::Run(base::MessagePump::Delegate*)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6ad9f5]
#04: base::MessagePumpLibevent::Run(base::MessagePump::Delegate*)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6ad9f5]
#05: MessageLoop::Run()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6ab333]
#05: MessageLoop::Run()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6ab333]
#06: base::Thread::ThreadMain()[/Users/agaynor/projects/mozilla-#06: base::Thread::ThreadMain()[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6b7a7d]
central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6b7a7d]
#07: ThreadFunc(void*)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6b1f4a]
#08: _pthread_body[/usr/lib/system/libsystem_pthread.dylib +0x393b]
#09: _pthread_body[/usr/lib/system/libsystem_pthread.dylib +0x3887]
Hit MOZ_CRASH(MachExceptionHandler: Failed to forward to the previous handler!) at /Users/agaynor/projects/mozilla-central/js/src/ds/MemoryProtectionExceptionHandler.cpp:642
#07: ThreadFunc(void*)[/Users/agaynor/projects/mozilla-central/obj-x86_64-apple-darwin16.7.0/dist/NightlyDebug.app/Contents/MacOS/XUL +0x6b1f4a]
#08: _pthread_body[/usr/lib/system/libsystem_pthread.dylib +0x393b]
#09: _pthread_body[/usr/lib/system/libsystem_pthread.dylib +0x3887]
Hit MOZ_CRASH(MachExceptionHandler: Failed to forward to the previous handler!) at /Users/agaynor/projects/mozilla-central/js/src/ds/MemoryProtectionExceptionHandler.cpp:642
Alex, what is your audio setup? Do you use a USB headset, or just earbuds? What version of osx is that?
Flags: needinfo?(agaynor)
(Reporter)

Comment 2

9 months ago
This is MacBook Pro, with an external monitor (which has a camera, maybe a microphone?), and also a standard pair of headphones.

This is macOS 10.12.6.
Flags: needinfo?(agaynor)
What device do you choose when you're allowing appear.in to use your microphone/camera ?

Updated

9 months ago
Flags: needinfo?(agaynor)
(Reporter)

Comment 4

9 months ago
    Camera: FaceTime HD Camera
    Microphone: default: Display Audio
Flags: needinfo?(agaynor)
(Assignee)

Comment 5

9 months ago
I am facing a similar issue with my debug build. The good point is that I have it only with one specific headset. In my case the internal device works well. What looks strange is the callstack though. I do not expect cubeb being called from the destructor of ImageLayerComposite.
This is not the internal device, this is a screen that has a microphone. We need to fix this quickly, having assert that blow up for legitimate use cases is not great.

Updated

9 months ago
Rank: 18
Priority: -- → P1
This is a P1 bug without an assignee. 

P1 are bugs which are being worked on for the current release cycle/iteration/sprint. 

If the bug is not assigned by Monday, 28 August, the bug's priority will be reset to '--'.
Keywords: stale-bug
Mass change P1->P2 to align with new Mozilla triage process
Priority: P1 → P2
(Reporter)

Comment 9

4 months ago
Paul, is there any chance someone from your team will have a chance to look at this? It's a real bummer when trying to test sandboxing changes which might impact AV :-)

FWIW, even simpler reproduction with: https://www.webrtc-experiment.com/RecordRTC/
Flags: needinfo?(padenot)
Alex, can you fix this? You said you can repro.
Flags: needinfo?(padenot)
(Assignee)

Comment 11

4 months ago
Yes I can take it.
Assignee: nobody → achronop
(Reporter)

Comment 12

4 months ago
Thanks much!
(Assignee)

Comment 13

4 months ago
The problem in that assert is the mixer_params->channels = 0 (mixer_params->layout = CUBEB_LAYOUT_UNDEFINED). We calculate the channels value from "global" layout here:
https://searchfox.org/mozilla-central/source/media/libcubeb/src/cubeb_audiounit.cpp#415
The "global" layout is set during stream_init (in audiounit_layout_init()) after setting the stream layout:
https://searchfox.org/mozilla-central/source/media/libcubeb/src/cubeb_audiounit.cpp#1408
The method above can return CUBEB_LAYOUT_UNDEFINED and that creates the error.
Worth to mention that the method returns different values for the same device between a debug/release builds or between stand alone cubeb app or firefox, for the same configuration.

IMO there is no point to try to mix when the mixer layout is CUBEB_LAYOUT_UNDEFINED. We need to take that into account during stream init and not to instantiate a mixer (and not attempt mixing during audio callback) when that's the case. In addition it would be nice to add mixer params in cubeb_stream struct and check them through out the call.

@chunmin since you implemented most of the mixer functionality can you tell me your thoughts?
Flags: needinfo?(cchang)
(Assignee)

Comment 14

3 months ago
In the meantime I pushed the implementation to a branch. Feel free to comment on that too.
https://github.com/kinetiknz/cubeb/pull/397
Replied in github.
Flags: needinfo?(cchang)
This will be fixed in bug 1432779
Status: NEW → RESOLVED
Last Resolved: a month ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.