Hardware video decoders can use wrong SyncObjectClient causing tearing/wrong frames to be displayed
Categories
(Core :: Graphics, defect)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox160 | --- | fixed |
People
(Reporter: aosmond, Assigned: aosmond)
References
Details
(Keywords: perf-alert)
Attachments
(4 external files)
In order to synchronize hardware video decoding with the compositor, it will prefer to use D3D11 fences and/or decoding on the compositor device. When those are unavailable, we can use a shared sync object via SyncObjectD3D11Client and SyncObjectD3D11Host.
On SWGL + D3D11, we get one sync object for our single ID3D11Device using for compositing. That means all windows will share the same the same sync object:
https://searchfox.org/firefox-main/rev/d0e0fc69c10b345e8e1a83bae3d2da774970704d/gfx/webrender_bindings/RenderCompositorD3D11SWGL.cpp#72
On full HW-WR, we get one sync object per RenderCompositorANGLE, which maps to each window:
https://searchfox.org/firefox-main/rev/d0e0fc69c10b345e8e1a83bae3d2da774970704d/gfx/webrender_bindings/RenderCompositorANGLE.cpp#168
Now normally the latter isn't a problem, but today we get the sync handle we want via TextureFactoryIdentifier when the video decoder is created. Since a tab can move between windows, that means we can end up using the wrong sync object. This can cause tearing and frame skips (but is otherwise safe). This won't happen with SWGL + D3D11 since it is always the same sync object.
Because it can be very complicated to synchronize which sync object the video decoder should be using, I think we should just follow the same model from SWGL + D3D11 with HW-WR. Most users are not impacted by this since they have D3D11 fence support, or they use the same ID3D11Device for compositing and decoding:
https://searchfox.org/firefox-main/rev/d0e0fc69c10b345e8e1a83bae3d2da774970704d/gfx/thebes/DeviceManagerDx.cpp#1178
Doing so will not only fix flickering issues for these users, it will also make refactors such as bug 2082607 safer.
| Assignee | ||
Updated•29 days ago
|
| Assignee | ||
Comment 1•28 days ago
|
||
The reuse decoder device feature was only recorded when the pref was on, and it
showed as enabled even when reuse could not happen: on AMD it was forced on
outside of gfxConfig, and it did not account for software WebRender or a
compositor device without video support. Fence support was not reported at all.
Together these decide whether video uses the D3D11 sync object.
The parent now decides decoder device reuse, including the AMD requirement, in
InitPlatformHardwareVideoConfig, using the adapter from gfxInfo like the
blocklist does. The GPU process reports whether the compositor device supports
video and fences in D3D11DeviceStatus, which is used to report whether the
compositor device is actually reused.
gfx.direct3d11.reuse-decoder-device.force-disabled disables reuse even where it
is required, and gfx.direct3d11.fences-enabled can turn fences off. Together
they force video onto the sync object on hardware that would otherwise use
fences or a shared device.
| Assignee | ||
Comment 2•28 days ago
|
||
Each RenderCompositorANGLE created its own sync object, so a video decoder only
synchronized with the window whose sync handle it was given. That window may
not be the one compositing the video, for example after its tab moved to
another window, or it may be gone. SWGL with D3D11 already shared one sync
object per device through DeviceAttachmentsD3D11.
DeviceManagerDx now creates the sync object together with the compositor
device and drops it with the device. It is handed out together with the device,
so a compositor always gets the sync object of the device it renders with:
DeviceAttachmentsD3D11 receives it when created, and RenderThread keeps it with
the singleton GL context that ANGLE renders with. It is also created for WARP
devices, which ANGLE already did; the WARP exception dated from Windows 7.
SyncObjectHost becomes atomically refcounted because it is now shared across
threads. A sync object timeout on any window still triggers a device reset, as
before, but every window now waits on the same keyed mutex.
| Assignee | ||
Comment 3•28 days ago
|
||
CompositorD3D11 acquired the sync object at the start of every frame, while
RenderCompositorANGLE only does so while a registered texture needs it
(RenderThread::SyncObjectNeeded). Both now share the same sync object, so give
SWGL with D3D11 the same behaviour, including handling a timeout as a device
reset instead of skipping the frame or crashing.
| Assignee | ||
Comment 4•28 days ago
|
||
These textures always have a write fence, which LockInternal waits on, and the
producer never registers them with the sync object. Requesting the sync object
only made the compositors acquire its keyed mutex for nothing.
Updated•28 days ago
|
Comment 6•26 days ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/e9f895b479bd
https://hg.mozilla.org/mozilla-central/rev/55ccc25015e7
https://hg.mozilla.org/mozilla-central/rev/fb885e00b773
https://hg.mozilla.org/mozilla-central/rev/f420c8f42bb4
Comment 7•19 days ago
|
||
Perfherder has detected a talos performance change from push f420c8f42bb4e8ee67b1f19cc7608779e477bf3d.
No action is required from the author; this comment is provided for informational purposes only.
| Improvement | Test | Platform | Options | Absolute values [old vs new] |
|---|---|---|---|---|
| 2% | tart (doc) | windows11-64-24h2-shippable | e10s fission stylo webrender-sw | 1.83 -> 1.79 |
Need Help or Information?
If you have any questions, please reach out to acseh@mozilla.com. Alternatively, you can find help on Slack by joining #perf-help, and on Matrix you can find help by joining #perftest.
Details of the alert can be found in the alert summary, including links to graphs and comparisons for each of the affected tests.
| Assignee | ||
Comment 8•19 days ago
|
||
What fun, the unnecessary sync was causing us 2% on SWGL + D3D11 compositing! Easy win.
Updated•19 days ago
|
Description
•