Opened 7 weeks ago

Closed 3 days ago

#13618 closed Bug Report - General (fixed)

Issue in macOS for playback of 480p/i videos on retina display

Reported by: John Hoyt Owned by: Mark Kendall
Priority: minor Milestone: 31.1
Component: MythTV - Video Playback Version: v31-fixes
Severity: medium Keywords: MacOS VideoToolbox
Cc: markk, David Hampton Ticket locked: no

Description

In macOS Catalina with a retina display the screen only renders the playback in the bottom left quarter of the screen. This only occurs for my when playing back 480p/480i videos (i.e. 1080p videos play fullscreen)

There are also times when the screen GUI (menus) on render in the bottom quarter of the screen but the jumps back to fullscreen view after digging through menus.

A bandaid fix to the problem is to select the app, hit get info, then select the "Open in Low Resolution".

I have attached an output of mythfrontend

Attachments (28)

mythfrontend.output.txt (33.7 KB) - added by John Hoyt 7 weeks ago.
Mythfrontend output
output.lowres.480p_video.txt (31.3 KB) - added by John Hoyt 6 weeks ago.
Mythfrontend out - low res set - 480 working fullscreen
output.NON_lowres.1080.working.txt (22.7 KB) - added by John Hoyt 6 weeks ago.
Mythfrontend outpu - NON low res - 1080p - working fullscreen
output.NON_lowresoutput.NON_lowres.1080.with_QT_env_var_eq_1.working.txt (77.0 KB) - added by John Hoyt 6 weeks ago.
Mythfrontend outpu - NON low res - 1080p - working fullscreen - QT_ENABLE_HIGHDPI_SCALING=1
output.NON_lowresoutput.NON_lowres.480.with_QT_env_var_eq_1.not_working.txt (64.7 KB) - added by John Hoyt 6 weeks ago.
Mythfrontend outpu - NON low res - 480 - not working fullscreen - QT_ENABLE_HIGHDPI_SCALING=1
output.sepvidemode.1080pand4801.txt (53.9 KB) - added by John Hoyt 6 weeks ago.
output with seperate video mode 1080p (working) 480i (not working)
output.sepvidemode.deinterlacersoff.1080pand4801.txt (48.7 KB) - added by John Hoyt 6 weeks ago.
output with seperate video mode - deinterlacers off - 1080p (working) 480i (not working)
highdpi.diff (5.5 KB) - added by Mark Kendall 6 weeks ago.
Debug and don't disable HighDPI setting
output.480i. QT_ENABLE_HIGHDPI_SCALING.eq.0.txt (28.0 KB) - added by John Hoyt 6 weeks ago.
patched output 480i QT_ENABLE_HIGHDPI_SCALING=0
output.480i. QT_ENABLE_HIGHDPI_SCALING.eq.1.txt (26.2 KB) - added by John Hoyt 6 weeks ago.
patched output 480i QT_ENABLE_HIGHDPI_SCALING=1
dpi2.diff (14.3 KB) - added by Mark Kendall 4 weeks ago.
Test patch - try and scale UI and video
macbookpro14.2560x1600.png (631.8 KB) - added by John Hoyt 4 weeks ago.
Macbook Pro 14" Screenshot
macbooprpo16.3584x2250.png (699.8 KB) - added by John Hoyt 4 weeks ago.
Macbook Pro 16" Screenshot
output.macbookpro14.2560x1600.txt (32.3 KB) - added by John Hoyt 4 weeks ago.
output from macbook pro 14" 2560x1600
macbooprpo16.3584x2250.2.png (699.8 KB) - added by John Hoyt 4 weeks ago.
output from macbook pro 16" 3584x2250
dpi3.diff (17.7 KB) - added by Mark Kendall 4 weeks ago.
output.osd.txt (82.3 KB) - added by John Hoyt 4 weeks ago.
Wrong OSD Size
OSD_wrong_Size scaled.png (484.7 KB) - added by John Hoyt 4 weeks ago.
Screenshot - OSD wrong size
dpi4.diff (19.3 KB) - added by Mark Kendall 4 weeks ago.
Screen Shot 2020-06-06 at 6.56.19 AM.png (565.5 KB) - added by John Hoyt 4 weeks ago.
Recordings shrunk screen
dpi5.diff (19.8 KB) - added by Mark Kendall 4 weeks ago.
dpi5.output.txt (19.2 KB) - added by John Hoyt 4 weeks ago.
DPI output from mythfrontend
Screen Shot 2020-06-06 at 1.46.05 PM.png (489.4 KB) - added by John Hoyt 4 weeks ago.
Screenshot of half working audio settings
dpi6.diff (19.1 KB) - added by Mark Kendall 4 weeks ago.
output.dpi6.txt (14.6 KB) - added by John Hoyt 4 weeks ago.
Output dpi6
dpi7.diff (17.7 KB) - added by Mark Kendall 3 weeks ago.
dpi8_master.diff (17.2 KB) - added by Mark Kendall 5 days ago.
Commit candidate - master/v32
dpi8_v31.diff (17.2 KB) - added by Mark Kendall 4 days ago.
Commit candidate - v31

Change History (67)

Changed 7 weeks ago by John Hoyt

Attachment: mythfrontend.output.txt added

Mythfrontend output

comment:1 Changed 7 weeks ago by ctreleaven

cc me

comment:2 Changed 6 weeks ago by Mark Kendall

Owner: changed from Peter Bennett to Mark Kendall
Status: newaccepted

comment:3 Changed 6 weeks ago by Mark Kendall

Status: acceptedinfoneeded

This is clearly related to:-

https://doc.qt.io/qt-5/highdpi.html

Unfortunately, my ageing macbook does not have a display that I can test with and I'm struggling to understand why the behaviour would be different when playing HD material - and indeed why there are no problems with the GUI.

Can you provide the same logs for:-

  • playback of HD material (i.e. when it works)
  • playback with SD material after 'Open in Low Resolution' works

As you are on Qt5.14, could you also try setting the 'QT_ENABLE_HIGHDPI_SCALING' environment variable and attach logs.

What happens if you enable video mode switching and try and change the GUI/video resolution to 2560x1600?

Changed 6 weeks ago by John Hoyt

Mythfrontend out - low res set - 480 working fullscreen

Changed 6 weeks ago by John Hoyt

Mythfrontend outpu - NON low res - 1080p - working fullscreen

Changed 6 weeks ago by John Hoyt

Mythfrontend outpu - NON low res - 1080p - working fullscreen - QT_ENABLE_HIGHDPI_SCALING=1

Changed 6 weeks ago by John Hoyt

Mythfrontend outpu - NON low res - 480 - not working fullscreen - QT_ENABLE_HIGHDPI_SCALING=1

comment:4 Changed 6 weeks ago by John Hoyt

Logs uploaded. No dice on setting QT_ENABLE_HIGHDPI_SCALING (I tried both QT_ENABLE_HIGHDPI_SCALING=1 and QT_ENABLE_HIGHDPI_SCALING=0).

Can you point me to where the video mode switching setting is buried? Happy to try setting it and then setting the GUI/video resolution.

comment:5 in reply to:  4 ; Changed 6 weeks ago by ctreleaven

Replying to jhoyt4:

...

Can you point me to where the video mode switching setting is buried? Happy to try setting it and then setting the GUI/video resolution.

The only such setting I'm aware of is in System Preferences > Energy Saver.

comment:6 in reply to:  5 Changed 6 weeks ago by John Hoyt

The only such setting I'm aware of is in System Preferences > Energy Saver.

Unfortunately, I don't see that setting in Energy Saver (nor in Displays)

comment:7 Changed 6 weeks ago by Mark Kendall

OK - progress of sorts:)

Firstly, video mode switching is accessed through 'Setup->Appearance->Separate video modes for GUI and TV playback'

If you enable that, you should then be able to select 2560x1600 for the GUI. Then just select the same resolution for 'Video output', 'Auto' for rate and 'Default' for 'Aspect'. (Using anything else for video playback may just confuse the issue and is not required for this case - as the display is native 2560x1600 and has a variable display rate - so there is no benefit in trying to use other video modes).

It would be interesting to see playback logs if that helps - though it is not a proper fix (it should work out of the box imho).

So I think the root cause of the problem is this line from the Qt docs:-

Typically, most applications work with device independent pixels; except for OpenGL and code for raster graphics.

So with a retina display, the windowing system is using 1280x800 for the mythfrontend window/widget, and this is what Qt is using/reports, but the underlying OpenGL context will be using the native display size (2560x1600).

The reason the HD video works and SD does not is not due to the different resolutions but because, in this case, the SD video is interlaced and the HD video is not. The mythtv opengl video code uses an intermediate framebuffer for deinterlacing (to improve performance) which triggers an OpenGL viewport change. The switch back to the regular/fullscreen viewport after deinterlacing is presumably where it all goes wrong - as the OpenGL context should be using 2560x1600 but is only set to 1280x800 (because that is the window size).

If you go into the details of the video display profile (Setup->Video->Playback->Current video Playback Profile - and then into the specific profile details) and disable all deinterlacing, playback *should* work.

The real head scratcher here, however, is why does the GUI work without issue? I note you said that sometimes it starts displaying in the bottom left and then reverts. Based on the assumption that the windowing system and OpenGL are using different resolutions, I don't honestly understand how it ever gets it right:)

I can only assume that there is some event received, perhaps after our window is setup, that triggers a change.

I'll pull together a debugging patch to see what is going on.

Longer term, we need a fix that works out of the box, regardless of system settings etc. Personally I don't think we want to be using a downscaled UI at all - if you are playing HD/4k material, it will just be unnecessarily downscaled - and then scaled up again by the OS; which is far from ideal.

Ideally we want to try and encourage/ensure Qt starts up with 2560x1600 (or the proper native resolution at least). I really want to avoid having to add workarounds for scaling factors etc (i.e. using https://doc.qt.io/qt-5/qwindow.html#devicePixelRatio).

What setting are you using for you macbook display? (https://support.apple.com/en-us/HT202471)

comment:8 Changed 6 weeks ago by John Hoyt

Display - Resolution set to "Default for display" (i.e. not scaled)

Setting up as follows (log uploaded):
Setup->Appearance->Separate video modes for GUI and TV playback checked
Setup->Appearance->Separate video modes for GUI and TV playback -> GUI -> 2560x1600
Setup->Appearance->Separate video modes for GUI and TV playback -> Video Output -> 2560x1600
App starts up with GUI in bottom left corner of screen
Navigate and on first click the GUI expands to fill the full screen
Playback of 1080p plays full screen
Navigate to videos - GUI stays fullscreen
Playback of 480i plays in bottom quarter of screen

Setting up as follows (log uploaded):
Setup->Appearance->Separate video modes for GUI and TV playback checked
Setup->Appearance->Separate video modes for GUI and TV playback -> GUI -> 2560x1600
Setup->Appearance->Separate video modes for GUI and TV playback -> Video Output -> 2560x1600
Setup->Video->Playback->VideoToobox?-> All deinterlacers turned off
App starts up with GUI in bottom left corner of screen
Navigate and on first click the GUI expands to fill the full screen
Playback of 1080p plays full screen
Navigate to videos - GUI stays fullscreen
Playback of 480i video - video plays in bottom left corner

Last edited 6 weeks ago by John Hoyt (previous) (diff)

Changed 6 weeks ago by John Hoyt

output with seperate video mode 1080p (working) 480i (not working)

Changed 6 weeks ago by John Hoyt

output with seperate video mode - deinterlacers off - 1080p (working) 480i (not working)

comment:9 Changed 6 weeks ago by Mark Kendall

Thanks John,

Unfortunately the switch to 2560x1600 is failing:-

2020-05-19 09:45:10.777729 E Display: Failed to change mode to 2560x1600@0.000Hz

Not sure if this is programmer error though... (just wondering if we are trying to switch modes before we have a main window - which will fail - I'll add that to the debug patch).

w.r.t to deinterlacing - unfortunately the extra framebuffer switch is still being triggered even without the deinterlacer - but I wouldn't worry about that for the moment.

More important is trying to figure out what is triggering the GUI to be adjusted when you navigate the menus. Very strange.

comment:10 Changed 6 weeks ago by John Hoyt

Just out of morbid curiosity, I set the GUI and playback screens to 1280x800. Confirmed 480i still plays in the bottom left corner. I can post a log entry if it will help.

Last edited 6 weeks ago by John Hoyt (previous) (diff)

Changed 6 weeks ago by Mark Kendall

Attachment: highdpi.diff added

Debug and don't disable HighDPI setting

comment:11 Changed 6 weeks ago by Mark Kendall

I've attached a debugging patch to try and get some better detail on what is going on internally.

It also removes the line (that I'd forgotten about) that disables the high dpi environment variable override - which is presumably why it didn't change anything.

Can you attach logs for playback of SD material with and without QT_ENABLE_HIGHDPI_SCALING set?

thanks, Mark

comment:12 Changed 6 weeks ago by John Hoyt

Output files uploaded. Just a note, both playback with and without QT_ENABLE_HIGHDPI_SCALING set played back in the bottom left corner of the screen (i.e. no full screen).

Changed 6 weeks ago by John Hoyt

patched output 480i QT_ENABLE_HIGHDPI_SCALING=0

Changed 6 weeks ago by John Hoyt

patched output 480i QT_ENABLE_HIGHDPI_SCALING=1

comment:13 Changed 6 weeks ago by John Hoyt

Apologies, just realise that I forgot to run last night with -v playback. I've just done so and uploaded the verbose files (replacing the previous ones).

Changed 4 weeks ago by Mark Kendall

Attachment: dpi2.diff added

Test patch - try and scale UI and video

comment:14 Changed 4 weeks ago by Mark Kendall

John - apologies for the delay. I've attached a test patch.

I'm reasonably confident the UI element is correct - though I'm still confused how the UI gets 'fixed' with the current code. The video element I'm less sure about - if nothing else, it is incomplete.

comment:15 Changed 4 weeks ago by Mark Kendall

Forgot to mention - this needs an up to date version of fixes/31. I pushed a change to track the device pixel ratio.

comment:16 Changed 4 weeks ago by John Hoyt

Mark, no apologies necessary - you're the one doing the heavy lifting.

I have confirmed that playback for 1080p and 480i video does playback fullscreen on both a Macbook Pro 14" with 2560x1600 screen and a Macbook Pro 16" with 3584x2250 screen (both running Catalina). This is without having to set "Open in Low Resolution" Mode.

...but Unfortunately there's now an issue where the menu renders the background in the upper left hand corner (see attached screenshots). This now occurs on both Macbooks.

Also attached are the logs for both macs (hoping they help).

Please let me know if you need me to run in a more verbose log setting.

Last edited 4 weeks ago by John Hoyt (previous) (diff)

Changed 4 weeks ago by John Hoyt

Attachment: macbookpro14.2560x1600.png added

Macbook Pro 14" Screenshot

Changed 4 weeks ago by John Hoyt

Attachment: macbooprpo16.3584x2250.png added

Macbook Pro 16" Screenshot

Changed 4 weeks ago by John Hoyt

output from macbook pro 14" 2560x1600

Changed 4 weeks ago by John Hoyt

output from macbook pro 16" 3584x2250

Changed 4 weeks ago by Mark Kendall

Attachment: dpi3.diff added

comment:17 Changed 4 weeks ago by Mark Kendall

OK - fingers crossed. dpi3.diff should fix the UI image sizing. If so, can you confirm that the OSD is displayed properly as well? Thanks, Mark

comment:18 Changed 4 weeks ago by John Hoyt

Getting close

Menus look good Playback looks good

OSD - wrong size (see picture and log)

Changed 4 weeks ago by John Hoyt

Attachment: output.osd.txt added

Wrong OSD Size

Changed 4 weeks ago by John Hoyt

Attachment: OSD_wrong_Size scaled.png added

Screenshot - OSD wrong size

comment:19 Changed 4 weeks ago by Mark Kendall

Milestone: needs_triage31.1

Changed 4 weeks ago by Mark Kendall

Attachment: dpi4.diff added

comment:20 Changed 4 weeks ago by Mark Kendall

dpi4.diff attached.

Fingers crossed again. Hopefully UI, video and OSD all working correctly - and if working, this version is something approaching suitable for pushing.

comment:21 Changed 4 weeks ago by John Hoyt

So close.

Playback works great. OSD is at the correct size. Menus look good navigating and in mythvideo.

Unfortunately there's now a new bug introduces in "recordings" where the UI renders in the top left corner.

Changed 4 weeks ago by John Hoyt

Recordings shrunk screen

comment:22 Changed 4 weeks ago by Mark Kendall

Is it just that screen? Nothing else?

comment:23 Changed 4 weeks ago by John Hoyt

Digging through the app a bit more - unfortunately no

Mythvideo in list view and gallery view is fine - but Browse view is incorrect*
Myththimage looks correct
Manage recordings is incorrect*
Information Center is incorrect*
Program Guide is incorrect*
Settings are incorrect* - if there's just a list of menus everything looks good, if there are settings things go wonky with some items rendering shrunk and other items showing full screen. Also when prompted to save the dialog box is shrunken
Theme Chooser is incorrect*
Exit menu is correct


* by incorrect - renders shrunken in upper lefthand corner of the screen

Changed 4 weeks ago by Mark Kendall

Attachment: dpi5.diff added

comment:24 Changed 4 weeks ago by Mark Kendall

John - not sure about latest change - though I can't think of any other reason why it would be failing.

comment:25 Changed 4 weeks ago by John Hoyt

Mark, unfortunately, the latest patch does not appear to change anything.

I'm going to attach the latest log file and a screenshot from settings to show the part works / part doesn't work problem.

I also just tried this on both the macbook pro 16 and 14 hoping the change in screen resolution would provide different behavior. It unfortunately did not.

Thanks again for working on this.

Changed 4 weeks ago by John Hoyt

Attachment: dpi5.output.txt added

DPI output from mythfrontend

Changed 4 weeks ago by John Hoyt

Screenshot of half working audio settings

Changed 4 weeks ago by Mark Kendall

Attachment: dpi6.diff added

comment:26 Changed 4 weeks ago by Mark Kendall

v6 added:) This was working correctly before??

comment:27 Changed 4 weeks ago by John Hoyt

Regretfully, still not working.

I believe it was only working because those using v30 or earlier had non-retina displays and/or set the "Open in Low Resolution" flag.

Last edited 4 weeks ago by John Hoyt (previous) (diff)

Changed 4 weeks ago by John Hoyt

Attachment: output.dpi6.txt added

Output dpi6

comment:28 Changed 4 weeks ago by Mark Kendall

John - I was referring to your earlier feedback from a previous patch:-

Getting close

Menus look good Playback looks good

OSD - wrong size (see picture and log)

So I'm assuming the menus were OK at that point?

comment:29 Changed 4 weeks ago by John Hoyt

On the recordings screen - yes. Can't speak for the settings.

comment:30 Changed 4 weeks ago by John Hoyt

I just recompiled with dpi3 and can confirm everything (and I mean all menus - went exhaustive) work. It's just the OSD that's buggered up.

Changed 3 weeks ago by Mark Kendall

Attachment: dpi7.diff added

comment:31 Changed 3 weeks ago by Mark Kendall

John - dpi7.diff is dpi3 with one modification to get the OSD scaled correctly.

comment:32 Changed 3 weeks ago by John Hoyt

That looks like it fixed the OSD. Playback and the menus also look good.

Thank you for helping get this fixed!!!

Last edited 3 weeks ago by John Hoyt (previous) (diff)

comment:33 Changed 13 days ago by John Hoyt

Mark, anything else I can help with to close out the ticket?

comment:34 Changed 10 days ago by Mark Kendall

John - sorry, just been a little busy. Need to find time to clean up the working version before committing. May need a little testing to ensure it is working correctly:)

Changed 5 days ago by Mark Kendall

Attachment: dpi8_master.diff added

Commit candidate - master/v32

comment:35 Changed 4 days ago by John Hoyt

Mark, I'm getting the following error on the patch file. Should I try this on a specific git revision or at head like I'm currently trying?

patching file mythtv/libs/libmythui/opengl/mythpainteropengl.cpp
Hunk #1 succeeded at 20 (offset 1 line).
Hunk #2 succeeded at 94 (offset -1 lines).
Hunk #3 FAILED at 126.
Hunk #4 FAILED at 151.
Hunk #5 succeeded at 245 (offset -1 lines).
Hunk #6 succeeded at 271 (offset -1 lines).
Hunk #7 succeeded at 279 (offset -1 lines).
Hunk #8 succeeded at 311 (offset -1 lines).

All of the rest of the files patched fine.

Last edited 4 days ago by John Hoyt (previous) (diff)

Changed 4 days ago by Mark Kendall

Attachment: dpi8_v31.diff added

Commit candidate - v31

comment:36 Changed 4 days ago by Mark Kendall

John - I'm assuming you need the v31 version (master has diverged a little). You will also need to do a 'make distclean' in the libs/libmythui source directory - otherwise it won't pick up that MythPainter? is now a QObject.

comment:37 Changed 4 days ago by John Hoyt

Thanks!

I'm going to blow away my local copy of the v31 repo and start from scratch. I've had some issues in the past with distclean not getting everything and want to make sure I build the "correct" version.

Last edited 4 days ago by John Hoyt (previous) (diff)

comment:38 Changed 4 days ago by John Hoyt

Mark, I just finished testing and everything looks like it's working.

Thank you very very much for fixing all of the issues!!!

comment:39 Changed 3 days ago by Mark Kendall <mark.kendall@…>

Resolution: fixed
Status: infoneededclosed

In 19e8d9d0cf/mythtv:

macos: Handle high DPI displays

  • behaviour should be unchanged for non-macos installations
  • the underlying problem is that when macos is using high DPI, the

windowing system reports e.g. 1920x1080 as the window size but the
underlying OpenGL context is using the full resolution e.g. 3840x2160.

  • video playback is actually easiest - as we just scale the video

window/viewport as needed - and everything else falls into place.

  • the UI painter is slightly more complicated as our UI images are at

the lower resolution - and the entire UI code is operating on the
reported window size. So scale incoming rendering data as required,
which also requires some tweaking of the texture vertices.

Closes #13618

Note: See TracTickets for help on using tickets.