зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1804061 - Move and improve the fix for bug 1456101. r=webrtc-reviewers,ng
This patch moves the bits that need to run on main thread to avoid the deadlock in bug 1456101 closer to where the deadlock would happen, effectively shortening them. It also applies the same strategy to a few more call to the same function, that happen elsewhere, and therefore should also be prone to deadlocking. Differential Revision: https://phabricator.services.mozilla.com/D166059
This commit is contained in:
Родитель
c2384cde43
Коммит
81b02b3d13
|
@ -70,30 +70,10 @@ int32_t VideoEngine::CreateVideoCapture(const char* deviceUniqueIdUTF8) {
|
|||
}
|
||||
} else {
|
||||
#ifndef WEBRTC_ANDROID
|
||||
# ifdef MOZ_X11
|
||||
webrtc::VideoCaptureModule* captureModule;
|
||||
auto type = mCaptureDevInfo.type;
|
||||
nsresult result = NS_DispatchToMainThread(
|
||||
media::NewRunnableFrom([&captureModule, id, deviceUniqueIdUTF8,
|
||||
type]() -> nsresult {
|
||||
captureModule =
|
||||
webrtc::DesktopCaptureImpl::Create(id, deviceUniqueIdUTF8, type);
|
||||
return NS_OK;
|
||||
}),
|
||||
nsIEventTarget::DISPATCH_SYNC);
|
||||
|
||||
if (result == NS_OK) {
|
||||
entry = CaptureEntry(
|
||||
id, rtc::scoped_refptr<webrtc::VideoCaptureModule>(captureModule));
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
# else
|
||||
entry = CaptureEntry(
|
||||
id, rtc::scoped_refptr<webrtc::VideoCaptureModule>(
|
||||
webrtc::DesktopCaptureImpl::Create(id, deviceUniqueIdUTF8,
|
||||
mCaptureDevInfo.type)));
|
||||
# endif
|
||||
#else
|
||||
MOZ_ASSERT("CreateVideoCapture NO DESKTOP CAPTURE IMPL ON ANDROID" ==
|
||||
nullptr);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include "modules/video_capture/video_capture.h"
|
||||
#include "mozilla/Maybe.h"
|
||||
#include "mozilla/StaticPrefs_media.h"
|
||||
#include "mozilla/SyncRunnable.h"
|
||||
|
||||
#include "PerformanceRecorder.h"
|
||||
|
||||
|
@ -333,7 +334,18 @@ const char* DesktopCaptureImpl::CurrentDeviceName() const {
|
|||
}
|
||||
|
||||
static DesktopCaptureOptions CreateDesktopCaptureOptions() {
|
||||
DesktopCaptureOptions options = DesktopCaptureOptions::CreateDefault();
|
||||
DesktopCaptureOptions options;
|
||||
// Help avoid an X11 deadlock, see bug 1456101.
|
||||
#ifdef MOZ_X11
|
||||
MOZ_ALWAYS_SUCCEEDS(mozilla::SyncRunnable::DispatchToThread(
|
||||
mozilla::GetMainThreadSerialEventTarget(),
|
||||
NS_NewRunnableFunction(__func__, [&] {
|
||||
options = DesktopCaptureOptions::CreateDefault();
|
||||
})));
|
||||
#else
|
||||
options = DesktopCaptureOptions::CreateDefault();
|
||||
#endif
|
||||
|
||||
// Leave desktop effects enabled during WebRTC captures.
|
||||
options.set_disable_effects(false);
|
||||
|
||||
|
|
|
@ -270,9 +270,19 @@ void DesktopDeviceInfoImpl::CleanUpWindowList() {
|
|||
}
|
||||
|
||||
void DesktopDeviceInfoImpl::InitializeWindowList() {
|
||||
DesktopCaptureOptions options;
|
||||
// Help avoid an X11 deadlock, see bug 1456101.
|
||||
#ifdef MOZ_X11
|
||||
MOZ_ALWAYS_SUCCEEDS(mozilla::SyncRunnable::DispatchToThread(
|
||||
mozilla::GetMainThreadSerialEventTarget(),
|
||||
NS_NewRunnableFunction(__func__, [&] {
|
||||
options = DesktopCaptureOptions::CreateDefault();
|
||||
})));
|
||||
#else
|
||||
options = DesktopCaptureOptions::CreateDefault();
|
||||
#endif
|
||||
std::unique_ptr<DesktopCapturer> winCap =
|
||||
DesktopCapturer::CreateWindowCapturer(
|
||||
DesktopCaptureOptions::CreateDefault());
|
||||
DesktopCapturer::CreateWindowCapturer(options);
|
||||
DesktopCapturer::SourceList list;
|
||||
if (winCap && winCap->GetSourceList(&list)) {
|
||||
DesktopCapturer::SourceList::iterator itr;
|
||||
|
@ -379,9 +389,19 @@ void DesktopDeviceInfoImpl::CleanUpScreenList() {
|
|||
}
|
||||
|
||||
void DesktopDeviceInfoImpl::InitializeScreenList() {
|
||||
DesktopCaptureOptions options;
|
||||
// Help avoid an X11 deadlock, see bug 1456101.
|
||||
#ifdef MOZ_X11
|
||||
MOZ_ALWAYS_SUCCEEDS(mozilla::SyncRunnable::DispatchToThread(
|
||||
mozilla::GetMainThreadSerialEventTarget(),
|
||||
NS_NewRunnableFunction(__func__, [&] {
|
||||
options = DesktopCaptureOptions::CreateDefault();
|
||||
})));
|
||||
#else
|
||||
options = DesktopCaptureOptions::CreateDefault();
|
||||
#endif
|
||||
std::unique_ptr<DesktopCapturer> screenCapturer =
|
||||
DesktopCapturer::CreateScreenCapturer(
|
||||
DesktopCaptureOptions::CreateDefault());
|
||||
DesktopCapturer::CreateScreenCapturer(options);
|
||||
DesktopCapturer::SourceList list;
|
||||
if (screenCapturer && screenCapturer->GetSourceList(&list)) {
|
||||
DesktopCapturer::SourceList::iterator itr;
|
||||
|
|
Загрузка…
Ссылка в новой задаче