Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad Video Playback Performance (on Mac) #144

Closed
Calvin-Xu opened this issue Jan 18, 2023 · 7 comments
Closed

Bad Video Playback Performance (on Mac) #144

Calvin-Xu opened this issue Jan 18, 2023 · 7 comments
Labels
bug Something isn't working

Comments

@Calvin-Xu
Copy link
Contributor

Previously I mentioned how my HD630 desktop was not able to play video at 4K output resolutions in Memento, and I had to switch to 1080P output system-wide.

Lately I discovered my 16" Intel MacBook Pro, using AMD Radeon Pro 5500M 8 GB, also struggles to playback video smoothly at the display's native resolution (3072 × 1920), and I have been expanding the subtitlelistwidget to make the playback area smaller to keep video playback smooth.

I have not investigated whether a specific commit caused this or what the bottleneck might be. So far I can only say that a build with OCR disabled does not seem better.

@ripose-jp
Copy link
Owner

I doubt it's a GPU bottleneck given the specs. Can you take a screenshot of the statistics of a video that lags your MacBook in both Memento and mpv playing at full resolution? You can show stats with Shift+I.

@Calvin-Xu
Copy link
Contributor Author

Calvin-Xu commented Jan 20, 2023

After some testing I found this is not a Memento problem. After playing the identical video clip for about two minutes, mpv also started dropping frames.

Memento:
memento

mpv:
mpv

mpv produced the following stacktrace that I also got from Memento. I have never seem this before, but it looks to be caused by MacOS update and windowing/fullscreen related again. There is an issue already, mpv-player/mpv#11018, but nobody seem to mention dropped frames there, so maybe it is unrelated. After starting playback and fullscreening either Memento or mpv, I did not change window size of switch desktops; only let the videos play.

1   HIToolbox                           0x00007ff81183f726 _ZN15MenuBarInstance22EnsureAutoShowObserverEv + 102
2   HIToolbox                           0x00007ff81183f2b8 _ZN15MenuBarInstance14EnableAutoShowEv + 52
3   HIToolbox                           0x00007ff8117aecd7 _ZN15MenuBarInstance21UpdateAggregateUIModeE21MenuBarAnimationStylehhh + 1113
4   HIToolbox                           0x00007ff81183f173 _ZN15MenuBarInstance19SetFullScreenUIModeEjj + 175
5   AppKit                              0x00007ff80b3104b7 -[NSApplication _setPresentationOptions:instance:flags:] + 1145
6   AppKit                              0x00007ff80b165165 -[NSApplication _updateFullScreenPresentationOptionsForInstance:] + 582
7   CoreFoundation                      0x00007ff807e7f3f4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 137
8   CoreFoundation                      0x00007ff807f1943a ___CFXRegistrationPost_block_invoke + 88
9   CoreFoundation                      0x00007ff807f19389 _CFXRegistrationPost + 536
10  CoreFoundation                      0x00007ff807e52919 _CFXNotificationPost + 735
11  Foundation                          0x00007ff808c8cf2c -[NSNotificationCenter postNotificationName:object:userInfo:] + 82
12  AppKit                              0x00007ff80b310b28 spacesNotificationHandler + 119
13  SkyLight                            0x00007ff80caae74d _ZN12_GLOBAL__N_123notify_datagram_handlerEj15CGSDatagramTypePvmS1_ + 1030
14  SkyLight                            0x00007ff80cdc104a _ZN21CGSDatagramReadStream26dispatchMainQueueDatagramsEv + 202
15  SkyLight                            0x00007ff80cdc0f71 ___ZN21CGSDatagramReadStream15mainQueueWakeupEv_block_invoke + 18
16  libdispatch.dylib                   0x00007ff807c2d7fb _dispatch_call_block_and_release + 12
17  libdispatch.dylib                   0x00007ff807c2ea44 _dispatch_client_callout + 8
18  libdispatch.dylib                   0x00007ff807c3b7b9 _dispatch_main_queue_drain + 952
19  libdispatch.dylib                   0x00007ff807c3b3f3 _dispatch_main_queue_callback_4CF + 31
20  CoreFoundation                      0x00007ff807ec8610 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
21  CoreFoundation                      0x00007ff807e88b90 __CFRunLoopRun + 2454
22  CoreFoundation                      0x00007ff807e87b80 CFRunLoopRunSpecific + 560
23  HIToolbox                           0x00007ff8117cc766 RunCurrentEventLoopInMode + 292
24  HIToolbox                           0x00007ff8117cc576 ReceiveNextEventCommon + 679
25  HIToolbox                           0x00007ff8117cc2b3 _BlockUntilNextEventMatchingListInModeWithFilter + 70
26  AppKit                              0x00007ff80afd3f33 _DPSNextEvent + 909
27  AppKit                              0x00007ff80afd2db4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1219
28  AppKit                              0x00007ff80afc53f7 -[NSApplication run] + 586
29  mpv                                 0x00000001005b69f5 cocoa_main + 757
30  dyld                                0x00007ff807a7b310 start + 2432
AV: 00:00:09 / 00:23:41 (1%) A-V:  0.001 DS: 2.380/12 Dropped: 32
[osd/libass] fontselect: Using default font family: (sans, 400, 0) -> /System/Library/Fonts/Helvetica.ttc, -1, Helvetica
[osd/libass] fontselect: Using default font family: (sans, 700, 0) -> /System/Library/Fonts/Helvetica.ttc, -1, Helvetica-Bold
AV: 00:00:43 / 00:23:41 (3%) A-V:  0.006 DS: 0.840/68 Dropped: 255
Audio device underrun detected.
AV: 00:00:46 / 00:23:41 (3%) A-V:  0.009 DS: 0.760/74 Dropped: 306
Audio device underrun detected.
AV: 00:00:51 / 00:23:41 (4%) A-V:  0.011 DS: 0.670/85 Dropped: 405
Audio device underrun detected.
AV: 00:00:54 / 00:23:41 (4%) A-V:  0.017 DS: 0.680/90 Dropped: 454
Audio device underrun detected.
1   HIToolbox                           0x00007ff8117cc0c2 _ZN15MenuBarInstance22RemoveAutoShowObserverEv + 30
2   HIToolbox                           0x00007ff8117aece3 _ZN15MenuBarInstance21UpdateAggregateUIModeE21MenuBarAnimationStylehhh + 1125
3   HIToolbox                           0x00007ff8117ae7a4 _ZN15MenuBarInstance16ForEachMenuBarDoEU13block_pointerFvPS_E + 46
4   HIToolbox                           0x00007ff8117ae762 SetSystemUIMode + 209
5   AppKit                              0x00007ff80b3104c3 -[NSApplication _setPresentationOptions:instance:flags:] + 1157
6   AppKit                              0x00007ff80b165185 -[NSApplication _updateFullScreenPresentationOptionsForInstance:] + 614
7   CoreFoundation                      0x00007ff807e7f3f4 __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 137
8   CoreFoundation                      0x00007ff807f1943a ___CFXRegistrationPost_block_invoke + 88
9   CoreFoundation                      0x00007ff807f19389 _CFXRegistrationPost + 536
10  CoreFoundation                      0x00007ff807e52919 _CFXNotificationPost + 735
11  Foundation                          0x00007ff808c8cf2c -[NSNotificationCenter postNotificationName:object:userInfo:] + 82
12  AppKit                              0x00007ff80b310b28 spacesNotificationHandler + 119
13  SkyLight                            0x00007ff80caae74d _ZN12_GLOBAL__N_123notify_datagram_handlerEj15CGSDatagramTypePvmS1_ + 1030
14  SkyLight                            0x00007ff80cdc104a _ZN21CGSDatagramReadStream26dispatchMainQueueDatagramsEv + 202
15  SkyLight                            0x00007ff80cdc0f71 ___ZN21CGSDatagramReadStream15mainQueueWakeupEv_block_invoke + 18
16  libdispatch.dylib                   0x00007ff807c2d7fb _dispatch_call_block_and_release + 12
17  libdispatch.dylib                   0x00007ff807c2ea44 _dispatch_client_callout + 8
18  libdispatch.dylib                   0x00007ff807c3b7b9 _dispatch_main_queue_drain + 952
19  libdispatch.dylib                   0x00007ff807c3b3f3 _dispatch_main_queue_callback_4CF + 31
20  CoreFoundation                      0x00007ff807ec8610 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
21  CoreFoundation                      0x00007ff807e88b90 __CFRunLoopRun + 2454
22  CoreFoundation                      0x00007ff807e87b80 CFRunLoopRunSpecific + 560
23  HIToolbox                           0x00007ff8117cc766 RunCurrentEventLoopInMode + 292
24  HIToolbox                           0x00007ff8117cc576 ReceiveNextEventCommon + 679
25  HIToolbox                           0x00007ff8117cc2b3 _BlockUntilNextEventMatchingListInModeWithFilter + 70
26  AppKit                              0x00007ff80afd3f33 _DPSNextEvent + 909
27  AppKit                              0x00007ff80afd2db4 -[NSApplication(NSEvent) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 1219
28  AppKit                              0x00007ff80afc53f7 -[NSApplication run] + 586
29  mpv                                 0x00000001005b69f5 cocoa_main + 757
30  dyld                                0x00007ff807a7b310 start + 243
➜ mpv -v
[cplayer] Command line options: '-v'
[cplayer] mpv 0.35.0 Copyright © 2000-2022 mpv/MPlayer/mplayer2 projects
[cplayer]  built on Thu Nov 17 13:14:07 UTC 2022
[cplayer] FFmpeg library versions:
[cplayer]    libavutil       57.28.100
[cplayer]    libavcodec      59.37.100
[cplayer]    libavformat     59.27.100
[cplayer]    libswscale      6.7.100
[cplayer]    libavfilter     8.44.100
[cplayer]    libswresample   4.7.100
[cplayer] FFmpeg version: 5.1.2

@ripose-jp
Copy link
Owner

I've noticed the stacktrace as well when switching windows while Memento is fullscreened. It doesn't seem to cause any issues beyond spamming standard error. Since it's probably an mpv thing, I think it's best to just let them sort it out.

As for the dropped frames, I can think of a few possible causes.

  • Drivers for the 5500M are poorly optimized for OpenGL on macOS.
  • macOS is rendering Memento and mpv using your iGPU instead of the dGPU.
    • I am of the opinion that this shouldn't matter on a 2019 Intel laptop as either should be sufficient for 24 FPS at 4K.
  • There is some inefficiency in the mpv rendering pipeline.
    • I don't think this is likely because high resolutions would lead to dropped frames on other platforms.

I'm going to mark this as a can't fix and leave it open since the problem affects mpv as well. I also don't have the requisite hardware to recreate the issue.

@ripose-jp ripose-jp added bug Something isn't working can't fix For some reason or another this issue cannot be fixed labels Jan 21, 2023
@Calvin-Xu
Copy link
Contributor Author

Just want to say after trying various other fixes I gave up and went with hwdec=no. No dropped frames so I can't really complain.

@ripose-jp
Copy link
Owner

Interesting. Memento enables hwdec=auto-safe in spite of the mpv docs advising hwdec=no. Did you override that with some other value in your mpv.conf or did you let Memento decide?

@Calvin-Xu
Copy link
Contributor Author

Calvin-Xu commented May 16, 2023

I overrode it with hwdec=no in mpv.conf. Previously I had no entries touching this value.

On this note I might add that I did this after comparing playing the same video file in IINA (default config) and noticing that it was not using hardware decoding.

@ripose-jp ripose-jp removed the can't fix For some reason or another this issue cannot be fixed label May 17, 2023
@ripose-jp
Copy link
Owner

Thanks for letting me know about the fix. I'm going to stop enabling hwdec by default and close this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants