Skip to content

Conversation

low-batt
Copy link
Contributor

This commit will:

  • Add methods displayActive and displayIdle to VideoView

  • Add use of a Timer to delay stopping the display link

  • Change MPVController to ensure display link is running while seeking

  • Change PlayerCore to ensure display link is running while stepping

  • Change MainWindowController to ensure display link is running when entering and leaving full screen mode

  • I have read CONTRIBUTING.md

  • This implements/fixes issue Lag when scrolling horizontally to seek in build 1.3.0 and 1.3.1 #4153.


Description:

@low-batt low-batt linked an issue Mar 20, 2023 that may be closed by this pull request
@low-batt
Copy link
Contributor Author

See the issue for an analysis of the problem.

There one case the proposed fix does not cover. In order to properly support the user sending commands directly to mpv through the IPC interface, control of the display link should be based on events from mpv. This works for seeking:

echo '{ "command": ["seek", "5"] }' | socat - /tmp/mpv-socket | jq

It does not work for stepping:

echo '{ "command": ["frame-step"] }' | socat - /tmp/mpv-socket | jq

Directly commanding mpv to step through the IPC interface works, but it does cause mpv to report "mpv_render_report_swap() not being called". This is because the code that insures the display link is working for stepping is in PlayerCore.frameStep and not in MPVController in response to a mpv event. That is because I was unable to find a mpv event that IINA can key off of for stepping.

This commit will:
- Add methods displayActive and displayIdle to VideoView
- Add use of a Timer to delay stopping the display link
- Change MPVController to ensure display link is running while seeking
- Change PlayerCore to ensure display link is running while stepping
- Change MainWindowController to ensure display link is running when
  entering and leaving full screen mode

Rebased with develop and corrected merge conflicts.
@low-batt
Copy link
Contributor Author

Rebased with develop and corrected merge conflicts.

@low-batt low-batt requested a review from uiryuu March 27, 2023 03:50
// When playback is paused the display link is stopped in order to avoid wasting energy on
// It must be running when stepping to avoid slowdowns caused by mpv waiting for IINA to call
// mpv_render_report_swap.
mainWindow.videoView.displayActive()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems even if the display link is not running, frame step commands can run correctly. Do we have to activate the display link manually?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stepping, seeking, all currently work because mpv will timeout and continue on. When that happens mpv will complain:

[  14.169][v][vo/libmpv] mpv_render_report_swap() not being called.

We can tolerate some of this happening, but IINA should always try and avoid it. We don't want to see lots of these warnings from mpv when IINA is working correctly. For one thing that could hide other problems that trigger this warning that should not be occurring.

Because mpv does not give us an event to key off of (at least not that I could find) we have to tolerate this situation if the user sends a step command behind the back of IINA directly to mpv using the IPC interface. Unfortunate, but I don't see a way to deal with that situation.

This commit will:
- Add methods displayActive and displayIdle to VideoView
- Add use of a Timer to delay stopping the display link
- Change MPVController to ensure display link is running while seeking
- Change PlayerCore to ensure display link is running while stepping
- Change MainWindowController to ensure display link is running when
  entering and leaving full screen mode

Rebased with develop and corrected merge conflicts.
Corrected PlayerCore.frameStep as per review comment.
@svobs
Copy link
Contributor

svobs commented Mar 28, 2023

Very good fix! Looks like it has secondary improvements too like snappier & more reliable OSD updating.

@uiryuu uiryuu merged commit 067f2a9 into develop Mar 28, 2023
@uiryuu uiryuu deleted the fix-4153 branch March 28, 2023 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Lag when scrolling horizontally to seek in build 1.3.0 and 1.3.1
3 participants