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

"A MediaStreamTrack ended due to a capture failure" when selecting bluetooth headphones as audio input device #5855

Conversation

youennf
Copy link
Contributor

@youennf youennf commented Oct 27, 2022

b818b25

"A MediaStreamTrack ended due to a capture failure" when selecting bluetooth headphones as audio input device
https://bugs.webkit.org/show_bug.cgi?id=247119
rdar://problem/101628857

Reviewed by Eric Carlson.

Replace the boolean to update the sample buffer by a minimum buffer sample frames, which is set when render fails.
This minimum buffer sample frames is used to compute a minimum buffer size when setting up the audio unit.

Update Mock implementation to cover that case.
We do this by triggering this code path when triggerMockMicrophoneConfigurationChange is called.
We also update the capture verification timer so that timer for mock unit is reduced to 1 second.

Update LayoutTests/fast/mediastream/mediastreamtrack-configurationchange.html to cover that case.

* LayoutTests/fast/mediastream/mediastreamtrack-configurationchange.html:
* Source/WebCore/platform/mediastream/mac/CoreAudioSharedUnit.cpp:
(WebCore::CoreAudioSharedUnit::configureMicrophoneProc):
(WebCore::CoreAudioSharedUnit::processMicrophoneSamples):
(WebCore::CoreAudioSharedUnit::startInternal):
(WebCore::CoreAudioSharedUnit::isProducingMicrophoneSamplesChanged):
* Source/WebCore/platform/mediastream/mac/CoreAudioSharedUnit.h:
* Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.h:
* Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm:
(WebCore::MockAudioSharedUnit::singleton):
(WebCore::MockAudioSharedUnit::increaseBufferSize):
(WebCore::MockAudioSharedInternalUnit::emitSampleBuffers):
(WebCore::MockAudioSharedInternalUnit::render):
* Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp:
(WebCore::MockRealtimeMediaSourceCenter::triggerMockMicrophoneConfigurationChange):

Canonical link: https://commits.webkit.org/256091@main

0525aa9

Misc iOS, tvOS & watchOS macOS Linux Windows
βœ… πŸ§ͺ style βœ… πŸ›  ios βœ… πŸ›  mac βœ… πŸ›  wpe βœ… πŸ›  πŸ§ͺ win
βœ… πŸ§ͺ bindings βœ… πŸ›  ios-sim βœ… πŸ›  mac-debug βœ… πŸ›  gtk   πŸ›  wincairo
βœ… πŸ§ͺ webkitperl   πŸ§ͺ ios-wk2 βœ… πŸ›  mac-AS-debug   πŸ§ͺ gtk-wk2
βœ… πŸ§ͺ api-ios   πŸ§ͺ api-mac   πŸ§ͺ api-gtk
βœ… πŸ›  tv   πŸ§ͺ mac-wk1
βœ… πŸ›  tv-sim βœ… πŸ§ͺ mac-wk2
βœ… πŸ›  πŸ§ͺ merge βœ… πŸ›  watch   πŸ§ͺ mac-AS-debug-wk2
βœ… πŸ›  watch-sim βœ… πŸ§ͺ mac-wk2-stress

@youennf youennf self-assigned this Oct 27, 2022
@youennf youennf added the WebRTC For bugs in WebRTC label Oct 27, 2022
Copy link
Contributor

@eric-carlson eric-carlson left a comment

Choose a reason for hiding this comment

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

r=me

Comment on lines 178 to 180
http/wpt/webcodecs [ Skip ]
imported/w3c/web-platform-tests/webcodecs [ Skip ]

Copy link
Contributor

Choose a reason for hiding this comment

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

Did you mean to include this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope, will remove

Comment on lines +33 to +34
await new Promise(resolve => setTimeout(resolve, 2000));
assert_equals(track.readyState, "live");
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than always waiting for two seconds, when most of the time that is much too long and sometimes it will be too short, it might be better to poll the attribute and fail if it doesn't change after some longer time.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here, we need to wait for the verification timer to kick in, so we need to wait 1 second.
I put 2 seconds just in case.
After 2 seconds, if the track is still live, we have recovered properly.

@youennf youennf force-pushed the eng/A-MediaStreamTrack-ended-due-to-a-capture-failure-when-selecting-bluetooth-headphones-as-audio-input-device branch from 1cf874b to 76813f1 Compare October 27, 2022 17:33
@webkit-ews-buildbot webkit-ews-buildbot added the merging-blocked Applied to prevent a change from being merged label Oct 27, 2022
@youennf youennf force-pushed the eng/A-MediaStreamTrack-ended-due-to-a-capture-failure-when-selecting-bluetooth-headphones-as-audio-input-device branch from 76813f1 to 0525aa9 Compare October 28, 2022 08:30
@youennf youennf removed the merging-blocked Applied to prevent a change from being merged label Oct 28, 2022
@youennf youennf added the merge-queue Applied to send a pull request to merge-queue label Oct 28, 2022
…uetooth headphones as audio input device

https://bugs.webkit.org/show_bug.cgi?id=247119
rdar://problem/101628857

Reviewed by Eric Carlson.

Replace the boolean to update the sample buffer by a minimum buffer sample frames, which is set when render fails.
This minimum buffer sample frames is used to compute a minimum buffer size when setting up the audio unit.

Update Mock implementation to cover that case.
We do this by triggering this code path when triggerMockMicrophoneConfigurationChange is called.
We also update the capture verification timer so that timer for mock unit is reduced to 1 second.

Update LayoutTests/fast/mediastream/mediastreamtrack-configurationchange.html to cover that case.

* LayoutTests/fast/mediastream/mediastreamtrack-configurationchange.html:
* Source/WebCore/platform/mediastream/mac/CoreAudioSharedUnit.cpp:
(WebCore::CoreAudioSharedUnit::configureMicrophoneProc):
(WebCore::CoreAudioSharedUnit::processMicrophoneSamples):
(WebCore::CoreAudioSharedUnit::startInternal):
(WebCore::CoreAudioSharedUnit::isProducingMicrophoneSamplesChanged):
* Source/WebCore/platform/mediastream/mac/CoreAudioSharedUnit.h:
* Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.h:
* Source/WebCore/platform/mediastream/mac/MockAudioSharedUnit.mm:
(WebCore::MockAudioSharedUnit::singleton):
(WebCore::MockAudioSharedUnit::increaseBufferSize):
(WebCore::MockAudioSharedInternalUnit::emitSampleBuffers):
(WebCore::MockAudioSharedInternalUnit::render):
* Source/WebCore/platform/mock/MockRealtimeMediaSourceCenter.cpp:
(WebCore::MockRealtimeMediaSourceCenter::triggerMockMicrophoneConfigurationChange):

Canonical link: https://commits.webkit.org/256091@main
@webkit-early-warning-system webkit-early-warning-system force-pushed the eng/A-MediaStreamTrack-ended-due-to-a-capture-failure-when-selecting-bluetooth-headphones-as-audio-input-device branch from 0525aa9 to b818b25 Compare October 28, 2022 09:49
@webkit-commit-queue
Copy link
Collaborator

Committed 256091@main (b818b25): https://commits.webkit.org/256091@main

Reviewed commits have been landed. Closing PR #5855 and removing active labels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WebRTC For bugs in WebRTC
Projects
None yet
5 participants