Opened 9 years ago

Closed 7 years ago

Last modified 6 years ago

#12311 closed Bug Report - General (Invalid)

tearing on full-screen video playback when 2D glamor accell is enabled

Reported by: warpme@… Owned by: Peter Bennett
Priority: minor Milestone: 30.0
Component: MythTV - Video Playback Version: Master Head
Severity: medium Keywords: tearing glamor
Cc: Ticket locked: no

Description

Tear-free 2D glamor accell (used by default by all radeonsi and also recommended for intel) with current xorg server requires alignment between X11 root window size/position and application window (myth). If both root window and app window have equal size&position - graphic stack can turn-off glamor and use DRI based vsync for frame page flipping. This can give tearing free video playback without expensive video frame copies. On current master with: 'separate video modes' disabled; "Use GUI size for TV playback" and "Use fixed window size" enabled, I can't achieve tear-free playabck, because X11 root window and Myth window are not aligned:

root window:

xrandr
Screen 0: minimum 320 x 200, current 1920 x 1080, maximum 16384 x 16384
HDMI-0 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 820mm x 460mm
   1920x1080      50.0*+   60.0     50.0     59.9     24.0     24.0  
   1920x1080i     60.1     50.0     60.0  
   1600x1200      60.0  
   1400x1050      59.9  
   1280x1024      60.0  
   1360x768       60.0  
   1280x720       60.0     50.0     59.9  
   1440x576i      50.1  
   1024x768       75.1     70.1     60.0  
   1440x480i      60.1     60.1  
   800x600        72.2     75.0     60.3     56.2  
   720x576        50.0  
   720x480        60.0     59.9  
   640x480        75.0     72.8     60.0     59.9  
   720x400        70.1  
DVI-0 disconnected (normal left inverted right x axis y axis)
VGA-0 disconnected (normal left inverted right x axis y axis)

mythtv window: gui

xwininfo: Window id: 0x1600050 "MythTV Frontend"

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1920
  Height: 1080
  Depth: 24
  Visual: 0x21
  Visual Class: TrueColor
  Border width: 1
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  --2+0  --2--2  +0--2
  -geometry 1920x1080+0+0

myth window: video playback

xwininfo: Window id: 0x1600050 "MythTV Frontend"

  Absolute upper-left X:  -1
  Absolute upper-left Y:  -1
  Relative upper-left X:  -1
  Relative upper-left Y:  -1
  Width: 1920
  Height: 1080
  Depth: 24
  Visual: 0x21
  Visual Class: TrueColor
  Border width: 1
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +-1+-1  --1+-1  --1--1  +-1--1
  -geometry 1920x1080+-1+-1

Missaligment causing tearing. xorg log shows:

[1561601.461] (--) RADEON(0): HDMI max TMDS frequency 170000KHz
[1561609.906] DRI2CanFlip: Window clipList doesn\'t match root window dimensions:
[1561609.906] Window clipList extents: (1, 1)-(1920, 1080)
[1561609.906] Root window extents: (0, 0)-(1920, 1080)
[1561609.906] Can\'t flip because DRI2CanFlip failed
[1561609.941] DRI2CanFlip: Window clipList doesn\'t match root window dimensions:
[1561609.941] Window clipList extents: (1, 1)-(1920, 1080)
[1561609.941] Root window extents: (0, 0)-(1920, 1080)
[1561609.941] Can\'t flip because DRI2CanFlip failed
[1561611.345] DRI2CanFlip: Window clipList doesn\'t match root window dimensions:

It is also interesting that after any video playback, GUI & video starts to have thesame pos/size (but still missaligned to X11 root window):

xwininfo: Window id: 0x1600050 "MythTV Frontend"

  Absolute upper-left X:  -1
  Absolute upper-left Y:  -1
  Relative upper-left X:  -1
  Relative upper-left Y:  -1
  Width: 1920
  Height: 1080
  Depth: 24
  Visual: 0x21
  Visual Class: TrueColor
  Border width: 1
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +-1+-1  --1+-1  --1--1  +-1--1
  -geometry 1920x1080+-1+-1

Another, parralel issue is when 'separate video modes' option is enabled: In such case playback start to have also cropped height.

mythtv window: GUI

xwininfo: Window id: 0x16000e3 "MythTV Frontend"

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1920
  Height: 1080
  Depth: 24
  Visual: 0x21
  Visual Class: TrueColor
  Border width: 1
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  --2+0  --2--2  +0--2
  -geometry 1920x1080+0+0

mythtv window: video playback:

xwininfo: Window id: 0x16000e3 "MythTV Frontend"

  Absolute upper-left X:  -1
  Absolute upper-left Y:  -1
  Relative upper-left X:  -1
  Relative upper-left Y:  -1
  Width: 1920
  Height: 1078
  Depth: 24
  Visual: 0x21
  Visual Class: TrueColor
  Border width: 1
  Class: InputOutput
  Colormap: 0x20 (installed)
  Bit Gravity State: NorthWestGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +-1+-1  --1+-1  --1-1  +-1-1
  -geometry 1920x1078+-1+-1

Attachments (2)

0212-ticket12311.patch (1.9 KB) - added by warpme@… 9 years ago.
Patch for 0.28
0212-ticket12311-v2.patch (2.3 KB) - added by warpme@… 7 years ago.
Patch for current master

Download all attachments as: .zip

Change History (19)

comment:1 Changed 9 years ago by warpme@…

Attached patch solves issue for me. It was tested on Cabin HD8310 and playback is tear-free. First hunk is more hack that solution addressing root cause. I think this area of MythTV code should be reworked as now (with glamor becoming default 2D accell arch) fullscreen mythtv window and X root window should be properly aligned (in terms size and position). Second hunk makes GUI and playback windows position the same. It was easier to adapt GUI window coordinates to playback window coordinates than doing this vice-versa - although I think proper solution should fix playback window coordinates (now they are -1,-1 while should be 0,0)

Changed 9 years ago by warpme@…

Attachment: 0212-ticket12311.patch added

Patch for 0.28

comment:2 Changed 9 years ago by JYA

If this is a patch for when something is active (and so,etching new at that) why would your patch modify the default behaviour then?

If making a hack, limit the scope of that hack so it's only active under very strict condition, or fix the core issue itself...

Enough hack in MythTV code I say

comment:3 Changed 9 years ago by warpme@…

Regarding windows coordinates (second hunk) - I was trying to address it with proper _playback window coordinates_ - but finally achieving this becomes beyond of my MythTV code knowledge. (I'm really missing that MythTV coding standard isn't forcing to comment by default...). First hunk (related to window size) seems to be already within hack (tv_play.cpp line1255). I don't know why in my system (X mode to TV set always to 1080p50), maxHeight = display_res->GetMaxHeight?(); returns 1200. In all my those frontends with X modes lower than fullHD, display_res->GetMaxHeight?() returns expected values. I suspect issue that 1920x1080 display returns 1920x1200 is kind of bug....If it is bug - then currently I haven't better idea to overcome it....

comment:4 Changed 7 years ago by warpme@…

Here is link for debugging patch for 1.19 Xorg server allowing to debug window clipping / window dimension.

https://github.com/warpme/minimyth2/blob/master/script/xorg/xorg-server/files/xorg-server-1.19.3-debug-page-flipping.patch

pls use it it for verifying that mythv clipping area matches myth widow.

Changed 7 years ago by warpme@…

Attachment: 0212-ticket12311-v2.patch added

Patch for current master

comment:5 Changed 7 years ago by Peter Bennett

Owner: changed from JYA to Peter Bennett
Status: newassigned

I did already make some changes for the case where you use different video modes for playback. There were multiple bugs there (see #7408 #11363 #13054).

You mention: 'separate video modes' disabled; "Use GUI size for TV playback" and "Use fixed window size" enabled. - I would think that it would be best to turn off "Use GUI size for TV playback", because you want to use full screen. Does that help?

I don't know if I can test this. What is the hardware setup and the playback profile setting?

comment:6 Changed 7 years ago by warpme@…

Peter, thx for replay. I must go out of town for business trip next days - but I'll try check current code remotely. HW setup needed for testing is: current xorg (1.19+); current mesa (17+); and ATI HW like HD6300+. Mine HW is AMD E2100 with HD 8310. I'll report if will be able to test remotely...

comment:7 Changed 7 years ago by Peter Bennett

I have only NVidia cards in my computers, but I also have integrated intel graphics and I have two spare old ATI adapters

  • 1 very old 128MB ATI Radeon X300 SE
  • 1 old ATI Radeon HD 4350 512MB

Is any of this helpful in testing the bug? I suppose I will have to remove the NVidia drivers and install ATI drivers. Any ideas on the best way to do this?

Also - what playback profile do you use? Is it VDPAU, VAAPI, or something else?

comment:8 Changed 7 years ago by warpme@…

Peter, X300 is way too old. 4350 was subject of intensive discussion in mesa community about should such old HW be supported with vdpau or not. I believe it is today. So with 4350 we can try. You need: recent xorg server (1.19+); mesa 17+. Will be good to have also recent kernel+drm to have DRI3 working. Lets put DRI thing for latter stage. Key is to have HW decode stack operating. We need to have working playback with VDPAU (where mesa provides VDPAU API to HW decode). Pls try to: install desired SW to your distro (sorry I can't be more specific here as I'm doing this purely package-by-package in mm2); setup HW; configure myth vdpau; achieve state where You can have VDPAU working playback on 4350. Let me know if You need any second brain here - I'll love to help...

comment:9 Changed 7 years ago by warpme@…

PS: I'm still in business trip and and can't launch my ATI HW remotely :-(. I'll be back at 8.08.2017....

comment:10 Changed 7 years ago by warpme@…

Peter, I finally give run for current 29-fixes. Good hing is that there is no more issue with 1px shift when playback starts. Now GUI and video are drawing in exactly the same area on main x screen.

I see however 2px miss-aligment between main x screen and myth drawing area.

xwininfo outputs:

xwininfo: Window id: 0x1600005 "MythTV Frontend"

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1920
  Height: 1080
  Depth: 24
  Visual: 0x30f
  Visual Class: TrueColor
  Border width: 1
  Class: InputOutput
  Colormap: 0x1600001 (installed)
  Bit Gravity State: ForgetGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  --2+0  --2--2  +0--2
  -geometry 1920x1080+0+0

pls look at corners: there is 2px shift between main window and myth window corners. This causes xserver to turn-off page flipping thus tearing on video playback.

comment:11 Changed 7 years ago by Peter Bennett

I am using ubuntu 16.04. Xorg.log shows version as X.Org X Server 1.18.4. Mesa libraries look like they are 12.0.6. Maybe I need a newer version?

My plan is to use only ubuntu LTS versions, the next one is 18.04.

I have an Intel VGA controller in a laptop, maybe that would work, so that I don't have to switch VGA cards in another machine to the old ATI adapter that may or may not support glamor.

VGA compatible controller: Intel Corporation Device 5916 (rev 02) (prog-if 00 [VGA controller])
Subsystem: Acer Incorporated [ALI] Device 1094
Flags: bus master, fast devsel, latency 0, IRQ 129
Memory at b0000000 (64-bit, non-prefetchable) [size=16M]
Memory at a0000000 (64-bit, prefetchable) [size=256M]
I/O ports at 4000 [size=64]
Expansion ROM at <unassigned> [disabled]
Capabilities: [40] Vendor Specific Information: Len=0c <?>
Capabilities: [70] Express Root Complex Integrated Endpoint, MSI 00
Capabilities: [ac] MSI: Enable+ Count=1/1 Maskable- 64bit-
Capabilities: [d0] Power Management version 2
Capabilities: [100] #1b
Capabilities: [200] Address Translation Service (ATS)
Capabilities: [300] #13
Kernel driver in use: i915_bpo
Kernel modules: i915_bpo

Looking at some web sites it seems that glamor is for OpenGL. Does it work for you if you select OpenGL video playback?

comment:12 Changed 7 years ago by warpme@…

Peter, I think we can make whole thing easier to work on by doing it steep by steep.

First thing I think we need to verify is misalignment between Xroot window and myth window in FS mode.

Currently I see 2ps misalignment - and this causes issue with tearing in case when Xorg 2D accell is based on OpenGL (glamour way of things) (DDX way has workaround for such cases built-in in Xorg server - that's why issue popup with glamour).

This issue is more Xwindows aspect than HW accell decode - so You probably can catch/test this issue on any system. Simply use xwininfo tool to verify how myth draws it's FS window into X root window. I used this in #comment:10 and there You can see 2px shift.

In MiniMyth2 I have workaround which plays with window coordinates and workarounds issue (so users of mm2 don't have tearing) - but this patch is crude workaround - not proper solution...

Path is here: https://github.com/warpme/minimyth2/blob/master/script/myth-master/mythtv/files/0212-ticket12311-v2.patch

it is possible when we fix misalignment issue - whole page flipping issue causing tearing will go away...

comment:13 Changed 7 years ago by Peter Bennett

This is on Master (V30-Pre) Frontend setup: I set as follows

  • GUI dimension: full screen (0 0 0 0)
  • All checkboxes under GUI dimension unchecked
  • Separate video modes for GUI and playback unchecked
  • Playback profile OpenGL Slim or VAAPI both give same result

xrandr

peter@raza:~$ xrandr
Screen 0: minimum 8 x 8, current 1920 x 1080, maximum 32767 x 32767
eDP1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 344mm x 193mm
   1920x1080     60.01*+  59.93  
   1680x1050     59.95    59.88  
   1600x1024     60.17  
   1400x1050     59.98  
   1600x900      60.00  
   1280x1024     60.02  
   1440x900      59.89  
   1280x960      60.00  
   1368x768      60.00  
   1360x768      59.80    59.96  
   1152x864      60.00  
   1280x720      60.00  
   1024x768      60.00  
   1024x576      60.00  
   960x540       60.00  
   800x600       60.32    56.25  
   864x486       60.00  
   640x480       59.94  
   720x405       60.00  
   640x360       60.00  
DP1 disconnected (normal left inverted right x axis y axis)
HDMI1 disconnected (normal left inverted right x axis y axis)
VIRTUAL1 disconnected (normal left inverted right x axis y axis)

xwininfo on MythTV GUI

xwininfo: Window id: 0x4600004 "MythTV Frontend"

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1920
  Height: 1080
  Depth: 24
  Visual: 0xd1
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x4600001 (not installed)
  Bit Gravity State: ForgetGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  -0+0  -0-0  +0-0
  -geometry 1920x1080+0+0

xwininfo while playing a 1920x1080 recording

xwininfo: Window id: 0x4600004 "MythTV Frontend"

  Absolute upper-left X:  0
  Absolute upper-left Y:  0
  Relative upper-left X:  0
  Relative upper-left Y:  0
  Width: 1920
  Height: 1080
  Depth: 24
  Visual: 0xd1
  Visual Class: TrueColor
  Border width: 0
  Class: InputOutput
  Colormap: 0x4600001 (not installed)
  Bit Gravity State: ForgetGravity
  Window Gravity State: NorthWestGravity
  Backing Store State: NotUseful
  Save Under State: no
  Map State: IsViewable
  Override Redirect State: no
  Corners:  +0+0  -0+0  -0-0  +0-0
  -geometry 1920x1080+0+0

I do not see any strange corners or offsets. Is there something special I have to do to see them?

comment:14 Changed 7 years ago by Peter Bennett

I think maybe the problem is your xwininfo shows border width 1 and mine shows 0.

Could this be caused by the window manager? I am using xfce.

You can try to run without a window manager. This is how I do that:

  • Stop the display manager service (in my case sudo systemctl stop lightdm.service). This will log you off.
  • Press ctl-alt-F1 to get a login prompt
  • Login text mode
  • startx /usr/share/bin/mythfrontend

You have to give the full path for mythfrontend, it does not search the path for it.

Without the window manager you will not have access to xwininfo. Instead you could start xterm from startx and from xterm launch mythfrontend and xwininfo.

comment:15 Changed 7 years ago by warpme@…

Peter, Indeed issue was within my window manager. Now it is fixed and all seems to be working as expected. Million thx for Your work on #7408 #11363 and also on this ticket. It can be closed with status: fixed. Thx again!

comment:16 Changed 7 years ago by Stuart Auchterlonie

Milestone: unknown30.0
Resolution: Invalid
Status: assignedclosed

Closing at original reporters request.

comment:17 Changed 6 years ago by Peter Bennett

Owner: changed from Peter Bennett to Peter Bennett
Note: See TracTickets for help on using tickets.