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

opening selector multiple times will cause the selection to fail, is it a input.select API bug? #15795

Open
6 tasks done
verygoodlee opened this issue Feb 3, 2025 · 2 comments · May be fixed by #15796
Open
6 tasks done
Labels

Comments

@verygoodlee
Copy link
Contributor

mpv Information

mpv v0.39.0-723-g38ad1ed0 Copyright © 2000-2025 mpv/MPlayer/mplayer2 projects
 built on Feb  1 2025 17:04:54
libplacebo version: v7.350.0 (v7.349.0-30-g056b852-dirty)
FFmpeg version: N-118392-g0113e3080
FFmpeg library versions:
   libavcodec      61.31.101
   libavdevice     61.4.100
   libavfilter     10.9.100
   libavformat     61.9.106
   libavutil       59.56.100
   libswresample   5.4.100
   libswscale      8.13.100

Other Information

- Windows version: Win10 22H2
- GPU model, driver and version:
- Source of mpv: https://github.com/zhongfly/mpv-winbuild/releases/tag/2025-02-02-38ad1ed
- Latest known working version:
- Issue started after the following happened:

Reproduction Steps

  • bind alt+s to close console and open subtitle selector
alt+s    script-message-to console disable; script-binding select/select-sid
  • play any video with subtitles
  • press alt+s two times
  • press enter to select any subtitle

Expected Behavior

subtitle selected

Actual Behavior

nothing happened

Log File

log.txt

Sample Files

N/A

I carefully read all instruction and confirm that I did the following:

  • I tested with the latest mpv version to validate that the issue is not already fixed.
  • I provided all required information including system and mpv version.
  • I produced the log file with the exact same set of files, parameters, and conditions used in "Reproduction Steps", with the addition of --log-file=output.txt.
  • I produced the log file while the behaviors described in "Actual Behavior" were actively observed.
  • I attached the full, untruncated log file.
  • I attached the backtrace in the case of a crash.
@guidocella
Copy link
Contributor

That's not supported currently as the interactions with console are asynchronous so closing it and reopening it immediately unregisters the event listener of the new call.

@verygoodlee
Copy link
Contributor Author

verygoodlee commented Feb 3, 2025

So there's no issue if input.lua does not depend on console.lua.
However, doing so would result in a lot of duplicate code, which may not be worth it.

another issue found earlier is that input.select() does not support nesting, which seems to be the same reason.

input.select({
    ...
    submit = function(i)
        input.terminate()
        input.select({
             ...
             -- can't callback
             submit = function(j)
             end,
        })
    end,
})

guidocella added a commit to guidocella/mpv that referenced this issue Feb 3, 2025
Currently using mp.input while the console is open doesn't do anything.
We can allow using mp.input multiple times in a row by keeping the
console open, and sending a closed event only when the previous calling
script is different from the current one. If it is the same, sending a
closed event would unregister the new input-event listener, so it is
just never sent in this case as there is no sane way to do it.

Fixes mpv-player#15795.
@guidocella guidocella linked a pull request Feb 3, 2025 that will close this issue
guidocella added a commit to guidocella/mpv that referenced this issue Feb 3, 2025
Currently using mp.input while the console is open doesn't do anything.
We can allow using mp.input multiple times in a row by keeping the
console open, and sending a closed event only when the previous calling
script is different from the current one. If it is the same, sending a
closed event would unregister the new input-event listener, so it is
just never sent in this case as there is no sane way to do it.

Fixes mpv-player#15795.
guidocella added a commit to guidocella/mpv that referenced this issue Feb 4, 2025
Currently using mp.input while the console is open doesn't do anything.
We can allow using mp.input multiple times in a row by keeping the
console open, and sending a closed event only when the previous calling
script is different from the current one. If it is the same, sending a
closed event would unregister the new input-event listener, so it is
just never sent in this case as there is no sane way to do it. This is
useful e.g. to try out select script bindings in the console, or to
switch to a different mp.input script binding with a key binding without
having to close the current one.

Calling input.select() again within input.select()'s submit handler
needs to be fixed separately because with select the console is
immediately closed on submit (367a6b5), so input.lua receives submit,
requests a new selection, and receives closed wich unregisters the
handler of the new selection. Just not calling
mp.unregister_script_message("input-event") fixes it; its only purpose
was to allow garbage collection of variables defined in the scope using
mp.input.

Fixes mpv-player#15795.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants