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 2021-03-20 22:57:21.194862000 +0100 +++ dom/media/AudioStream.cpp 2021-03-20 23:00:50.527112000 +0100 @@ -26,7 +26,6 @@ #endif #include "Tracing.h" #include "webaudio/blink/DenormalDisabler.h" -#include "AudioThreadRegistry.h" // Use abort() instead of exception in SoundTouch. #define ST_NO_EXCEPTION_HANDLING 1 @@ -139,9 +138,7 @@ mTimeStretcher(nullptr), mState(INITIALIZED), mDataSource(aSource), - mPrefillQuirk(false), - mAudioThreadId(0), - mSandboxed(CubebUtils::SandboxEnabled()) {} + mPrefillQuirk(false) {} AudioStream::~AudioStream() { LOG("deleted, state %d", mState); @@ -565,21 +562,7 @@ aWriter.Available()); } -bool AudioStream::CheckThreadIdChanged() { -#ifdef MOZ_GECKO_PROFILER - auto id = profiler_current_thread_id(); - if (id != mAudioThreadId) { - mAudioThreadId = id; - return true; - } -#endif - return false; -} - long AudioStream::DataCallback(void* aBuffer, long aFrames) { - if (!mSandboxed && CheckThreadIdChanged()) { - CubebUtils::GetAudioThreadRegistry()->Register(mAudioThreadId); - } WebCore::DenormalDisabler disabler; TRACE_AUDIO_CALLBACK_BUDGET(aFrames, mAudioClock.GetInputRate()); @@ -635,9 +618,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 2021-03-20 23:01:10.169773000 +0100 +++ dom/media/AudioStream.h 2021-03-20 23:01:56.622691000 +0100 @@ -294,7 +294,6 @@ template int InvokeCubeb(Function aFunction, Args&&... aArgs); - bool CheckThreadIdChanged(); // The monitor is held to protect all access to member variables. Monitor mMonitor; @@ -328,9 +327,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; Atomic mPlaybackComplete;