Closed Bug 1800213 Opened 2 years ago Closed 2 years ago

Improve the screen capture threading model

Categories

(Core :: WebRTC: Audio/Video, task, P2)

task

Tracking

()

RESOLVED FIXED
112 Branch
Tracking Status
firefox112 --- fixed

People

(Reporter: pehrsons, Assigned: pehrsons)

References

(Blocks 1 open bug)

Details

Attachments

(5 files)

The ScreenCaptureThread is currently an old libwebrtc class. On Windows it is specialized (UI) subclass of this that we built on top of this old libwebrtc class.

Alternatives exist, for instance base::Thread which is a chromium import that we use for ipc. I also think it would be easy enough to get the support we need (the ui thread on windows) out of nsThread.

Then we also use this thread differently on different platforms. On Windows we use a (platform) timer to drive the frame capturing. On Linux and Mac we run the capturing in a busy-loop, even though the thread has a task queue. This needed some special treatment to work.

I'm thinking once we have an nsSerialEventTarget (which base::Thread and nsThread both implement) we can run the capturing with an nsTimer instead. We'll have to try out a bit how it behaves under load on single-core machines, but I think it could be decent.

Blocks: 1800215
Depends on: 1804061
Blocks: 1806646

VideoCapture used to be a base::Thread called VideoCapture.
DesktopCapture used to be a rtc::PlatformThread/PlatformUIThread called ScreenCaptureThread.

Mozification: With this patch desktop capture runs on an nsThread, driven by an
nsTimer.

The logic for scheduling the timer is similar to the non-win32 cases prior to
this patch, but this patch also takes into account the wall-clock duration of
the frame capture. This should result in more accurate framerates when the
capture is fast enough (less than 50% of the wall-clock budget of the requested
framerate).

Attachment #9310833 - Attachment description: Bug 1800213 - Allow the existing (but now as nsThreads) VideoCapture and DesktopCapture threads. r?andi! → Bug 1800213 - Allow the existing (but now as nsThreads) VideoCapture and DesktopCapture threads. r?KrisWright!
Attachment #9311840 - Attachment description: Bug 1800213 - Improve frame time logic in DesktopCaptureImpl. r?ng! → Bug 1800213 - Improve frame time logic in DesktopCaptureImpl. r?ng!, r?karlt!
Pushed by pehrsons@gmail.com: https://hg.mozilla.org/integration/autoland/rev/9bb34476446b Update WPT expectations. r=webrtc-reviewers,ng https://hg.mozilla.org/integration/autoland/rev/1aa7bb249577 Allow the existing (but now as nsThreads) VideoCapture and DesktopCapture threads. r=KrisWright https://hg.mozilla.org/integration/autoland/rev/49cab24f10f9 Add a flag for creating nsThreads with a NONMAINUITHREAD MessageLoop. r=xpcom-reviewers,nika https://hg.mozilla.org/integration/autoland/rev/6ac26b111043 Mozify the threading model and timer driver in desktop_capture_impl. r=karlt,webrtc-reviewers,ng https://hg.mozilla.org/integration/autoland/rev/ec2dfdd59ba1 Improve frame time logic in DesktopCaptureImpl. r=ng,karlt
Blocks: 1769714
Regressions: 1821477
Regressions: 1826483
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: