mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 1818685 - Disable video overlay if mVideoSwapChain->Present() is very slow on Windows r=gfx-reviewers,lsalzman
There were cases that mVideoSwapChain->Present() took long time. It caused low fps and stuttering and lots of dropped frames. When it happens, disabling video overlay could address the problem. Differential Revision: https://phabricator.services.mozilla.com/D171039
This commit is contained in:
parent
8924fd2459
commit
c28b3ba4ed
@ -1099,13 +1099,37 @@ void DCSurfaceVideo::PresentVideo() {
|
||||
return;
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
hr = mVideoSwapChain->Present(0, 0);
|
||||
auto start = TimeStamp::Now();
|
||||
HRESULT hr = mVideoSwapChain->Present(0, 0);
|
||||
auto end = TimeStamp::Now();
|
||||
|
||||
if (FAILED(hr) && hr != DXGI_STATUS_OCCLUDED) {
|
||||
gfxCriticalNoteOnce << "video Present failed: " << gfx::hexa(hr);
|
||||
}
|
||||
|
||||
mPrevTexture = mRenderTextureHost;
|
||||
|
||||
// Disable video overlay if mVideoSwapChain->Present() is too slow. It drops
|
||||
// fps.
|
||||
|
||||
if (!StaticPrefs::gfx_webrender_dcomp_video_check_slow_present()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const auto maxWaitDurationMs = 2.0;
|
||||
const auto maxSlowPresentCount = 5;
|
||||
const auto duration = (end - start).ToMilliseconds();
|
||||
|
||||
if (duration > maxWaitDurationMs) {
|
||||
mSlowPresentCount++;
|
||||
} else {
|
||||
mSlowPresentCount = 0;
|
||||
}
|
||||
|
||||
if (mSlowPresentCount > maxSlowPresentCount) {
|
||||
gfxCriticalNoteOnce << "Video swapchain present is slow";
|
||||
RenderThread::Get()->HandleWebRenderError(WebRenderError::VIDEO_OVERLAY);
|
||||
}
|
||||
}
|
||||
|
||||
DXGI_FORMAT DCSurfaceVideo::GetSwapChainFormat() {
|
||||
|
@ -353,6 +353,7 @@ class DCSurfaceVideo : public DCSurface {
|
||||
bool mFailedYuvSwapChain = false;
|
||||
RefPtr<RenderTextureHost> mRenderTextureHost;
|
||||
RefPtr<RenderTextureHost> mPrevTexture;
|
||||
int mSlowPresentCount = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -6528,6 +6528,10 @@
|
||||
type: bool
|
||||
value: @IS_EARLY_BETA_OR_EARLIER@
|
||||
mirror: once
|
||||
- name: gfx.webrender.dcomp-video-check-slow-present
|
||||
type: RelaxedAtomicBool
|
||||
value: true
|
||||
mirror: always
|
||||
- name: gfx.video.convert-i420-to-nv12.force-enabled
|
||||
type: bool
|
||||
value: false
|
||||
|
Loading…
Reference in New Issue
Block a user