Skip to content

Conversation

@guidocella
Copy link
Contributor

This paragraph was added 10 years ago in f8dc5db. Hooks are now commonly used both in internal (ytdl_hook, auto_profiles) and external scripts (e.g. https://github.com/mpv-player/mpv/issues?q=mp.add_hook). They are the only way to handle events synchronously and nobody is just going to change the API and break all scripts at this point, so remove the warning.

Copy link
Member

@Dudemanguy Dudemanguy left a comment

Choose a reason for hiding this comment

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

Yeah no point in scaring people.

no API stability guarantees made. Not following the protocol exactly can make
the player freeze randomly. Basically, nobody should use this API.
events are supposed to be asynchronous, and the hook API provides a way to
handle events that require stricter coordination.
Copy link
Member

Choose a reason for hiding this comment

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

Not following the protocol exactly can make the player freeze randomly.

Should be left intact. The hook api may be used, but is still dangerous tool in hands on scripts, and should be used with caution.

Not following the protocol exactly can make the player freeze randomly. Use with caution, avoid if possible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How would it freeze randomly though? We even call yt-dlp in a hook and it doesn't freeze.

Copy link
Member

@kasper93 kasper93 Nov 14, 2025

Choose a reason for hiding this comment

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

If you don't trigger next hook from script it will wait and hang forever. Generally scripts shouldn't be able to interrupt main player loop.

(I think in lua the process is mostly automatic, but hooks in general require careful use)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Apparently in the C api you have to call mpv_hook_continue but this is done automatically in scripts. But I think "randomly" makes it sound like it will occasionally break unpredictably. If you don't continue mpv will freeze, it is not random.

Copy link
Contributor

Choose a reason for hiding this comment

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

The message can be changed to:

Not following the protocol exactly can make the player freeze. Use with caution, avoid if synchronous event handling is not required.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's much better.

This paragraph was added 10 years ago in f8dc5db. Hooks are now
commonly used both in internal (ytdl_hook, auto_profiles) and external
scripts (e.g. https://github.com/mpv-player/mpv/issues?q=mp.add_hook).
They are the only way to handle events synchronously and nobody is just
going to change the API and break all scripts at this point, so remove
the warning.
@sfan5 sfan5 merged commit f6c1164 into mpv-player:master Nov 21, 2025
8 checks passed
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.

5 participants