Revert bug 1647717 to workaround the issue of occational tab crashing when using any cubeb backends other than pulse-rust to play media. The loss of such change will be that users will not be able to do profiling on threads created by libcubeb. --- dom/media/AudioStream.cpp.orig 2022-02-25 16:27:47.676236000 +0100 +++ dom/media/AudioStream.cpp 2022-02-25 16:54:21.223904000 +0100 @@ -27,7 +27,6 @@ #endif #include "Tracing.h" #include "webaudio/blink/DenormalDisabler.h" -#include "AudioThreadRegistry.h" #include "mozilla/StaticPrefs_media.h" // Use abort() instead of exception in SoundTouch. @@ -144,8 +143,6 @@ mAudioClock(aInRate), mState(INITIALIZED), mDataSource(aSource), - mAudioThreadId(ProfilerThreadId{}), - mSandboxed(CubebUtils::SandboxEnabled()), mPlaybackComplete(false), mPlaybackRate(1.0f), mPreservesPitch(true) {} @@ -551,17 +548,6 @@ aWriter.Available()); } -bool AudioStream::CheckThreadIdChanged() { - ProfilerThreadId id = profiler_current_thread_id(); - if (id != mAudioThreadId) { - mAudioThreadId = id; - mAudioThreadChanged = true; - return true; - } - mAudioThreadChanged = false; - return false; -} - void AudioStream::AssertIsOnAudioThread() const { // This can be called right after CheckThreadIdChanged, because the audio // thread can change when not sandboxed. @@ -590,9 +576,6 @@ } long AudioStream::DataCallback(void* aBuffer, long aFrames) { - if (CheckThreadIdChanged() && !mSandboxed) { - CubebUtils::GetAudioThreadRegistry()->Register(mAudioThreadId); - } WebCore::DenormalDisabler disabler; TRACE_AUDIO_CALLBACK_BUDGET(aFrames, mAudioClock.GetInputRate()); @@ -647,9 +630,6 @@ mDumpFile.Write(static_cast(aBuffer), aFrames * mOutChannels); - if (!mSandboxed && writer.Available() != 0) { - CubebUtils::GetAudioThreadRegistry()->Unregister(mAudioThreadId); - } return aFrames - writer.Available(); } --- dom/media/AudioStream.h.orig 2022-02-25 16:27:53.316210000 +0100 +++ dom/media/AudioStream.h 2022-02-25 16:55:18.967535000 +0100 @@ -323,7 +323,6 @@ template int InvokeCubeb(Function aFunction, Args&&... aArgs); - bool CheckThreadIdChanged(); void AssertIsOnAudioThread() const; soundtouch::SoundTouch* mTimeStretcher; @@ -357,9 +356,6 @@ // the default device is used. It is set // during the Init() in decoder thread. RefPtr mSinkInfo; - // Contains the id of the audio thread, from profiler_get_thread_id. - std::atomic mAudioThreadId; - const bool mSandboxed = false; MozPromiseHolder mEndedPromise; std::atomic mPlaybackComplete;